static void gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser) { GtkWidget *box; GtkWidget *label; GtkWidget *scrolled_window; GtkWidget *alignment; gchar *str; chooser->priv = GVC_SOUND_THEME_CHOOSER_GET_PRIVATE (chooser); #if GTK_CHECK_VERSION (3, 0, 0) chooser->priv->theme_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #else chooser->priv->theme_box = gtk_hbox_new (FALSE, 0); #endif gtk_box_pack_start (GTK_BOX (chooser), chooser->priv->theme_box, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic (_("Sound _theme:")); gtk_box_pack_start (GTK_BOX (chooser->priv->theme_box), label, FALSE, FALSE, 0); chooser->priv->combo_box = gtk_combo_box_new (); gtk_box_pack_start (GTK_BOX (chooser->priv->theme_box), chooser->priv->combo_box, FALSE, FALSE, 6); gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->combo_box); chooser->priv->sound_settings = g_settings_new (KEY_SOUNDS_SCHEMA); g_signal_connect (G_OBJECT (chooser->priv->sound_settings), "changed", G_CALLBACK (on_key_changed), chooser); str = g_strdup_printf ("<b>%s</b>", _("C_hoose an alert sound:")); chooser->priv->selection_box = box = gtk_frame_new (str); g_free (str); label = gtk_frame_get_label_widget (GTK_FRAME (box)); gtk_label_set_use_underline (GTK_LABEL (label), TRUE); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE); alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0); gtk_container_add (GTK_CONTAINER (alignment), box); gtk_box_pack_start (GTK_BOX (chooser), alignment, TRUE, TRUE, 6); alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 0, 0); gtk_container_add (GTK_CONTAINER (box), alignment); chooser->priv->treeview = create_alert_treeview (chooser); gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->treeview); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (scrolled_window), chooser->priv->treeview); gtk_container_add (GTK_CONTAINER (alignment), scrolled_window); chooser->priv->click_feedback_button = gtk_check_button_new_with_mnemonic (_("Enable _window and button sounds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->priv->click_feedback_button), g_settings_get_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY)); gtk_box_pack_start (GTK_BOX (chooser), chooser->priv->click_feedback_button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (chooser->priv->click_feedback_button), "toggled", G_CALLBACK (on_click_feedback_toggled), chooser); setup_theme_selector (chooser); update_theme (chooser); setup_list_size_constraint (scrolled_window, chooser->priv->treeview); }
static void init_capplet (void) { GtkWidget *dialog; GtkWidget *preview; GtkWidget *treeview; GtkWidget *list_scroller; GtkWidget *activate_delay_hscale; GtkWidget *activate_delay_hbox; GtkWidget *label; GtkWidget *enabled_checkbox; GtkWidget *lock_checkbox; GtkWidget *root_warning_label; GtkWidget *preview_button; GtkWidget *gpm_button; GtkWidget *fullscreen_preview_window; GtkWidget *fullscreen_preview_previous; GtkWidget *fullscreen_preview_next; GtkWidget *fullscreen_preview_area; GtkWidget *fullscreen_preview_close; char *gtk_builder_file; gdouble activate_delay; gboolean enabled; gboolean is_writable; GSettings *settings; GError *error=NULL; gint mode; gtk_builder_file = g_build_filename (GTKBUILDERDIR, GTK_BUILDER_FILE, NULL); builder = gtk_builder_new(); if (!gtk_builder_add_from_file(builder, gtk_builder_file, &error)) { g_warning("Couldn't load builder file: %s", error->message); g_error_free(error); } g_free (gtk_builder_file); if (builder == NULL) { dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not load the main interface")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Please make sure that the screensaver is properly installed")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); exit (1); } preview = GTK_WIDGET (gtk_builder_get_object (builder, "preview_area")); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "prefs_dialog")); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview")); list_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "themes_scrolled_window")); activate_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale")); activate_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hbox")); enabled_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox")); lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox")); root_warning_label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label")); preview_button = GTK_WIDGET (gtk_builder_get_object (builder, "preview_button")); gpm_button = GTK_WIDGET (gtk_builder_get_object (builder, "gpm_button")); fullscreen_preview_window = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_window")); fullscreen_preview_area = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_area")); fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close")); fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button")); fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button")); label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale); label = GTK_WIDGET (gtk_builder_get_object (builder, "savers_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview); gtk_widget_set_no_show_all (root_warning_label, TRUE); widget_set_best_colormap (preview); if (! is_program_in_path (GPM_COMMAND)) { gtk_widget_set_no_show_all (gpm_button, TRUE); gtk_widget_hide (gpm_button); } activate_delay = config_get_activate_delay (&is_writable); ui_set_delay (activate_delay); if (! is_writable) { gtk_widget_set_sensitive (activate_delay_hbox, FALSE); } g_signal_connect (activate_delay_hscale, "format-value", G_CALLBACK (format_value_callback_time), NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), config_get_lock (&is_writable)); if (! is_writable) { gtk_widget_set_sensitive (lock_checkbox, FALSE); } g_signal_connect (lock_checkbox, "toggled", G_CALLBACK (lock_checkbox_toggled), NULL); enabled = config_get_enabled (&is_writable); ui_set_enabled (enabled); if (! is_writable) { gtk_widget_set_sensitive (enabled_checkbox, FALSE); } g_signal_connect (enabled_checkbox, "toggled", G_CALLBACK (enabled_checkbox_toggled), NULL); setup_list_size_constraint (list_scroller, treeview); gtk_widget_set_size_request (preview, 480, 300); gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver"); gtk_window_set_icon_name (GTK_WINDOW (fullscreen_preview_window), "screensaver"); gtk_drag_dest_set (dialog, GTK_DEST_DEFAULT_ALL, drop_types, G_N_ELEMENTS (drop_types), GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE); g_signal_connect (dialog, "drag-motion", G_CALLBACK (drag_motion_cb), NULL); g_signal_connect (dialog, "drag-leave", G_CALLBACK (drag_leave_cb), NULL); g_signal_connect (dialog, "drag-data-received", G_CALLBACK (drag_data_received_cb), NULL); gtk_widget_show_all (dialog); /* Update list of themes if using random screensaver */ settings = g_settings_new (GSETTINGS_SCHEMA); mode = g_settings_get_enum (settings, KEY_MODE); if (mode == GS_MODE_RANDOM) { gchar **list; list = get_all_theme_ids (theme_manager); g_settings_set_strv (settings, KEY_THEMES, (const gchar * const*) list); g_strfreev (list); } g_signal_connect (settings, "changed", G_CALLBACK (key_changed_cb), NULL); g_object_unref (settings); preview_clear (preview); gs_job_set_widget (job, preview); if (check_is_root_user ()) { setup_for_root_user (); } g_signal_connect (activate_delay_hscale, "value-changed", G_CALLBACK (activate_delay_value_changed_cb), NULL); g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL); g_signal_connect (preview_button, "clicked", G_CALLBACK (fullscreen_preview_start_cb), treeview); g_signal_connect (fullscreen_preview_close, "clicked", G_CALLBACK (fullscreen_preview_cancelled_cb), NULL); g_signal_connect (fullscreen_preview_previous, "clicked", G_CALLBACK (fullscreen_preview_previous_cb), NULL); g_signal_connect (fullscreen_preview_next, "clicked", G_CALLBACK (fullscreen_preview_next_cb), NULL); g_idle_add ((GSourceFunc)setup_treeview_idle, NULL); }