Пример #1
0
/**
 * gva_main_init:
 *
 * Initializes the main window.
 *
 * This function should be called once when the application starts.
 **/
void
gva_main_init (void)
{
        GSettings *settings;
        gchar *text;

        settings = gva_get_settings ();

        gva_tree_view_init ();

        gtk_box_pack_start (
                GTK_BOX (GVA_WIDGET_MAIN_VBOX),
                gva_ui_get_managed_widget ("/main-menu"),
                FALSE, FALSE, 0);

        gtk_box_reorder_child (
                GTK_BOX (GVA_WIDGET_MAIN_VBOX),
                gva_ui_get_managed_widget ("/main-menu"), 0);

        gtk_widget_set_sensitive (
                GVA_WIDGET_MAIN_MUTE_BUTTON,
                gva_mame_supports_sound ());

        g_settings_bind (
                settings, GVA_SETTING_SOUND_MUTED,
                GVA_WIDGET_MAIN_MUTE_BUTTON, "muted",
                G_SETTINGS_BIND_DEFAULT);

        gtk_window_move (
                GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW),
                g_settings_get_int (settings, "window-x"),
                g_settings_get_int (settings, "window-y"));

        gtk_window_resize (
                GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW),
                g_settings_get_int (settings, "window-width"),
                g_settings_get_int (settings, "window-height"));

        if (g_settings_get_boolean (settings, "window-maximized"))
                gtk_window_maximize (GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW));

        /* Initialize the search entry. */
        text = gva_main_get_last_search_text ();
        gtk_entry_set_text (GTK_ENTRY (GVA_WIDGET_MAIN_SEARCH_ENTRY), text);
        g_free (text);

        gva_ui_lock ();

        gtk_action_set_visible (GVA_ACTION_INSERT_FAVORITE, FALSE);
        gtk_action_set_visible (GVA_ACTION_REMOVE_FAVORITE, FALSE);

        gtk_window_present (GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW));
}
Пример #2
0
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;
}