X-Git-Url: https://harishankar.org/repos/?p=wordblah.git;a=blobdiff_plain;f=wordblah_player.c;h=50a1c57a2cfd5c7bb863422415ee48f92a90a0a7;hp=26dab2991e2579e7226f9ba8e4aec7e9f925eed3;hb=HEAD;hpb=2aac9fd96329b27dffec6534a042cfbe045f3a11 diff --git a/wordblah_player.c b/wordblah_player.c index 26dab29..50a1c57 100644 --- a/wordblah_player.c +++ b/wordblah_player.c @@ -57,7 +57,7 @@ gboolean on_down_list_selection_changed (GtkTreeSelection *sel, GtkTreeIter iter; GtkTreeModel* mod; - if (gtk_tree_selection_get_selected (sel, &mod, &iter)) + if (gtk_tree_selection_get_selected (sel, &mod, &iter) == TRUE) { guint sel_word_index; gtk_tree_model_get (mod, &iter, 0, &sel_word_index, -1); @@ -78,7 +78,7 @@ gboolean on_across_list_selection_changed (GtkTreeSelection *sel, GtkTreeIter iter; GtkTreeModel* mod; - if (gtk_tree_selection_get_selected (sel, &mod, &iter)) + if (gtk_tree_selection_get_selected (sel, &mod, &iter) == TRUE) { guint sel_word_index; gtk_tree_model_get (mod, &iter, 0, &sel_word_index, -1); @@ -554,7 +554,30 @@ void on_menu_load_grid_state_activate (GtkMenuItem *item, GtkDrawingArea *area) { char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - load_user_data (&app_data, filename); + MainPlayerData temp; + load_user_data (&temp, filename); + /* if the puzzle file is invalid or the grid is frozen */ + if (temp.puzzle.grid_size == 0 || + temp.puzzle.grid_frozen == false) + { + GtkWidget *errordlg; + char message[256]; + if (temp.puzzle.grid_size == 0) + strcpy (message, INVALID_PUZZLE); + else + strcpy (message, UNFROZEN_GRID_PLAYER); + + errordlg = gtk_message_dialog_new (GTK_WINDOW(main_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s",message); + gtk_dialog_run (GTK_DIALOG(errordlg)); + gtk_widget_destroy (errordlg); + + } + else + app_data = temp; g_free (filename); } @@ -622,15 +645,22 @@ void on_menu_open_activate (GtkMenuItem *item, GtkDrawingArea* area) MainPlayerData temp; reset_player_data (&temp, filename); - /* if the grid is not frozen then the game cannot be played */ - if (temp.is_loaded == false) + /* if the puzzle is either an invalid puzzle file or grid is not frozen + then the game cannot be played */ + if (temp.puzzle.grid_size == 0 || temp.is_loaded == false) { GtkWidget *errordlg ; + char message[256]; + if (temp.puzzle.grid_size == 0) + strcpy (message, INVALID_PUZZLE); + else + strcpy (message, UNFROZEN_GRID_PLAYER); + errordlg = gtk_message_dialog_new (GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, - UNFROZEN_GRID_PLAYER); + "%s",message); gtk_dialog_run (GTK_DIALOG(errordlg)); gtk_widget_destroy (errordlg); } @@ -659,7 +689,8 @@ void on_menu_about_activate (GtkMenuItem *item, gpointer data) "comments", COMMENTS, "website", WEBSITE, "website-label", WEBSITE_LABEL, - "license-type", GTK_LICENSE_GPL_2_0, + "license-type", GTK_LICENSE_CUSTOM, + "license", LICENSE_BSD, "version", VERSION, (char*)NULL); }