static void
panel_properties_dialog_opacity_scale_setup (PanelPropertiesDialog *dialog,
					     GtkBuilder            *gui)
{
	GtkWidget *opacity_label;
	GtkWidget *opacity_legend;

	dialog->opacity_scale = PANEL_GTK_BUILDER_GET (gui, "opacity_scale");
	g_return_if_fail (dialog->opacity_scale != NULL);
	opacity_label = PANEL_GTK_BUILDER_GET (gui, "opacity_label");
	g_return_if_fail (opacity_label != NULL);
	opacity_legend = PANEL_GTK_BUILDER_GET (gui, "opacity_legend");
	g_return_if_fail (opacity_legend != NULL);

	panel_properties_dialog_background_color_update (dialog);

	g_signal_connect_swapped (dialog->opacity_scale, "value_changed",
				  G_CALLBACK (panel_properties_dialog_opacity_scale_changed),
				  dialog);

	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_COLOR_KEY,
				  opacity_label, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_COLOR_KEY,
				  opacity_legend, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_COLOR_KEY,
				  dialog->opacity_scale, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings_background,
				     PANEL_BACKGROUND_COLOR_KEY))
		gtk_widget_show (dialog->writability_warn_background);
}
static void
panel_properties_dialog_color_button_setup (PanelPropertiesDialog *dialog,
					    GtkBuilder            *gui)
{
	GtkWidget *color_label;

	dialog->color_button = PANEL_GTK_BUILDER_GET (gui, "color_button");
	g_return_if_fail (dialog->color_button != NULL);
	color_label = PANEL_GTK_BUILDER_GET (gui, "color_label");
	g_return_if_fail (color_label != NULL);

	panel_properties_dialog_background_color_update (dialog);

	g_signal_connect_swapped (dialog->color_button, "color_set",
				  G_CALLBACK (panel_properties_dialog_color_button_changed),
				  dialog);

	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_COLOR_KEY,
				  color_label, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_COLOR_KEY,
				  dialog->color_button, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings_background,
				     PANEL_BACKGROUND_COLOR_KEY))
		gtk_widget_show (dialog->writability_warn_background);
}
static void
panel_properties_dialog_size_spin_setup (PanelPropertiesDialog *dialog,
					 GtkBuilder            *gui)
{
	GtkWidget *size_label;
	GtkWidget *size_label_pixels;

	dialog->size_spin = PANEL_GTK_BUILDER_GET (gui, "size_spin");
	g_return_if_fail (dialog->size_spin != NULL);
	size_label = PANEL_GTK_BUILDER_GET (gui, "size_label");
	g_return_if_fail (size_label != NULL);
	size_label_pixels = PANEL_GTK_BUILDER_GET (gui, "size_label_pixels");
	g_return_if_fail (size_label_pixels != NULL);

	panel_properties_size_spin_update_range (dialog);

	g_settings_bind (dialog->settings, PANEL_TOPLEVEL_SIZE_KEY,
			 dialog->size_spin, "value",
			 G_SETTINGS_BIND_DEFAULT);

	g_settings_bind_writable (dialog->settings, PANEL_TOPLEVEL_SIZE_KEY,
				  size_label, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings, PANEL_TOPLEVEL_SIZE_KEY,
				  size_label_pixels, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings, PANEL_TOPLEVEL_SIZE_KEY))
		gtk_widget_show (dialog->writability_warn_general);
}
static void
panel_properties_dialog_setup_orientation_combo (PanelPropertiesDialog *dialog,
						 GtkBuilder            *gui)
{
	GtkWidget        *orientation_label;
	GtkListStore     *model;
	GtkTreeIter       iter;
	GtkCellRenderer  *renderer;
	int               i;

	dialog->orientation_combo = PANEL_GTK_BUILDER_GET (gui, "orientation_combo");
	g_return_if_fail (dialog->orientation_combo != NULL);
	orientation_label = PANEL_GTK_BUILDER_GET (gui, "orientation_label");
	g_return_if_fail (orientation_label != NULL);

	model = gtk_list_store_new (NUMBER_COLUMNS,
				    G_TYPE_STRING,
				    G_TYPE_POINTER);

	gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->orientation_combo),
				 GTK_TREE_MODEL (model));

	for (i = 0; i < G_N_ELEMENTS (orientation_items); i++) {
		gtk_list_store_append (model, &iter);
		gtk_list_store_set (model, &iter,
				    COLUMN_TEXT, g_dpgettext2 (NULL, "Orientation", orientation_items [i].name),
				    COLUMN_ITEM, &(orientation_items [i]),
				    -1);
	}

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->orientation_combo),
				    renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->orientation_combo),
					renderer, "text", COLUMN_TEXT, NULL);

	panel_properties_dialog_orientation_update (dialog);

	g_signal_connect_swapped (dialog->orientation_combo, "changed",
				  G_CALLBACK (panel_properties_dialog_orientation_changed),
				  dialog);
	g_signal_connect (dialog->settings_background,
			  "changed::"PANEL_TOPLEVEL_ORIENTATION_KEY,
			  G_CALLBACK (panel_properties_dialog_orientation_setting_changed),
			  dialog);

	g_settings_bind_writable (dialog->settings, PANEL_TOPLEVEL_ORIENTATION_KEY,
				  orientation_label, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings, PANEL_TOPLEVEL_ORIENTATION_KEY,
				  dialog->orientation_combo, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings, PANEL_TOPLEVEL_ORIENTATION_KEY))
		gtk_widget_show (dialog->writability_warn_general);
}
Exemple #5
0
static void
impl_attach_window (EphyExtension *extension,
		    EphyWindow *window)
{
	GtkUIManager *manager;
	GtkActionGroup *action_group;
	GtkAction *action;
	GSettings *settings;
	EphyLocationController *location_controller;

	g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
			  "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
			  G_CALLBACK (fullscreen_cb), window);
	g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
			  "changed::" EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
			  G_CALLBACK (arbitrary_url_cb), window);

	/* Trigger an initial state on these elements. */
	fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
		       EPHY_PREFS_LOCKDOWN_FULLSCREEN, window);
	arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
			  EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, window);

	manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));

	action_group = find_action_group (manager, "WindowActions");
	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
				   action_group, window_actions,
				   G_N_ELEMENTS (window_actions));

	action_group = find_action_group (manager, "PopupsActions");
	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
				   action_group, popup_actions,
				   G_N_ELEMENTS (popup_actions));

	action = gtk_action_group_get_action (action_group,
					      "SetImageAsBackground");
	settings = ephy_settings_get ("org.gnome.desktop.background");
	g_settings_bind_writable (settings, "picture-filename",
				  action, "sensitive", FALSE);

	action_group = find_action_group (manager, "SpecialToolbarActions");
	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
				   action_group, special_toolbar_actions,
				   G_N_ELEMENTS (special_toolbar_actions));

	location_controller = ephy_window_get_location_controller (window);
	bind_location_controller (EPHY_SETTINGS_LOCKDOWN, location_controller);
}
static void
panel_properties_dialog_background_radios_setup (PanelPropertiesDialog *dialog,
						 GtkBuilder            *gui)
{
	dialog->default_radio     = PANEL_GTK_BUILDER_GET (gui, "default_radio");
	dialog->color_radio       = PANEL_GTK_BUILDER_GET (gui, "color_radio");
	dialog->image_radio       = PANEL_GTK_BUILDER_GET (gui, "image_radio");
	dialog->color_widgets     = PANEL_GTK_BUILDER_GET (gui, "color_widgets");
	dialog->image_widgets     = PANEL_GTK_BUILDER_GET (gui, "image_widgets");

	panel_properties_dialog_background_type_update (dialog);

	g_signal_connect_swapped (dialog->default_radio, "toggled",
				  G_CALLBACK (panel_properties_dialog_background_radios_toggled),
				  dialog);
	g_signal_connect_swapped (dialog->color_radio, "toggled",
				  G_CALLBACK (panel_properties_dialog_background_radios_toggled),
				  dialog);
	g_signal_connect_swapped (dialog->image_radio, "toggled",
				  G_CALLBACK (panel_properties_dialog_background_radios_toggled),
				  dialog);

	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_TYPE_KEY,
				  dialog->default_radio, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_TYPE_KEY,
				  dialog->color_radio, "sensitive", FALSE);
	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_TYPE_KEY,
				  dialog->image_radio, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings_background,
				     PANEL_BACKGROUND_TYPE_KEY))
		gtk_widget_show (dialog->writability_warn_background);
}
static void
panel_properties_dialog_image_chooser_setup (PanelPropertiesDialog *dialog,
					     GtkBuilder            *gui)
{
	dialog->image_chooser = PANEL_GTK_BUILDER_GET (gui, "image_chooser");
	panel_gtk_file_chooser_add_image_preview (GTK_FILE_CHOOSER (dialog->image_chooser));

	panel_properties_dialog_background_image_update (dialog);

	g_signal_connect_swapped (dialog->image_chooser, "file-set",
				  G_CALLBACK (panel_properties_dialog_image_chooser_changed),
				  dialog);

	g_settings_bind_writable (dialog->settings_background,
				  PANEL_BACKGROUND_IMAGE_URI_KEY,
				  dialog->image_chooser, "sensitive", FALSE);

	if (!g_settings_is_writable (dialog->settings_background,
				     PANEL_BACKGROUND_IMAGE_URI_KEY))
		gtk_widget_show (dialog->writability_warn_background);
}
/**
 * terminal_profile_edit:
 * @profile: a #GSettings
 * @transient_parent: a #GtkWindow, or %NULL
 * @widget_name: a widget name in the profile editor's UI, or %NULL
 *
 * Shows the profile editor with @profile, anchored to @transient_parent.
 * If @widget_name is non-%NULL, focuses the corresponding widget and
 * switches the notebook to its containing page.
 */
void
terminal_profile_edit (GSettings  *profile,
                       GtkWindow  *transient_parent,
                       const char *widget_name)
{
  TerminalSettingsList *profiles_list;
  GtkBuilder *builder;
  GError *error = NULL;
  GtkWidget *editor, *w;
  gs_free char *uuid = NULL;
  guint i;
  gfloat style_darkness;

  editor = g_object_get_data (G_OBJECT (profile), "editor-window");
  if (editor)
    {
      terminal_util_dialog_focus_widget (editor, widget_name);

      gtk_window_set_transient_for (GTK_WINDOW (editor),
                                    NULL);
      gtk_window_present (GTK_WINDOW (editor));
      return;
    }

  fixup_color_chooser_button ();

  profiles_list = terminal_app_get_profiles_list (terminal_app_get ());

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/org/gnome/terminal/ui/profile-preferences.ui", &error);
  g_assert_no_error (error);

  editor = (GtkWidget *) gtk_builder_get_object  (builder, "profile-editor-dialog");
  g_object_set_data_full (G_OBJECT (editor), "builder",
                          builder, (GDestroyNotify) g_object_unref);

  /* Store the dialogue on the profile, so we can acccess it above to check if
   * there's already a profile editor for this profile.
   */
  g_object_set_data (G_OBJECT (profile), "editor-window", editor);

  g_signal_connect (editor, "destroy",
                    G_CALLBACK (profile_editor_destroyed),
                    profile);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "close-button");
  g_signal_connect (w, "clicked", G_CALLBACK (editor_close_button_clicked_cb), editor);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "help-button");
  g_signal_connect (w, "clicked", G_CALLBACK (editor_help_button_clicked_cb), editor);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "profile-editor-notebook");
  gtk_widget_add_events (w, GDK_BUTTON_PRESS_MASK | GDK_SCROLL_MASK);
  g_signal_connect (w, "scroll-event", G_CALLBACK (scroll_event_cb), NULL);

  uuid = terminal_settings_list_dup_uuid_from_child (profiles_list, profile);
  gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "profile-uuid")),
                      uuid);

  g_signal_connect (gtk_builder_get_object  (builder, "default-size-reset-button"),
                    "clicked",
                    G_CALLBACK (default_size_reset_cb),
                    profile);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
  init_color_scheme_menu (w);

  /* Hook up the palette colorpickers and combo box */

  for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
    {
      char name[32];
      char *text;

      g_snprintf (name, sizeof (name), "palette-colorpicker-%u", i + 1);
      w = (GtkWidget *) gtk_builder_get_object  (builder, name);

      g_object_set_data (G_OBJECT (w), "palette-entry-index", GUINT_TO_POINTER (i));

      text = g_strdup_printf (_("Choose Palette Color %u"), i + 1);
      gtk_color_button_set_title (GTK_COLOR_BUTTON (w), text);
      g_free (text);

      text = g_strdup_printf (_("Palette entry %u"), i + 1);
      gtk_widget_set_tooltip_text (w, text);
      g_free (text);

      g_signal_connect (w, "notify::rgba",
                        G_CALLBACK (palette_color_notify_cb),
                        profile);
    }

  gtk_widget_style_get (GTK_WIDGET (
              terminal_window_get_active (TERMINAL_WINDOW (transient_parent))),
                        "background-darkness", &style_darkness,
                        NULL);

  gtk_widget_set_visible (gtk_builder_get_object (
              builder,
              "use-theme-transparency-checkbutton"), style_darkness >= 0);

  profile_palette_notify_colorpickers_cb (profile, TERMINAL_PROFILE_PALETTE_KEY, editor);
  g_signal_connect (profile, "changed::" TERMINAL_PROFILE_PALETTE_KEY,
                    G_CALLBACK (profile_palette_notify_colorpickers_cb),
                    editor);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "palette-combobox");
  g_signal_connect (w, "notify::active",
                    G_CALLBACK (palette_scheme_combo_changed_cb),
                    profile);

  profile_palette_notify_scheme_combo_cb (profile, TERMINAL_PROFILE_PALETTE_KEY, GTK_COMBO_BOX (w));
  g_signal_connect (profile, "changed::" TERMINAL_PROFILE_PALETTE_KEY,
                    G_CALLBACK (profile_palette_notify_scheme_combo_cb),
                    w);

  /* Hook up the color scheme pickers and combo box */
  w = (GtkWidget *) gtk_builder_get_object  (builder, "color-scheme-combobox");
  g_signal_connect (w, "notify::active",
                    G_CALLBACK (color_scheme_combo_changed_cb),
                    profile);

  profile_colors_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
  g_signal_connect (profile, "changed::" TERMINAL_PROFILE_FOREGROUND_COLOR_KEY,
                    G_CALLBACK (profile_colors_notify_scheme_combo_cb),
                    w);
  g_signal_connect (profile, "changed::" TERMINAL_PROFILE_BACKGROUND_COLOR_KEY,
                    G_CALLBACK (profile_colors_notify_scheme_combo_cb),
                    w);

  w = GTK_WIDGET (gtk_builder_get_object (builder, "custom-command-entry"));
  custom_command_entry_changed_cb (GTK_ENTRY (w));
  g_signal_connect (w, "changed",
                    G_CALLBACK (custom_command_entry_changed_cb), NULL);

  g_signal_connect (gtk_builder_get_object  (builder, "reset-compat-defaults-button"),
                    "clicked",
                    G_CALLBACK (reset_compat_defaults_cb),
                    profile);

  g_settings_bind_with_mapping (profile,
                                TERMINAL_PROFILE_VISIBLE_NAME_KEY,
                                editor,
                                "title",
                                G_SETTINGS_BIND_GET |
                                G_SETTINGS_BIND_NO_SENSITIVITY,
                                (GSettingsBindGetMapping)
                                string_to_window_title, NULL, NULL, NULL);

  g_settings_bind (profile,
                   TERMINAL_PROFILE_ALLOW_BOLD_KEY,
                   gtk_builder_get_object (builder, "allow-bold-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind_with_mapping (profile,
                                TERMINAL_PROFILE_BACKGROUND_COLOR_KEY,
                                gtk_builder_get_object (builder,
                                                        "background-colorpicker"),
                                "rgba",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) s_to_rgba,
                                (GSettingsBindSetMapping) rgba_to_s,
                                NULL, NULL);
  g_settings_bind_with_mapping (profile,
                                TERMINAL_PROFILE_BACKSPACE_BINDING_KEY,
                                gtk_builder_get_object (builder,
                                                        "backspace-binding-combobox"),
                                "active",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) string_to_enum,
                                (GSettingsBindSetMapping) enum_to_string,
                                vte_erase_binding_get_type, NULL);
  g_settings_bind (profile, TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY,
                   gtk_builder_get_object (builder,
                                           "bold-color-same-as-fg-checkbox"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY,
                   gtk_builder_get_object (builder,
                                           "bold-colorpicker-box"),
                   "sensitive", 
                   G_SETTINGS_BIND_GET |
                   G_SETTINGS_BIND_INVERT_BOOLEAN |
                   G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_BOLD_COLOR_KEY,
                                gtk_builder_get_object (builder,
                                                        "bold-colorpicker"),
                                "rgba",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) s_to_rgba,
                                (GSettingsBindSetMapping) rgba_to_s,
                                NULL, NULL);
  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_CURSOR_SHAPE_KEY,
                                gtk_builder_get_object (builder,
                                                        "cursor-shape-combobox"),
                                "active",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) string_to_enum,
                                (GSettingsBindSetMapping) enum_to_string,
                                vte_cursor_shape_get_type, NULL);
  g_settings_bind (profile, TERMINAL_PROFILE_CUSTOM_COMMAND_KEY,
                   gtk_builder_get_object (builder, "custom-command-entry"),
                   "text", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS_KEY,
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON
                                                   (gtk_builder_get_object
                                                    (builder,
                                                     "default-size-columns-spinbutton"))),
                   "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_DEFAULT_SIZE_ROWS_KEY,
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON
                                                   (gtk_builder_get_object
                                                    (builder,
                                                     "default-size-rows-spinbutton"))),
                   "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_DELETE_BINDING_KEY,
                                gtk_builder_get_object (builder,
                                                        "delete-binding-combobox"),
                                "active",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) string_to_enum,
                                (GSettingsBindSetMapping) enum_to_string,
                                vte_erase_binding_get_type, NULL);
  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_EXIT_ACTION_KEY,
                                gtk_builder_get_object (builder,
                                                        "exit-action-combobox"),
                                "active",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) string_to_enum,
                                (GSettingsBindSetMapping) enum_to_string,
                                terminal_exit_action_get_type, NULL);
  g_settings_bind (profile, TERMINAL_PROFILE_FONT_KEY,
                   gtk_builder_get_object (builder, "font-selector"),
                   "font-name", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind_with_mapping (profile,
                                TERMINAL_PROFILE_FOREGROUND_COLOR_KEY,
                                gtk_builder_get_object (builder,
                                                        "foreground-colorpicker"),
                                "rgba",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) s_to_rgba,
                                (GSettingsBindSetMapping) rgba_to_s,
                                NULL, NULL);
  g_settings_bind (profile, TERMINAL_PROFILE_LOGIN_SHELL_KEY,
                   gtk_builder_get_object (builder,
                                           "login-shell-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY,
                   gtk_builder_get_object (builder, "profile-name-entry"),
                   "text", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_SCROLLBACK_LINES_KEY,
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON
                                                   (gtk_builder_get_object
                                                    (builder,
                                                     "scrollback-lines-spinbutton"))),
                   "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_SCROLLBACK_UNLIMITED_KEY,
                   gtk_builder_get_object (builder,
                                           "scrollback-limited-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET |
                   G_SETTINGS_BIND_INVERT_BOOLEAN);
  g_settings_bind (profile, TERMINAL_PROFILE_SCROLLBACK_UNLIMITED_KEY,
                   gtk_builder_get_object (builder,
                                           "scrollback-box"),
                   "sensitive", 
                   G_SETTINGS_BIND_GET |
                   G_SETTINGS_BIND_INVERT_BOOLEAN |
                   G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind_with_mapping (profile,
                                TERMINAL_PROFILE_SCROLLBAR_POLICY_KEY,
                                gtk_builder_get_object (builder,
                                                        "scrollbar-checkbutton"),
                                "active",
                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
                                (GSettingsBindGetMapping) scrollbar_policy_to_bool,
                                (GSettingsBindSetMapping) bool_to_scrollbar_policy,
                                NULL, NULL);
  g_settings_bind (profile, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE_KEY,
                   gtk_builder_get_object (builder,
                                           "scroll-on-keystroke-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_SCROLL_ON_OUTPUT_KEY,
                   gtk_builder_get_object (builder,
                                           "scroll-on-output-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_USE_SYSTEM_FONT_KEY,
                   gtk_builder_get_object (builder,
                                           "custom-font-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET |
                   G_SETTINGS_BIND_INVERT_BOOLEAN);
  g_settings_bind (profile, TERMINAL_PROFILE_USE_CUSTOM_COMMAND_KEY,
                   gtk_builder_get_object (builder,
                                           "use-custom-command-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_USE_THEME_COLORS_KEY,
                   gtk_builder_get_object (builder,
                                           "use-theme-colors-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_AUDIBLE_BELL_KEY,
                   gtk_builder_get_object (builder, "bell-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  g_settings_bind (profile,
                   TERMINAL_PROFILE_USE_CUSTOM_COMMAND_KEY,
                   gtk_builder_get_object (builder, "custom-command-box"),
                   "sensitive",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind (profile,
                   TERMINAL_PROFILE_USE_SYSTEM_FONT_KEY,
                   gtk_builder_get_object (builder, "font-selector"),
                   "sensitive",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN |
                   G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind (profile,
                   TERMINAL_PROFILE_USE_THEME_COLORS_KEY,
                   gtk_builder_get_object (builder, "colors-box"),
                   "sensitive",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN |
                   G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind_writable (profile,
                            TERMINAL_PROFILE_PALETTE_KEY,
                            gtk_builder_get_object (builder, "palette-box"),
                            "sensitive",
                            FALSE);
  g_settings_bind (profile,
                   TERMINAL_PROFILE_REWRAP_ON_RESIZE_KEY,
                   gtk_builder_get_object (builder, "rewrap-on-resize-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  /* Compatibility options */
  w = (GtkWidget *) gtk_builder_get_object  (builder, "encoding-combobox");
  init_encodings_combo (w);
  g_settings_bind (profile,
                   TERMINAL_PROFILE_ENCODING_KEY,
                   w,
                   "active-id", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  w = (GtkWidget *) gtk_builder_get_object  (builder, "cjk-ambiguous-width-combobox");
  g_settings_bind (profile, TERMINAL_PROFILE_CJK_UTF8_AMBIGUOUS_WIDTH_KEY,
                   w,
                   "active-id",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  g_settings_bind (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND,
                   gtk_builder_get_object (builder, "use-transparent-background"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND,
                   gtk_builder_get_object (builder, "background-transparent-scale-box"),
                   "sensitive", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY);
  g_settings_bind (profile, TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT,
                   gtk_builder_get_object (builder, "background-transparent-adjustment"),
                   "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
  g_settings_bind (profile, TERMINAL_PROFILE_USE_THEME_TRANSPARENCY,
                   gtk_builder_get_object (builder, "use-theme-transparency-checkbutton"),
                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  if (style_darkness >= 0)
      g_settings_bind (profile, TERMINAL_PROFILE_USE_THEME_TRANSPARENCY,
              gtk_builder_get_object (builder, "use-transparent-background-box"),
              "sensitive",
              G_SETTINGS_BIND_GET |
              G_SETTINGS_BIND_INVERT_BOOLEAN |
              G_SETTINGS_BIND_NO_SENSITIVITY);

  /* Finished! */
  terminal_util_bind_mnemonic_label_sensitivity (editor);

  terminal_util_dialog_focus_widget (editor, widget_name);

  gtk_window_set_transient_for (GTK_WINDOW (editor),
                                NULL);
  gtk_window_present (GTK_WINDOW (editor));
}
static void
cc_night_light_dialog_init (CcNightLightDialog *self)
{
  g_autoptr(GtkCssProvider) provider = NULL;
  g_autoptr(GError) error = NULL;

  gtk_widget_init_template (GTK_WIDGET (self));

  gtk_scale_add_mark (GTK_SCALE (self->scale_color_temperature),
                      3000, GTK_POS_BOTTOM,
                      _("More Warm"));

  gtk_scale_add_mark (GTK_SCALE (self->scale_color_temperature),
                      4000, GTK_POS_BOTTOM,
                      NULL);

  gtk_scale_add_mark (GTK_SCALE (self->scale_color_temperature),
                      5000, GTK_POS_BOTTOM,
                      NULL);

  gtk_scale_add_mark (GTK_SCALE (self->scale_color_temperature),
                      6000, GTK_POS_BOTTOM,
                      _("Less Warm"));

  self->cancellable = g_cancellable_new ();
  self->settings_display = g_settings_new (DISPLAY_SCHEMA);

  g_signal_connect (self->settings_display, "changed", G_CALLBACK (dialog_settings_changed_cb), self);

  g_settings_bind_writable (self->settings_display, "night-light-schedule-from",
                            self->spinbutton_from_hours, "sensitive",
                            FALSE);
  g_settings_bind_writable (self->settings_display, "night-light-schedule-from",
                            self->spinbutton_from_minutes, "sensitive",
                            FALSE);
  g_settings_bind_writable (self->settings_display, "night-light-schedule-to",
                            self->spinbutton_to_minutes, "sensitive",
                            FALSE);
  g_settings_bind_writable (self->settings_display, "night-light-schedule-to",
                            self->spinbutton_to_minutes, "sensitive",
                            FALSE);

  /* use custom CSS */
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_resource (provider, "/org/gnome/control-center/display/night-light.css");
  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
                                       G_DBUS_PROXY_FLAGS_NONE,
                                       "org.gnome.SettingsDaemon.Color",
                                       "/org/gnome/SettingsDaemon/Color",
                                       "org.gnome.SettingsDaemon.Color",
                                       self->cancellable,
                                       dialog_got_proxy_cb,
                                       self);

  cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
                                       G_DBUS_PROXY_FLAGS_NONE,
                                       "org.gnome.SettingsDaemon.Color",
                                       "/org/gnome/SettingsDaemon/Color",
                                       "org.freedesktop.DBus.Properties",
                                       self->cancellable,
                                       dialog_got_proxy_props_cb,
                                       self);

  /* clock settings_display */
  self->settings_clock = g_settings_new (CLOCK_SCHEMA);
  self->clock_format = g_settings_get_enum (self->settings_clock, CLOCK_FORMAT_KEY);
  dialog_update_adjustments (self);
  g_signal_connect (self->settings_clock,
                    "changed::" CLOCK_FORMAT_KEY,
                    G_CALLBACK (dialog_clock_settings_changed_cb),
                    self);

  dialog_update_state (self);
}
Exemple #10
0
static void 
display_preferences_dialog (GSimpleAction *action,
                            GVariant      *parameter,
                            gpointer       user_data)
{
	FishApplet *fish = (FishApplet *) user_data;
	GtkBuilder *builder;
	GtkWidget  *box;
	GtkWidget  *name_entry;
	GtkWidget  *command_entry;
	GtkWidget  *speed_spin;
	GtkWidget  *rotate_toggle;
	GtkWidget  *button;

	if (fish->preferences_dialog) {
		gtk_window_set_screen (GTK_WINDOW (fish->preferences_dialog),
				       gtk_widget_get_screen (GTK_WIDGET (fish)));
		gtk_window_present (GTK_WINDOW (fish->preferences_dialog));
		return;
	}

	builder = gtk_builder_new ();
	gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
	gtk_builder_add_from_resource (builder, FISH_RESOURCE_PATH "fish.ui", NULL);

	fish->preferences_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "fish_preferences_dialog"));

	g_object_add_weak_pointer (G_OBJECT (fish->preferences_dialog),
				   (void**) &fish->preferences_dialog);

	gtk_window_set_wmclass (GTK_WINDOW (fish->preferences_dialog),
				"fish", "Fish");
	gtk_window_set_icon_name (GTK_WINDOW (fish->preferences_dialog),
				  FISH_ICON);
	gtk_dialog_set_default_response (
		GTK_DIALOG (fish->preferences_dialog), GTK_RESPONSE_OK);

	name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"));
	box = GTK_WIDGET (gtk_builder_get_object (builder, "name_box"));
	g_settings_bind (fish->settings, FISH_NAME_KEY,
			 name_entry, "text",
			 G_SETTINGS_BIND_DEFAULT);
	g_settings_bind_writable (fish->settings, FISH_NAME_KEY,
				  box, "sensitive",
				  FALSE);

	command_entry = GTK_WIDGET (gtk_builder_get_object (builder, "command_entry"));
	box = GTK_WIDGET (gtk_builder_get_object (builder, "command_box"));
	g_settings_bind (fish->settings, FISH_COMMAND_KEY,
			 command_entry, "text",
			 G_SETTINGS_BIND_GET);
	g_signal_connect (command_entry, "changed",
			  G_CALLBACK (command_value_changed), fish);
	g_settings_bind_writable (fish->settings, FISH_COMMAND_KEY,
				  box, "sensitive",
				  FALSE);

	g_settings_bind (fish->lockdown_settings, LOCKDOWN_COMMANDLINE_KEY,
			 box, "visible",
			 G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_INVERT_BOOLEAN);

	speed_spin = GTK_WIDGET (gtk_builder_get_object (builder, "speed_spin"));
	box = GTK_WIDGET (gtk_builder_get_object (builder, "speed_box"));
	g_settings_bind (fish->settings, FISH_SPEED_KEY,
			 speed_spin, "value",
			 G_SETTINGS_BIND_DEFAULT);
	g_settings_bind_writable (fish->settings, FISH_SPEED_KEY,
				  box, "sensitive",
				  FALSE);

	rotate_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_toggle"));
	g_settings_bind (fish->settings, FISH_ROTATE_KEY,
			 rotate_toggle, "active",
			 G_SETTINGS_BIND_DEFAULT);

	g_signal_connect (fish->preferences_dialog, "delete_event",
			  G_CALLBACK (delete_event), fish);
	g_signal_connect (fish->preferences_dialog, "response",
			  G_CALLBACK (handle_response), fish);

	button = GTK_WIDGET (gtk_builder_get_object (builder, "done_button"));
        g_signal_connect_swapped (button, "clicked",
				  (GCallback) gtk_widget_hide, 
				  fish->preferences_dialog);

	gtk_window_set_screen (GTK_WINDOW (fish->preferences_dialog),
			       gtk_widget_get_screen (GTK_WIDGET (fish)));
	gtk_window_set_resizable (GTK_WINDOW (fish->preferences_dialog), FALSE);
	gtk_window_present (GTK_WINDOW (fish->preferences_dialog));

	g_object_unref (builder);
}