/** * gva_main_execute_search: * * Executes a game database search and configures the main window to * display the results. More precisely, the function saves the search * entry contents to GConf, switches to the Search Results view, forces * an update, ensures a row in the resulting game list is selected, and * gives focus to the main tree view. * * The SQL expression used in the database search is retrieved from * gva_main_get_search_expression(). It is applied while updating the * Search Results view. **/ void gva_main_execute_search (void) { GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeView *view; GtkTreeIter iter; GtkEntry *entry; gchar *text; entry = GTK_ENTRY (GVA_WIDGET_MAIN_SEARCH_ENTRY); view = GTK_TREE_VIEW (GVA_WIDGET_MAIN_TREE_VIEW); selection = gtk_tree_view_get_selection (view); /* Save the search entry text. */ text = g_strdup (gtk_entry_get_text (entry)); gtk_entry_set_text (entry, g_strstrip (text)); gva_main_set_last_search_text (text); g_free (text); /* Force a tree view update. */ if (gva_tree_view_get_selected_view () != 2) gva_tree_view_set_selected_view (2); else { GError *error = NULL; gva_tree_view_update (&error); gva_error_handle (&error); } /* Select something in the tree view. Parts of this are * copied from gva_tree_view_set_selected_game(). */ if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { if (gtk_tree_model_get_iter_first (model, &iter)) { GtkTreePath *path; path = gtk_tree_model_get_path (model, &iter); gtk_tree_view_set_cursor (view, path, NULL, FALSE); gtk_tree_view_scroll_to_cell ( view, path, NULL, TRUE, 0.5, 0.0); gtk_tree_path_free (path); } } gtk_widget_grab_focus (GTK_WIDGET (view)); }
static void rompath_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type) { static GtkWidget *dialog = NULL; gint response; if (dialog != NULL) return; /* Filter out events we don't care about. */ switch (event_type) { case G_FILE_MONITOR_EVENT_CHANGED: case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_DELETED: case G_FILE_MONITOR_EVENT_CREATED: break; default: return; } dialog = gtk_message_dialog_new_with_markup ( GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "<big><b>%s</b></big>", _("Changes detected in ROM files")); gtk_message_dialog_format_secondary_text ( GTK_MESSAGE_DIALOG (dialog), _("GNOME Video Arcade has detected changes in your " "ROM files and will need to audit them in order to " "update the game list. However the audit may take " "several minutes to complete. Would you like to " "perform the audit now?\n\nIf you skip the audit now, " "it will be performed automatically the next time you " "start GNOME Video Arcade.")); gtk_dialog_add_buttons ( GTK_DIALOG (dialog), _("_Skip Audit"), GTK_RESPONSE_NO, _("_Audit ROM Files"), GTK_RESPONSE_YES, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); /* Don't destroy the dialog just yet. If the file monitor * trips again while we're analyzing ROMs, we want the NULL * check at the top of the function to evaluate TRUE so we * return immediately. */ gtk_widget_hide (dialog); if (response == GTK_RESPONSE_YES) { GError *error = NULL; gva_ui_lock (); gva_main_analyze_roms (&error); gva_error_handle (&error); gva_tree_view_update (&error); gva_error_handle (&error); gva_ui_unlock (); /* Present a helpful dialog if no ROMs were found. */ warn_if_no_roms (); } else { /* Don't bother the user again during this session. */ g_signal_handlers_disconnect_by_func ( monitor, rompath_changed_cb, NULL); } gtk_widget_destroy (dialog); dialog = NULL; }