gnome-terminal r2655 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2655 - trunk/src
- Date: Thu, 29 May 2008 19:42:24 +0000 (UTC)
Author: chpe
Date: Thu May 29 19:42:24 2008
New Revision: 2655
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2655&view=rev
Log:
Port the profile editor to the new profile API. Simplify code.
Modified:
trunk/src/profile-editor.c
trunk/src/profile-editor.h
Modified: trunk/src/profile-editor.c
==============================================================================
--- trunk/src/profile-editor.c (original)
+++ trunk/src/profile-editor.c Thu May 29 19:42:24 2008
@@ -1,12 +1,8 @@
-/* dialog for editing a profile */
-
/*
* Copyright  2002 Havoc Pennington
* Copyright  2002 Mathias Hasselmann
* Copyright  2008 Christian Persch
*
- * This file is part of gnome-terminal.
- *
* Gnome-terminal is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -32,13 +28,14 @@
#include "terminal-intl.h"
#include "profile-editor.h"
-#include "terminal.h"
#include "terminal-util.h"
#include <libgnomeui/gnome-file-entry.h>
#include <libgnomeui/gnome-icon-entry.h>
#include <libgnomeui/gnome-thumbnail.h>
+// FIXMEchpe make the kb spinbutton a label instead since changing it really isn't right
+
/* One slot in the ring buffer, plus the array which holds the data for
* the line, plus about 80 vte_charcell structures. */
#define BYTES_PER_LINE (sizeof(gpointer) + sizeof(GArray) + (80 * (sizeof(gunichar) + 4)))
@@ -48,12 +45,11 @@
struct _TerminalColorScheme
{
const char *name;
- GdkColor foreground;
- GdkColor background;
+ const GdkColor foreground;
+ const GdkColor background;
};
-/* alphabetized */
-static TerminalColorScheme color_schemes[] = {
+static const TerminalColorScheme color_schemes[] = {
{ N_("Black on light yellow"),
{ 0, 0x0000, 0x0000, 0x0000 }, { 0, 0xFFFF, 0xFFFF, 0xDDDD } },
{ N_("Black on white"),
@@ -66,363 +62,550 @@
{ 0, 0xFFFF, 0xFFFF, 0xFFFF }, { 0, 0x0000, 0x0000, 0x0000 } }
};
-typedef struct _TerminalPaletteScheme TerminalPaletteScheme;
+static void profile_forgotten_cb (TerminalProfile *profile,
+ GtkWidget *editor);
-struct _TerminalPaletteScheme
-{
- const char *name;
- const GdkColor *palette;
-};
+static void profile_notify_sensitivity_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkWidget *editor);
+
+static void profile_colors_notify_scheme_combo_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkComboBox *combo);
+
+static void profile_palette_notify_scheme_combo_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkComboBox *combo);
+
+static void profile_palette_notify_colorpickers_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkWidget *editor);
-static TerminalPaletteScheme palette_schemes[] = {
- { N_("Tango"), terminal_palette_tango },
- { N_("Linux console"), terminal_palette_linux },
- { N_("XTerm"), terminal_palette_xterm },
- { N_("Rxvt"), terminal_palette_rxvt }
-};
-static GtkWidget* profile_editor_get_widget (GtkWidget *editor,
- const char *widget_name);
-static void profile_editor_update_sensitivity (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_visible_name (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_icon (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_default_show_menubar (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_color_pickers (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_color_scheme_menu (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_title (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_title_mode (GtkWidget *editor,
- TerminalProfile *profile);
-static void profile_editor_update_allow_bold (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_silent_bell (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_word_chars (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_scrollbar_position (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_scrollback_lines (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_scroll_on_keystroke (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_scroll_on_output (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_exit_action (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_login_shell (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_update_records (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_use_custom_command (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_custom_command (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_palette (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_background_type (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_background_image (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_scroll_background (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_background_darkness (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_backspace_binding (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_delete_binding (GtkWidget *widget,
- TerminalProfile *profile);
-
-static void profile_editor_update_use_theme_colors (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_use_system_font (GtkWidget *widget,
- TerminalProfile *profile);
-static void profile_editor_update_font (GtkWidget *widget,
- TerminalProfile *profile);
-
-
-static void profile_forgotten (TerminalProfile *profile,
- GtkWidget *editor);
-static void profile_changed (TerminalProfile *profile,
- const TerminalSettingMask *mask,
- GtkWidget *editor);
-
-
-
-static void
-entry_set_text_if_changed (GtkEntry *entry,
- const char *text)
-{
- char *s;
-
- s = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- if (strcmp (s, text) != 0)
- gtk_entry_set_text (GTK_ENTRY (entry), text);
-
- g_free (s);
-}
-
-static void
-colorpicker_set_if_changed (GtkWidget *colorpicker,
- const GdkColor *color)
+static GtkWidget*
+profile_editor_get_widget (GtkWidget *editor,
+ const char *widget_name)
{
- GdkColor old_color;
-
- gtk_color_button_get_color (GTK_COLOR_BUTTON (colorpicker), &old_color);
-
- if (!gdk_color_equal (color, &old_color))
- gtk_color_button_set_color (GTK_COLOR_BUTTON (colorpicker), color);
-}
+ GtkBuilder *builder;
-static void
-profile_editor_destroyed (GtkWidget *editor,
- TerminalProfile *profile)
-{
- g_signal_handlers_disconnect_by_func (G_OBJECT (profile),
- G_CALLBACK (profile_forgotten),
- editor);
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (profile),
- G_CALLBACK (profile_changed),
- editor);
+ builder = g_object_get_data (G_OBJECT (editor), "builder");
+ g_assert (builder != NULL);
- g_object_set_data (G_OBJECT (profile), "editor-window", NULL);
- g_object_set_data (G_OBJECT (editor), "builder", NULL);
- profile_name_entry_notify (profile);
+ return (GtkWidget *) gtk_builder_get_object (builder, widget_name);
}
-static PangoFontDescription*
-fontpicker_get_desc (GtkWidget *font_picker)
+static void
+widget_and_labels_set_sensitive (GtkWidget *widget, gboolean sensitive)
{
- const char *current_name;
- PangoFontDescription *current_desc;
+ GList *labels, *i;
- current_name = gtk_font_button_get_font_name (GTK_FONT_BUTTON (font_picker));
- if (current_name)
- current_desc = pango_font_description_from_string (current_name);
- else
- current_desc = NULL;
+ labels = gtk_widget_list_mnemonic_labels (widget);
+ for (i = labels; i; i = i->next)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (i->data), sensitive);
+ }
+ g_list_free (labels);
- return current_desc;
+ gtk_widget_set_sensitive (widget, sensitive);
}
static void
-fontpicker_set_if_changed (GtkWidget *font_picker,
- const PangoFontDescription *font_desc)
+set_insensitive (GtkWidget *editor,
+ const char *widget_name,
+ gboolean setting)
{
- PangoFontDescription *current_desc;
-
- current_desc = fontpicker_get_desc (font_picker);
-
- if (current_desc == NULL || !pango_font_description_equal (font_desc, current_desc))
- {
- char *str;
-
- str = pango_font_description_to_string (font_desc);
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_picker),
- str);
+ GtkWidget *w;
- g_free (str);
- }
+ w = profile_editor_get_widget (editor, widget_name);
- if (current_desc)
- pango_font_description_free (current_desc);
+ widget_and_labels_set_sensitive (w, !setting);
}
-/*
- * Profile callbacks
- */
-
static void
-profile_forgotten (TerminalProfile *profile,
- GtkWidget *editor)
+profile_forgotten_cb (TerminalProfile *profile,
+ GtkWidget *editor)
{
- /* FIXME this might confuse users a bit, if it ever happens (unlikely
- * to actually happen much)
- */
gtk_widget_destroy (editor);
}
static void
-profile_changed (TerminalProfile *profile,
- const TerminalSettingMask *mask,
- GtkWidget *editor)
-{
- if (mask->visible_name)
- profile_editor_update_visible_name (editor, profile);
+profile_notify_sensitivity_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkWidget *editor)
+{
+ TerminalBackgroundType bg_type;
+ gboolean use_custom_locked, palette_locked, bg_type_locked, scrollback_lines_locked;
+ const char *prop_name;
- if (mask->icon_file)
- profile_editor_update_icon (editor, profile);
+ if (pspec)
+ prop_name = pspec->name;
+ else
+ prop_name = NULL;
- if (mask->default_show_menubar)
- profile_editor_update_default_show_menubar (editor, profile);
+ /* This one can't be short-circuited by the cache, since
+ * it depends on settings
+ */
+ use_custom_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_USE_CUSTOM_COMMAND);
+ set_insensitive (editor, "custom-command-box",
+ use_custom_locked ||
+ !terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_CUSTOM_COMMAND));
- if ((mask->foreground_color) ||
- (mask->background_color))
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TYPE))
{
- profile_editor_update_color_scheme_menu (editor, profile);
- profile_editor_update_color_pickers (editor, profile);
+ bg_type = terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE);
+ if (bg_type == TERMINAL_BACKGROUND_IMAGE)
+ {
+ set_insensitive (editor, "background-image-filechooser", terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE));
+ set_insensitive (editor, "scroll-background-checkbutton", terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLL_BACKGROUND));
+ set_insensitive (editor, "darken-background-vbox", terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS));
+ }
+ else if (bg_type == TERMINAL_BACKGROUND_TRANSPARENT)
+ {
+ set_insensitive (editor, "background-image-filechooser", TRUE);
+ set_insensitive (editor, "scroll-background-checkbutton", TRUE);
+ set_insensitive (editor, "darken-background-vbox", terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS));
+ }
+ else
+ {
+ set_insensitive (editor, "background-image-filechooser", TRUE);
+ set_insensitive (editor, "scroll-background-checkbutton", TRUE);
+ set_insensitive (editor, "darken-background-vbox", TRUE);
+ }
}
- if (mask->title)
- profile_editor_update_title (editor, profile);
-
- if (mask->title_mode)
- profile_editor_update_title_mode (editor, profile);
-
- if (mask->allow_bold)
- profile_editor_update_allow_bold (editor, profile);
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_USE_SYSTEM_FONT))
+ {
+ //FIXMEchpe
+ if (!terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_SYSTEM_FONT))
+ {
+ set_insensitive (editor, "font-hbox", terminal_profile_property_locked (profile, TERMINAL_PROFILE_FONT));
+ }
+ else
+ {
+ set_insensitive (editor, "font-hbox", TRUE);
+ }
+ }
- if (mask->silent_bell)
- profile_editor_update_silent_bell (editor, profile);
+ if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_THEME_COLORS))
+ {
+ set_insensitive (editor, "foreground-colorpicker", TRUE);
+ set_insensitive (editor, "foreground-colorpicker-label", TRUE);
+ set_insensitive (editor, "background-colorpicker", TRUE);
+ set_insensitive (editor, "background-colorpicker-label", TRUE);
+ set_insensitive (editor, "color-scheme-combobox", TRUE);
+ set_insensitive (editor, "color-scheme-combobox-label", TRUE);
+ }
+ else
+ {
+ gboolean fg_locked, bg_locked;
- if (mask->word_chars)
- profile_editor_update_word_chars (editor, profile);
+ fg_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_FOREGROUND_COLOR);
+ bg_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKGROUND_COLOR);
- if (mask->scrollbar_position)
- profile_editor_update_scrollbar_position (editor, profile);
+ set_insensitive (editor, "foreground-colorpicker", fg_locked);
+ set_insensitive (editor, "foreground-colorpicker-label", fg_locked);
+ set_insensitive (editor, "background-colorpicker", bg_locked);
+ set_insensitive (editor, "background-colorpicker-label", bg_locked);
+ set_insensitive (editor, "color-scheme-combobox", fg_locked || bg_locked);
+ set_insensitive (editor, "color-scheme-combobox-label", fg_locked || bg_locked);
+ }
+
+#if 0 /* uncomment once we've tested the sensitivity code */
+ if (mask == last_mask)
+ return;
+ g_object_set_data (G_OBJECT (editor), "cached-lock-mask",
+ GINT_TO_POINTER (mask));
+#endif
+
+ set_insensitive (editor, "profile-name-entry",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_VISIBLE_NAME));
- if (mask->scrollback_lines)
- profile_editor_update_scrollback_lines (editor, profile);
+ set_insensitive (editor, "profile-icon-entry",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_ICON_FILE));
+
+ set_insensitive (editor, "show-menubar-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR));
- if (mask->scroll_on_keystroke)
- profile_editor_update_scroll_on_keystroke (editor, profile);
+ set_insensitive (editor, "title-entry",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_TITLE));
+
+ set_insensitive (editor, "title-mode-combobox",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_TITLE_MODE));
- if (mask->scroll_on_output)
- profile_editor_update_scroll_on_output (editor, profile);
+ set_insensitive (editor, "allow-bold-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_ALLOW_BOLD));
- if (mask->exit_action)
- profile_editor_update_exit_action (editor, profile);
+ set_insensitive (editor, "bell-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_SILENT_BELL));
- if (mask->login_shell)
- profile_editor_update_login_shell (editor, profile);
+ set_insensitive (editor, "word-chars-entry",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_WORD_CHARS));
- if (mask->update_records)
- profile_editor_update_update_records (editor, profile);
+ set_insensitive (editor, "scrollbar-position-combobox",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLLBAR_POSITION));
- if (mask->use_custom_command)
- profile_editor_update_use_custom_command (editor, profile);
+ scrollback_lines_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLLBACK_LINES);
+ set_insensitive (editor, "scrollback-lines-spinbutton", scrollback_lines_locked);
+ set_insensitive (editor, "scrollback-kilobytes-spinbutton", scrollback_lines_locked);
+
+ set_insensitive (editor, "scroll-on-keystroke-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE));
- if (mask->custom_command)
- profile_editor_update_custom_command (editor, profile);
+ set_insensitive (editor, "scroll-on-output-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLL_ON_OUTPUT));
- if (mask->palette)
- profile_editor_update_palette (editor, profile);
+ set_insensitive (editor, "exit-action-combobox",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_EXIT_ACTION));
- if (mask->background_type)
- profile_editor_update_background_type (editor, profile);
-
- if (mask->background_image_file)
- profile_editor_update_background_image (editor, profile);
+ set_insensitive (editor, "login-shell-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_LOGIN_SHELL));
- if (mask->scroll_background)
- profile_editor_update_scroll_background (editor, profile);
+ set_insensitive (editor, "update-records-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_UPDATE_RECORDS));
- if (mask->background_darkness)
- profile_editor_update_background_darkness (editor, profile);
+ set_insensitive (editor, "use-custom-command-checkbutton", use_custom_locked);
- if (mask->backspace_binding)
- profile_editor_update_backspace_binding (editor, profile);
+ palette_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_PALETTE);
+ set_insensitive (editor, "palette-combobox", palette_locked);
+ set_insensitive (editor, "palette-table", palette_locked);
+
+ bg_type_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKGROUND_TYPE);
+ set_insensitive (editor, "solid-radiobutton", bg_type_locked);
+ set_insensitive (editor, "image-radiobutton", bg_type_locked);
+ set_insensitive (editor, "transparent-radiobutton", bg_type_locked);
- if (mask->delete_binding)
- profile_editor_update_delete_binding (editor, profile);
+ set_insensitive (editor, "backspace-binding-combobox",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_BACKSPACE_BINDING));
+ set_insensitive (editor, "delete-binding-combobox",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_DELETE_BINDING));
- if (mask->use_theme_colors)
- profile_editor_update_use_theme_colors (editor, profile);
-
- if (mask->use_system_font)
- profile_editor_update_use_system_font (editor, profile);
+ set_insensitive (editor, "use-theme-colors-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_USE_THEME_COLORS));
- if (mask->font)
- profile_editor_update_font (editor, profile);
-
- profile_editor_update_sensitivity (editor, profile);
+ set_insensitive (editor, "system-font-checkbutton",
+ terminal_profile_property_locked (profile, TERMINAL_PROFILE_USE_SYSTEM_FONT));
}
-/*
- * Widget callbacks
- */
+typedef enum {
+ FLAG_INVERT_BOOL = 1 << 0,
+ FLAG_SCROLLBACK = 1 << 1,
+} PropertyChangeFlags;
+
+typedef struct {
+ GtkWidget *window;
+ TerminalProfile *profile;
+ GtkWidget *widget;
+ const char *profile_prop;
+ gulong profile_notify_id;
+ gulong widget_notify_id;
+ PropertyChangeFlags flags;
+} PropertyChange;
static void
-visible_name_changed (GtkWidget *entry,
- TerminalProfile *profile)
+property_change_free (PropertyChange *change)
{
- char *text;
+ g_signal_handler_disconnect (change->profile, change->profile_notify_id);
+
+ g_slice_free (PropertyChange, change);
+}
+
+static gboolean
+transform_boolean (gboolean input,
+ PropertyChangeFlags flags)
+{
+ if (flags & FLAG_INVERT_BOOL)
+ input = !input;
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ return input;
+}
- terminal_profile_set_visible_name (profile, text);
+static int
+transform_spinbutton_value (int input,
+ PropertyChangeFlags flags,
+ gboolean from)
+{
+ if ((flags & FLAG_SCROLLBACK) == 0)
+ return input;
- g_free (text);
+ if (from) /* value from spin button */
+ input = input * BYTES_PER_LINE / 1024;
+ else /* value to set in the spin button */
+ input = input * 1024 / BYTES_PER_LINE;
+
+ return input;
}
static void
-icon_changed (GtkWidget *icon_entry,
- TerminalProfile *profile)
+profile_change_notify_cb (PropertyChange *change)
{
- char *filename;
+ TerminalProfile *profile = change->profile;
+ const char *profile_prop = change->profile_prop;
+ GtkWidget *widget = change->widget;
- filename = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY (icon_entry));
+ g_signal_handler_block (widget, change->widget_notify_id);
- /* NULL filename happens here to unset */
- terminal_profile_set_icon_file (profile, filename);
-
- g_free (filename);
+ if (GTK_IS_RADIO_BUTTON (widget))
+ {
+ glong pvalue, rvalue;
+
+ pvalue = terminal_profile_get_property_enum (profile, profile_prop);
+ rvalue = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "enum-value"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), pvalue == rvalue);
+ }
+ else if (GTK_IS_TOGGLE_BUTTON (widget))
+ {
+ gboolean enabled;
+
+ enabled = terminal_profile_get_property_boolean (profile, profile_prop);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
+ transform_boolean (enabled, change->flags));
+ }
+ else if (GTK_IS_SPIN_BUTTON (widget))
+ {
+ int value;
+
+ value = terminal_profile_get_property_int (profile, profile_prop);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), transform_spinbutton_value (value, change->flags, FALSE));
+ }
+ else if (GTK_IS_ENTRY (widget))
+ {
+ const char *text;
+
+ text = terminal_profile_get_property_string (profile, profile_prop);
+ gtk_entry_set_text (GTK_ENTRY (widget), text ? text : "");
+ }
+ else if (GTK_IS_COMBO_BOX (widget))
+ {
+ glong value;
+
+ value = terminal_profile_get_property_enum (profile, profile_prop);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), value);
+ }
+ else if (GTK_IS_RANGE (widget))
+ {
+ double value;
+
+ value = terminal_profile_get_property_double (profile, profile_prop);
+ gtk_range_set_value (GTK_RANGE (widget), value);
+ }
+ else if (GTK_IS_COLOR_BUTTON (widget))
+ {
+ const GdkColor *color;
+ GdkColor old_color;
+
+ color = terminal_profile_get_property_boxed (profile, profile_prop);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &old_color);
+
+ if (color && !gdk_color_equal (color, &old_color))
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), color);
+ }
+ else if (GTK_IS_FONT_BUTTON (widget))
+ {
+ const PangoFontDescription *font_desc;
+ char *font;
+
+ font_desc = terminal_profile_get_property_boxed (profile, profile_prop);
+ if (!font_desc)
+ goto out; /* FIXMEchpe reset instead? */
+
+ font = pango_font_description_to_string (font_desc);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (widget), font);
+ g_free (font);
+ }
+ else if (GTK_IS_FILE_CHOOSER (widget))
+ {
+ const char *name;
+ char *filename;
+
+ name = terminal_profile_get_property_string (profile, profile_prop);
+ if (!name)
+ goto out;
+
+ filename = g_filename_from_utf8 (name, -1, NULL, NULL, NULL);
+ if (!filename)
+ goto out; /* FIXME set filechooser to no-selection instead? */
+
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
+ g_free (filename);
+ }
+
+out:
+ g_signal_handler_unblock (widget, change->widget_notify_id);
}
static void
-show_menubar_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
+widget_change_notify_cb (PropertyChange *change)
{
- terminal_profile_set_default_show_menubar (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
+ TerminalProfile *profile = change->profile;
+ const char *profile_prop = change->profile_prop;
+ GtkWidget *widget = change->widget;
+
+ g_signal_handler_block (change->profile, change->profile_notify_id);
+
+ if (GTK_IS_RADIO_BUTTON (widget))
+ {
+ gboolean active;
+ glong value;
+
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ if (!active)
+ goto out;
+
+ value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "enum-value"));
+ g_object_set (profile, profile_prop, value, NULL);
+ }
+ else if (GTK_IS_TOGGLE_BUTTON (widget))
+ {
+ gboolean enabled;
+
+ enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ g_object_set (profile, profile_prop, transform_boolean (enabled, change->flags), NULL);
+ }
+ else if (GTK_IS_SPIN_BUTTON (widget))
+ {
+ double value;
+
+ value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+ g_object_set (profile, profile_prop, transform_spinbutton_value (value, change->flags, TRUE), NULL);
+ }
+ else if (GTK_IS_ENTRY (widget))
+ {
+ const char *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (widget));
+ g_object_set (profile, profile_prop, text, NULL);
+ }
+ else if (GTK_IS_COMBO_BOX (widget))
+ {
+ int value;
+
+ value = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+ g_object_set (profile, profile_prop, (glong) value, NULL);
+ }
+ else if (GTK_IS_COLOR_BUTTON (widget))
+ {
+ GdkColor color;
+
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &color);
+ g_object_set (profile, profile_prop, &color, NULL);
+ }
+ else if (GTK_IS_FONT_BUTTON (widget))
+ {
+ PangoFontDescription *font_desc;
+ const char *font;
+
+ font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (widget));
+ font_desc = pango_font_description_from_string (font);
+ g_object_set (profile, profile_prop, font_desc, NULL);
+ pango_font_description_free (font_desc);
+ }
+ else if (GTK_IS_RANGE (widget))
+ {
+ double value;
+
+ value = gtk_range_get_value (GTK_RANGE (widget));
+ g_object_set (profile, profile_prop, value, NULL);
+ }
+ else if (GTK_IS_FILE_CHOOSER (widget))
+ {
+ char *filename, *name = NULL;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ if (filename)
+ name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+
+ g_object_set (profile, profile_prop, name, NULL);
+ g_free (filename);
+ g_free (name);
+ }
+
+out:
+ g_signal_handler_unblock (change->profile, change->profile_notify_id);
}
-static void
-foreground_color_set (GtkWidget *colorpicker,
- TerminalProfile *profile)
+static PropertyChange *
+property_change_new (GtkWidget *editor,
+ TerminalProfile *profile,
+ const char *profile_prop,
+ GtkWidget *widget,
+ PropertyChangeFlags flags)
{
- GdkColor color;
- GdkColor bg;
+ PropertyChange *change;
+ const char *signal;
+ char notify_signal[64];
- gtk_color_button_get_color (GTK_COLOR_BUTTON (colorpicker), &color);
+ change = g_slice_new0 (PropertyChange);
- terminal_profile_get_color_scheme (profile, NULL, &bg);
-
- terminal_profile_set_color_scheme (profile, &color, &bg);
+ change->window = editor;
+
+ change->widget = widget;
+ g_assert (g_object_get_data (G_OBJECT (widget), "GT:PCD") == NULL);
+ g_object_set_data_full (G_OBJECT (widget), "GT:PCD", change, (GDestroyNotify) property_change_free);
+
+ if (GTK_IS_TOGGLE_BUTTON (widget))
+ signal = "notify::active";
+ else if (GTK_IS_SPIN_BUTTON (widget))
+ signal = "notify::value";
+ else if (GTK_IS_ENTRY (widget))
+ signal = "notify::text";
+ else if (GTK_IS_COMBO_BOX (widget))
+ signal = "notify::active";
+ else if (GTK_IS_COLOR_BUTTON (widget))
+ signal = "notify::color";
+ else if (GTK_IS_FONT_BUTTON (widget))
+ signal = "notify::font-name";
+ else if (GTK_IS_RANGE (widget))
+ signal = "value-changed";
+ else if (GTK_IS_FILE_CHOOSER (widget))
+ signal = "selection-changed"; // FIXMEchpe use file-set instead
+
+ change->widget_notify_id = g_signal_connect_swapped (widget, signal, G_CALLBACK (widget_change_notify_cb), change);
+
+ change->profile = profile;
+ change->flags = flags;
+ change->profile_prop = profile_prop;
+
+ g_snprintf (notify_signal, sizeof (notify_signal), "notify::%s", profile_prop);
+ profile_change_notify_cb (change);
+ change->profile_notify_id = g_signal_connect_swapped (profile, notify_signal, G_CALLBACK (profile_change_notify_cb), change);
+
+ return change;
}
+#if 0
static void
-background_color_set (GtkWidget *colorpicker,
- TerminalProfile *profile)
+icon_changed (GtkWidget *icon_entry,
+ TerminalProfile *profile)
{
- GdkColor color;
- GdkColor fg;
+ char *filename;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (colorpicker), &color);
+ filename = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY (icon_entry));
- terminal_profile_get_color_scheme (profile, &fg, NULL);
+ /* NULL filename happens here to unset */
+ terminal_profile_set_icon_file (profile, filename);
- terminal_profile_set_color_scheme (profile, &fg, &color);
+ g_free (filename);
}
+#endif
static void
-color_scheme_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
+color_scheme_combo_changed_cb (GtkWidget *combo,
+ GParamSpec *pspec,
+ TerminalProfile *profile)
{
- unsigned int i;
+ int i;
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
+ i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
if (i < G_N_ELEMENTS (color_schemes))
- terminal_profile_set_color_scheme (profile,
- &color_schemes[i].foreground,
- &color_schemes[i].background);
+ {
+ g_signal_handlers_block_by_func (profile, G_CALLBACK (profile_colors_notify_scheme_combo_cb), combo);
+ g_object_set (profile,
+ TERMINAL_PROFILE_FOREGROUND_COLOR, &color_schemes[i].foreground,
+ TERMINAL_PROFILE_BACKGROUND_COLOR, &color_schemes[i].background,
+ NULL);
+ g_signal_handlers_unblock_by_func (profile, G_CALLBACK (profile_colors_notify_scheme_combo_cb), combo);
+ }
else
{
/* "custom" selected, no change */
@@ -430,325 +613,172 @@
}
static void
-title_changed (GtkWidget *entry,
- TerminalProfile *profile)
+profile_colors_notify_scheme_combo_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkComboBox *combo)
{
- char *text;
+ const GdkColor *fg, *bg;
+ int i;
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
-
- terminal_profile_set_title (profile, text);
+ fg = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR);
+ bg = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BACKGROUND_COLOR);
- g_free (text);
+ for (i = 0; i < G_N_ELEMENTS (color_schemes); ++i)
+ {
+ if (fg && gdk_color_equal (fg, &color_schemes[i].foreground) &&
+ bg && gdk_color_equal (bg, &color_schemes[i].background))
+ break;
+ }
+ /* If we didn't find a match, then we get the last combo box item which is "custom" */
+
+ g_signal_handlers_block_by_func (combo, G_CALLBACK (color_scheme_combo_changed_cb), profile);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i);
+ g_signal_handlers_unblock_by_func (combo, G_CALLBACK (color_scheme_combo_changed_cb), profile);
}
static void
-title_mode_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
+palette_scheme_combo_changed_cb (GtkComboBox *combo,
+ GParamSpec *pspec,
+ TerminalProfile *profile)
{
int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
- terminal_profile_set_title_mode (profile, i);
-}
+ i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
-static void
-allow_bold_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_allow_bold (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
+ g_signal_handlers_block_by_func (profile, G_CALLBACK (profile_colors_notify_scheme_combo_cb), combo);
+ if (i < TERMINAL_PALETTE_N_BUILTINS)
+ terminal_profile_set_palette_builtin (profile, i);
+ else
+ {
+ /* "custom" selected, no change */
+ }
+ g_signal_handlers_unblock_by_func (profile, G_CALLBACK (profile_colors_notify_scheme_combo_cb), combo);
}
static void
-bell_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
+profile_palette_notify_scheme_combo_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkComboBox *combo)
{
- terminal_profile_set_silent_bell (profile,
- !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
+ guint i;
-static void
-word_chars_changed (GtkWidget *entry,
- TerminalProfile *profile)
-{
- char *text;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
-
- terminal_profile_set_word_chars (profile, text);
+ if (!terminal_profile_get_palette_is_builtin (profile, &i))
+ /* If we didn't find a match, then we want the last combo
+ * box item which is "custom"
+ */
+ i = TERMINAL_PALETTE_N_BUILTINS;
- g_free (text);
+ g_signal_handlers_block_by_func (combo, G_CALLBACK (palette_scheme_combo_changed_cb), profile);
+ gtk_combo_box_set_active (combo, i);
+ g_signal_handlers_unblock_by_func (combo, G_CALLBACK (palette_scheme_combo_changed_cb), profile);
}
static void
-scrollbar_position_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
+palette_color_notify_cb (GtkColorButton *button,
+ GParamSpec *pspec,
+ TerminalProfile *profile)
{
+ GtkWidget *editor;
+ GdkColor color;
int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
- terminal_profile_set_scrollbar_position (profile, i);
+ gtk_color_button_get_color (button, &color);
+ i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "palette-entry-index"));
+
+ editor = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ g_signal_handlers_block_by_func (profile, G_CALLBACK (profile_palette_notify_colorpickers_cb), editor);
+ terminal_profile_modify_palette_entry (profile, i, &color);
+ g_signal_handlers_unblock_by_func (profile, G_CALLBACK (profile_palette_notify_colorpickers_cb), editor);
}
static void
-scrollback_lines_value_changed (GtkWidget *spin,
- TerminalProfile *profile)
+profile_palette_notify_colorpickers_cb (TerminalProfile *profile,
+ GParamSpec *pspec,
+ GtkWidget *editor)
{
- double val;
-
- val = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin));
+ GtkWidget *w;
+ GdkColor colors[TERMINAL_PALETTE_SIZE];
+ guint n_colors, i;
- terminal_profile_set_scrollback_lines (profile, val);
-}
+ n_colors = G_N_ELEMENTS (colors);
+ terminal_profile_get_palette (profile, colors, &n_colors);
-static void
-scrollback_kilobytes_value_changed (GtkWidget *spin,
- TerminalProfile *profile)
-{
- double val;
-
- val = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin));
-
- terminal_profile_set_scrollback_lines (profile,
- (val * 1024) / BYTES_PER_LINE);
-}
-
-static void
-scroll_on_keystroke_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_scroll_on_keystroke (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
-
-static void
-scroll_on_output_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_scroll_on_output (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
-
-static void
-exit_action_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
-{
- int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
+ n_colors = MIN (n_colors, TERMINAL_PALETTE_SIZE);
+ for (i = 0; i < n_colors; i++)
+ {
+ char name[32];
+ GdkColor old_color;
- terminal_profile_set_exit_action (profile, i);
-}
+ g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1);
+ w = profile_editor_get_widget (editor, name);
-static void
-login_shell_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_login_shell (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (w), &old_color);
+ if (!gdk_color_equal (&old_color, &colors[i]))
+ {
+ g_signal_handlers_block_by_func (w, G_CALLBACK (palette_color_notify_cb), profile);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (w), &colors[i]);
+ g_signal_handlers_unblock_by_func (w, G_CALLBACK (palette_color_notify_cb), profile);
+ }
+ }
}
static void
-update_records_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
+custom_command_entry_changed_cb (GtkWidget *entry)
{
- terminal_profile_set_update_records (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
+ const char *command;
+ GError *error = NULL;
-static void
-use_custom_command_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_use_custom_command (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
+ command = gtk_entry_get_text (GTK_ENTRY (entry));
-static void
-custom_command_changed (GtkWidget *entry,
- TerminalProfile *profile)
-{
- char *text;
+ if (g_shell_parse_argv (command, NULL, NULL, &error))
+ {
+ GtkRcStyle *mod;
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
-
- terminal_profile_set_custom_command (profile, text);
+ gtk_widget_set_tooltip_text (entry, NULL);
- g_free (text);
-}
+ mod = gtk_widget_get_modifier_style (entry);
+ if (mod)
+ mod->color_flags[GTK_STATE_NORMAL] &= ~GTK_RC_TEXT;
-static void
-palette_scheme_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
-{
- unsigned int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
-
- if (i < G_N_ELEMENTS (palette_schemes))
- terminal_profile_set_palette (profile,
- palette_schemes[i].palette);
+ gtk_widget_modify_style (entry, mod);
+ /* caution, mod is potentially destroyed at this point */
+ }
else
{
- /* "custom" selected, no change */
- }
-}
-
-static void
-palette_color_set (GtkWidget *colorpicker,
- TerminalProfile *profile)
-{
- int i;
- GdkColor color;
-
- gtk_color_button_get_color (GTK_COLOR_BUTTON (colorpicker), &color);
-
- i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (colorpicker), "palette-entry-index"));
-
- terminal_profile_set_palette_entry (profile, i, &color);
-}
-
-static void
-solid_radio_toggled (GtkWidget *radiobutton,
- TerminalProfile *profile)
-{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton)))
- terminal_profile_set_background_type (profile,
- TERMINAL_BACKGROUND_SOLID);
-}
+ GdkColor color;
+ char *tooltip;
-static void
-image_radio_toggled (GtkWidget *radiobutton,
- TerminalProfile *profile)
-{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton)))
- terminal_profile_set_background_type (profile,
- TERMINAL_BACKGROUND_IMAGE);
-}
+ tooltip = g_strdup_printf (_("Error parsing command: %s"), error->message);
+ g_error_free (error);
-static void
-transparent_radio_toggled (GtkWidget *radiobutton,
- TerminalProfile *profile)
-{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton)))
- terminal_profile_set_background_type (profile,
- TERMINAL_BACKGROUND_TRANSPARENT);
+ gtk_widget_set_tooltip_text (entry, tooltip);
+ g_free (tooltip);
+
+ gdk_color_parse ("red", &color);
+ gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &color);
+ }
}
static void
-background_image_changed (GtkWidget *entry,
- TerminalProfile *profile)
+visible_name_entry_changed_cb (GtkEntry *entry,
+ GtkWindow *window)
{
+ const char *visible_name;
char *text;
- text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (entry));
-
- if (text == NULL)
- {
- return;
- }
-
- terminal_profile_set_background_image_file (profile, text);
+ visible_name = gtk_entry_get_text (entry);
+ text = g_strdup_printf (_("Editing Profile \"%s\""), visible_name);
+ gtk_window_set_title (window, text);
g_free (text);
}
static void
-scroll_background_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_scroll_background (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
-
-static void
-darken_background_value_changed (GtkWidget *scale,
- TerminalProfile *profile)
-{
- double new_val;
- double old_val;
-
- new_val = gtk_range_get_value (GTK_RANGE (scale));
- old_val = terminal_profile_get_background_darkness (profile);
-
- /* The epsilon here is some anti-infinite-loop paranoia */
- if (fabs (new_val - old_val) > 1e-6)
- terminal_profile_set_background_darkness (profile, new_val);
-}
-
-static void
-backspace_binding_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
-{
- int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
-
- terminal_profile_set_backspace_binding (profile, i);
-}
-
-static void
-delete_binding_changed (GtkWidget *combo_box,
- TerminalProfile *profile)
-{
- int i;
-
- i = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
-
- terminal_profile_set_delete_binding (profile, i);
-}
-
-static void
-reset_compat_defaults_clicked (GtkWidget *button,
- TerminalProfile *profile)
-{
- terminal_profile_reset_compat_defaults (profile);
-}
-
-static void
-use_theme_colors_toggled (GtkWidget *checkbutton,
+reset_compat_defaults_cb (GtkWidget *button,
TerminalProfile *profile)
{
- terminal_profile_set_use_theme_colors (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
-
-static void
-use_system_font_toggled (GtkWidget *checkbutton,
- TerminalProfile *profile)
-{
- terminal_profile_set_use_system_font (profile,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
-}
-
-static void
-font_set (GtkWidget *fontpicker,
- TerminalProfile *profile)
-{
- PangoFontDescription *desc;
- PangoFontDescription *tmp;
- const char *font_name;
-
- font_name = gtk_font_button_get_font_name (GTK_FONT_BUTTON (fontpicker));
- desc = pango_font_description_from_string (font_name);
- if (desc == NULL)
- {
- g_warning ("Font name \"%s\" from font picker can't be parsed", font_name);
- return;
- }
-
- /* Merge as paranoia against fontpicker giving us some junk */
- tmp = pango_font_description_copy (terminal_profile_get_font (profile));
- pango_font_description_merge (tmp, desc, TRUE);
- pango_font_description_free (desc);
- desc = tmp;
-
- terminal_profile_set_font (profile, desc);
-
- pango_font_description_free (desc);
+ terminal_profile_reset_property (profile, TERMINAL_PROFILE_DELETE_BINDING);
+ terminal_profile_reset_property (profile, TERMINAL_PROFILE_BACKSPACE_BINDING);
}
/*
@@ -771,13 +801,20 @@
static void
init_palette_scheme_menu (GtkWidget *combo_box)
{
+ /* Need to keep the same order as they're declared in terminal-profile.c */
+ const char *palette_schemes[] = {
+ N_("Tango"),
+ N_("Linux console"),
+ N_("XTerm"),
+ N_("Rxvt")
+ };
int i;
i = G_N_ELEMENTS (palette_schemes);
while (i > 0)
{
gtk_combo_box_prepend_text (GTK_COMBO_BOX (combo_box),
- _(palette_schemes[--i].name));
+ _(palette_schemes[--i]));
}
}
@@ -792,21 +829,24 @@
static void
init_background_darkness_scale (GtkWidget *scale)
{
- g_signal_connect (scale, "format_value",
+ g_signal_connect (scale, "format-value",
G_CALLBACK (format_percent_value),
NULL);
}
static void
-editor_response_cb (GtkDialog *editor,
- int id,
- void *data)
+editor_response_cb (GtkWidget *editor,
+ int response,
+ gpointer use_data)
{
- if (id == GTK_RESPONSE_HELP)
- terminal_util_show_help ("gnome-terminal-prefs", GTK_WINDOW (editor));
- else
- gtk_widget_destroy (GTK_WIDGET (editor));
+ if (response == GTK_RESPONSE_HELP)
+ {
+ terminal_util_show_help ("gnome-terminal-prefs", GTK_WINDOW (editor));
+ return;
+ }
+
+ gtk_widget_destroy (editor);
}
static GdkPixbuf *
@@ -894,7 +934,8 @@
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (filechooser), filter);
image_preview = gtk_image_new ();
- pixbuf = create_preview_pixbuf (terminal_profile_get_background_image_file (profile));
+ /* FIXMchpe this is bogus */
+ pixbuf = create_preview_pixbuf (terminal_profile_get_property_string (profile, TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE));
if (pixbuf != NULL)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (image_preview), pixbuf);
@@ -919,6 +960,29 @@
G_CALLBACK (update_image_preview), NULL);
}
+// #include <gconf/gconf.h>
+static void
+profile_editor_destroyed (GtkWidget *editor,
+ TerminalProfile *profile)
+{
+ g_signal_handlers_disconnect_by_func (profile, G_CALLBACK (profile_forgotten_cb), editor);
+ g_signal_handlers_disconnect_by_func (profile, G_CALLBACK (profile_notify_sensitivity_cb), editor);
+ g_signal_handlers_disconnect_matched (profile, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+ G_CALLBACK (profile_colors_notify_scheme_combo_cb), NULL);
+ g_signal_handlers_disconnect_matched (profile, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+ G_CALLBACK (profile_palette_notify_scheme_combo_cb), NULL);
+ g_signal_handlers_disconnect_matched (profile, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+ G_CALLBACK (profile_palette_notify_colorpickers_cb), NULL);
+ /* FIXMEchpe are those all? */
+
+ g_object_set_data (G_OBJECT (profile), "editor-window", NULL);
+ g_object_set_data (G_OBJECT (editor), "builder", NULL);
+
+ /* FIXMEchpe why!?? */
+/* gconf_client_notify (gconf_client_get_default ();
+ CONF_GLOBAL_PREFIX"/profile_list");*/
+}
+
void
terminal_profile_edit (TerminalProfile *profile,
GtkWindow *transient_parent)
@@ -926,7 +990,7 @@
char *path;
GtkBuilder *builder;
GError *error = NULL;
- GtkWidget *editor, *fontsel, *w;
+ GtkWidget *editor, *w;
GtkSizeGroup *size_group;
double num1, num2;
guint i;
@@ -966,531 +1030,181 @@
g_signal_connect (editor, "response",
G_CALLBACK (editor_response_cb),
NULL);
-
- g_signal_connect (profile, "changed",
- G_CALLBACK (profile_changed),
- editor);
- g_signal_connect (profile,
- "forgotten",
- G_CALLBACK (profile_forgotten),
- editor);
-
- profile_editor_update_sensitivity (editor, profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "profile-name-entry");
- profile_editor_update_visible_name (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (visible_name_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "profile-icon-entry");
- profile_editor_update_icon (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (icon_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "show-menubar-checkbutton");
- profile_editor_update_default_show_menubar (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (show_menubar_toggled),
- profile);
-
- profile_editor_update_color_pickers (editor, profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "foreground-colorpicker");
- g_signal_connect (w, "color_set",
- G_CALLBACK (foreground_color_set),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "background-colorpicker");
- g_signal_connect (w, "color_set",
- G_CALLBACK (background_color_set),
- profile);
w = (GtkWidget *) gtk_builder_get_object (builder, "color-scheme-combobox");
init_color_scheme_menu (w);
- profile_editor_update_color_scheme_menu (editor, profile);
- profile_editor_update_palette (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (color_scheme_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "title-entry");
- profile_editor_update_title (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (title_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "title-mode-combobox");
- profile_editor_update_title_mode (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (title_mode_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "allow-bold-checkbutton");
- profile_editor_update_allow_bold (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (allow_bold_toggled),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "bell-checkbutton");
- profile_editor_update_silent_bell (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (bell_toggled),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "word-chars-entry");
- profile_editor_update_word_chars (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (word_chars_changed),
- profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "scrollbar-position-combobox");
- profile_editor_update_scrollbar_position (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (scrollbar_position_changed),
- profile);
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "scrollback-lines-spinbutton");
- profile_editor_update_scrollback_lines (editor, profile);
- g_signal_connect (w, "value_changed",
- G_CALLBACK (scrollback_lines_value_changed),
- profile);
- gtk_size_group_add_widget (size_group, w);
-
- gtk_spin_button_get_range (GTK_SPIN_BUTTON (w), &num1, &num2);
- w = (GtkWidget *) gtk_builder_get_object (builder, "scrollback-kilobytes-spinbutton");
+ w = (GtkWidget *) gtk_builder_get_object (builder, "palette-combobox");
+ init_palette_scheme_menu (w);
- /* Sync kilobytes spinbutton range with the lines spinbutton */
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (w),
- (num1 * BYTES_PER_LINE) / 1024,
- (num2 * BYTES_PER_LINE) / 1024);
+ w = (GtkWidget *) gtk_builder_get_object (builder, "darken-background-scale");
+ init_background_darkness_scale (w);
- profile_editor_update_scrollback_lines (editor, profile);
- g_signal_connect (w, "value_changed",
- G_CALLBACK (scrollback_kilobytes_value_changed),
- profile);
- gtk_size_group_add_widget (size_group, w);
+ w = (GtkWidget *) gtk_builder_get_object (builder, "background-image-filechooser");
+ setup_background_filechooser (w, profile);
- g_object_unref (G_OBJECT (size_group));
+ /* Hook up the palette colorpickers and combo box */
- w = (GtkWidget *) gtk_builder_get_object (builder, "scroll-on-keystroke-checkbutton");
- profile_editor_update_scroll_on_keystroke (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (scroll_on_keystroke_toggled),
- profile);
+ for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
+ {
+ char name[32];
+ char *text;
- w = (GtkWidget *) gtk_builder_get_object (builder, "scroll-on-output-checkbutton");
- profile_editor_update_scroll_on_output (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (scroll_on_output_toggled),
- profile);
+ g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1);
+ w = (GtkWidget *) gtk_builder_get_object (builder, name);
- w = (GtkWidget *) gtk_builder_get_object (builder, "exit-action-combobox");
- profile_editor_update_exit_action (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (exit_action_changed),
- profile);
+ g_object_set_data (G_OBJECT (w), "palette-entry-index", GINT_TO_POINTER (i));
- w = (GtkWidget *) gtk_builder_get_object (builder, "login-shell-checkbutton");
- profile_editor_update_login_shell (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (login_shell_toggled),
- profile);
+ text = g_strdup_printf (_("Choose Palette Color %d"), i + 1);
+ gtk_color_button_set_title (GTK_COLOR_BUTTON (w), text);
+ g_free (text);
- w = (GtkWidget *) gtk_builder_get_object (builder, "update-records-checkbutton");
- profile_editor_update_update_records (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (update_records_toggled),
- profile);
+ text = g_strdup_printf (_("Palette entry %d"), i + 1);
+ gtk_widget_set_tooltip_text (w, text);
+ g_free (text);
- w = (GtkWidget *) gtk_builder_get_object (builder, "use-custom-command-checkbutton");
- profile_editor_update_use_custom_command (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (use_custom_command_toggled),
- profile);
+ g_signal_connect (w, "notify::color",
+ G_CALLBACK (palette_color_notify_cb),
+ profile);
+ }
- w = (GtkWidget *) gtk_builder_get_object (builder, "custom-command-entry");
- profile_editor_update_custom_command (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (custom_command_changed),
- profile);
+ profile_palette_notify_colorpickers_cb (profile, NULL, editor);
+ g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
+ G_CALLBACK (profile_palette_notify_colorpickers_cb),
+ editor);
w = (GtkWidget *) gtk_builder_get_object (builder, "palette-combobox");
- g_assert (w);
- init_palette_scheme_menu (w);
- g_signal_connect (w, "changed",
- G_CALLBACK (palette_scheme_changed),
- profile);
-
- profile_editor_update_background_type (editor, profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "solid-radiobutton");
- g_signal_connect (w, "toggled",
- G_CALLBACK (solid_radio_toggled),
- profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "image-radiobutton");
- g_signal_connect (w, "toggled",
- G_CALLBACK (image_radio_toggled),
- profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "transparent-radiobutton");
- g_signal_connect (w, "toggled",
- G_CALLBACK (transparent_radio_toggled),
+ g_signal_connect (w, "notify::active",
+ G_CALLBACK (palette_scheme_combo_changed_cb),
profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "background-image-filechooser");
- profile_editor_update_background_image (editor, profile);
- g_signal_connect (w, "selection-changed",
- G_CALLBACK (background_image_changed),
- profile);
- setup_background_filechooser (w, profile);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, "scroll-background-checkbutton");
- profile_editor_update_scroll_background (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (scroll_background_toggled),
- profile);
+ profile_palette_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
+ g_signal_connect (profile, "notify::" TERMINAL_PROFILE_PALETTE,
+ G_CALLBACK (profile_palette_notify_scheme_combo_cb),
+ w);
- w = (GtkWidget *) gtk_builder_get_object (builder, "darken-background-scale");
- init_background_darkness_scale (w);
- profile_editor_update_background_darkness (editor, profile);
- g_signal_connect (w, "value_changed",
- G_CALLBACK (darken_background_value_changed),
+ /* 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);
- w = (GtkWidget *) gtk_builder_get_object (builder, "backspace-binding-combobox");
- profile_editor_update_backspace_binding (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (backspace_binding_changed),
- profile);
+ profile_colors_notify_scheme_combo_cb (profile, NULL, GTK_COMBO_BOX (w));
+ g_signal_connect (profile, "notify::" TERMINAL_PROFILE_FOREGROUND_COLOR,
+ G_CALLBACK (profile_colors_notify_scheme_combo_cb),
+ w);
+ g_signal_connect (profile, "notify::" TERMINAL_PROFILE_BACKGROUND_COLOR,
+ G_CALLBACK (profile_colors_notify_scheme_combo_cb),
+ w);
- w = (GtkWidget *) gtk_builder_get_object (builder, "delete-binding-combobox");
- profile_editor_update_delete_binding (editor, profile);
- g_signal_connect (w, "changed",
- G_CALLBACK (delete_binding_changed),
- profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "use-theme-colors-checkbutton");
- profile_editor_update_use_theme_colors (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (use_theme_colors_toggled),
- profile);
- w = (GtkWidget *) gtk_builder_get_object (builder, "system-font-checkbutton");
- profile_editor_update_use_system_font (editor, profile);
- g_signal_connect (w, "toggled",
- G_CALLBACK (use_system_font_toggled),
+#if 0
+ g_signal_connect (gtk_builder_get_object (builder, "profile-icon-entry"),
+ "changed",
+ G_CALLBACK (icon_changed),
profile);
+#endif
-
- for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
- {
- gchar *t;
- gchar *s = g_strdup_printf ("palette-colorpicker-%d", i+1);
-
- w = (GtkWidget *) gtk_builder_get_object (builder, s);
- g_assert (w);
-
- t = g_strdup_printf (_("Choose Palette Color %d"), i+1);
- gtk_color_button_set_title (GTK_COLOR_BUTTON (w), t);
- g_free (t);
-
- t = g_strdup_printf (_("Palette entry %d"), i+1);
- gtk_widget_set_tooltip_text (w, t);
- g_free (t);
-
- g_object_set_data (G_OBJECT (w),
- "palette-entry-index",
- GINT_TO_POINTER (i));
-
- g_signal_connect (w, "color_set",
- G_CALLBACK (palette_color_set),
- profile);
+#define CONNECT_WITH_FLAGS(name, prop, flags) property_change_new (editor, profile, prop, (GtkWidget *) gtk_builder_get_object (builder, name), flags)
+#define CONNECT(name, prop) CONNECT_WITH_FLAGS (name, prop, 0)
+#define SET_ENUM_VALUE(name, value) g_object_set_data (gtk_builder_get_object (builder, name), "enum-value", GINT_TO_POINTER (value))
+
+ g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry")),
+ "changed",
+ G_CALLBACK (custom_command_entry_changed_cb), NULL);
+ g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry")),
+ "changed",
+ G_CALLBACK (visible_name_entry_changed_cb), editor);
- g_free (s);
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ w = (GtkWidget *) gtk_builder_get_object (builder, "scrollback-lines-spinbutton");
+ gtk_size_group_add_widget (size_group, w);
+ gtk_spin_button_get_range (GTK_SPIN_BUTTON (w), &num1, &num2);
- ++i;
- }
+ w = (GtkWidget *) gtk_builder_get_object (builder, "scrollback-kilobytes-spinbutton");
- profile_editor_update_palette (editor, profile);
+ /* Sync kilobytes spinbutton range with the lines spinbutton */
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (w),
+ (num1 * BYTES_PER_LINE) / 1024,
+ (num2 * BYTES_PER_LINE) / 1024);
- fontsel = (GtkWidget *) gtk_builder_get_object (builder, "font-selector");
- profile_editor_update_font (editor, profile);
- g_signal_connect (fontsel, "font_set",
- G_CALLBACK (font_set),
- profile);
+ gtk_size_group_add_widget (size_group, w);
+ g_object_unref (size_group);
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_size_group_add_widget (size_group,
- (GtkWidget *) gtk_builder_get_object (builder,
- "font-selector-label"));
- gtk_size_group_add_widget (size_group,
- (GtkWidget *) gtk_builder_get_object (builder,
- "profile-name-label"));
- gtk_size_group_add_widget (size_group,
- (GtkWidget *) gtk_builder_get_object (builder,
- "profile-icon-label"));
+ gtk_size_group_add_widget (size_group, (GtkWidget *) gtk_builder_get_object (builder, "font-selector-label"));
+ gtk_size_group_add_widget (size_group, (GtkWidget *) gtk_builder_get_object (builder, "profile-name-label"));
+ gtk_size_group_add_widget (size_group, (GtkWidget *) gtk_builder_get_object (builder, "profile-icon-label"));
g_object_unref (G_OBJECT (size_group));
- w = (GtkWidget *) gtk_builder_get_object (builder, "reset-compat-defaults-button");
- g_signal_connect (w, "clicked",
- G_CALLBACK (reset_compat_defaults_clicked),
- profile);
+ g_signal_connect (gtk_builder_get_object (builder, "reset-compat-defaults-button"),
+ "clicked",
+ G_CALLBACK (reset_compat_defaults_cb),
+ profile);
+
+ SET_ENUM_VALUE ("image-radiobutton", TERMINAL_BACKGROUND_IMAGE);
+ SET_ENUM_VALUE ("solid-radiobutton", TERMINAL_BACKGROUND_SOLID);
+ SET_ENUM_VALUE ("transparent-radiobutton", TERMINAL_BACKGROUND_TRANSPARENT);
+ CONNECT ("allow-bold-checkbutton", TERMINAL_PROFILE_ALLOW_BOLD);
+ CONNECT ("background-colorpicker", TERMINAL_PROFILE_BACKGROUND_COLOR);
+ CONNECT ("background-image-filechooser", TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE);
+ CONNECT ("backspace-binding-combobox", TERMINAL_PROFILE_BACKSPACE_BINDING);
+ CONNECT ("custom-command-entry", TERMINAL_PROFILE_CUSTOM_COMMAND);
+ CONNECT ("darken-background-scale", TERMINAL_PROFILE_BACKGROUND_DARKNESS);
+ CONNECT ("delete-binding-combobox", TERMINAL_PROFILE_DELETE_BINDING);
+ CONNECT ("exit-action-combobox", TERMINAL_PROFILE_EXIT_ACTION);
+ CONNECT ("font-selector", TERMINAL_PROFILE_FONT);
+ CONNECT ("foreground-colorpicker", TERMINAL_PROFILE_FOREGROUND_COLOR);
+ CONNECT ("image-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
+ CONNECT ("login-shell-checkbutton", TERMINAL_PROFILE_LOGIN_SHELL);
+ CONNECT ("profile-name-entry", TERMINAL_PROFILE_NAME);
+ CONNECT ("scroll-background-checkbutton", TERMINAL_PROFILE_SCROLL_BACKGROUND);
+ CONNECT ("scrollbar-position-combobox", TERMINAL_PROFILE_SCROLLBAR_POSITION);
+ CONNECT ("scroll-on-keystroke-checkbutton", TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE);
+ CONNECT ("scroll-on-output-checkbutton", TERMINAL_PROFILE_SCROLL_ON_OUTPUT);
+ CONNECT ("show-menubar-checkbutton", TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR);
+ CONNECT ("solid-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
+ CONNECT ("system-font-checkbutton", TERMINAL_PROFILE_USE_SYSTEM_FONT);
+ CONNECT ("title-entry", TERMINAL_PROFILE_TITLE);
+ CONNECT ("title-mode-combobox", TERMINAL_PROFILE_TITLE_MODE);
+ CONNECT ("transparent-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
+ CONNECT ("update-records-checkbutton", TERMINAL_PROFILE_UPDATE_RECORDS);
+ CONNECT ("use-custom-command-checkbutton", TERMINAL_PROFILE_USE_CUSTOM_COMMAND);
+ CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS);
+ CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS);
+ CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL /* FIXME? */);
+ CONNECT_WITH_FLAGS ("scrollback-kilobytes-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES, FLAG_SCROLLBACK);
+ CONNECT_WITH_FLAGS ("scrollback-lines-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES, 0);
+
+#undef CONNECT
+#undef CONNECT_WITH_FLAGS
+#undef SET_ENUM_VALUE
+
+ profile_notify_sensitivity_cb (profile, NULL, editor);
+ g_signal_connect (profile, "notify",
+ G_CALLBACK (profile_notify_sensitivity_cb),
+ editor);
+ g_signal_connect (profile,
+ "forgotten",
+ G_CALLBACK (profile_forgotten_cb),
+ editor);
gtk_window_set_transient_for (GTK_WINDOW (editor),
GTK_WINDOW (transient_parent));
gtk_window_present (GTK_WINDOW (editor));
}
+#if 0
static void
-widget_and_labels_set_sensitive (GtkWidget *widget, gboolean sensitive)
+profile_editor_update_icon (GtkWidget *editor,
+ TerminalProfile *profile)
{
- GList *labels, *i;
-
- labels = gtk_widget_list_mnemonic_labels (widget);
- for (i = labels; i; i = i->next)
- {
- gtk_widget_set_sensitive (GTK_WIDGET (i->data), sensitive);
- }
- g_list_free (labels);
-
- gtk_widget_set_sensitive (widget, sensitive);
-}
-
-static void
-set_insensitive (GtkWidget *editor,
- const char *widget_name,
- gboolean setting)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, widget_name);
-
- widget_and_labels_set_sensitive (w, !setting);
-}
-
-static void
-profile_editor_update_sensitivity (GtkWidget *editor,
- TerminalProfile *profile)
-{
- const TerminalSettingMask *mask;
- GtkWidget *w;
-
- /* the first time in this function the object data is unset
- * thus the last mask is 0, which means everything is sensitive,
- * which is what we want.
- */
- /* disabled for now for testing */
-#if 0
- TerminalSettingMask last_mask;
- last_mask = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (editor),
- "cached-lock-mask"));
-#endif
-
- mask = terminal_profile_get_locked_settings (profile);
-
- /* This one can't be short-circuited by the cache, since
- * it depends on settings
- */
- set_insensitive (editor, "custom-command-entry",
- mask->custom_command ||
- !terminal_profile_get_use_custom_command (profile));
-
- w = profile_editor_get_widget (editor, "custom-command-entry-label");
- gtk_widget_set_sensitive (w,
- !((mask->custom_command) ||
- !terminal_profile_get_use_custom_command (profile)));
- if (terminal_profile_get_background_type (profile) == TERMINAL_BACKGROUND_IMAGE)
- {
- set_insensitive (editor, "background-image-filechooser", mask->background_image_file);
- set_insensitive (editor, "scroll-background-checkbutton", mask->scroll_background);
- set_insensitive (editor, "darken-background-vbox", mask->background_darkness);
- }
- else if (terminal_profile_get_background_type (profile) == TERMINAL_BACKGROUND_TRANSPARENT)
- {
- set_insensitive (editor, "background-image-filechooser", TRUE);
- set_insensitive (editor, "scroll-background-checkbutton", TRUE);
- set_insensitive (editor, "darken-background-vbox", mask->background_darkness);
- }
- else
- {
- set_insensitive (editor, "background-image-filechooser", TRUE);
- set_insensitive (editor, "scroll-background-checkbutton", TRUE);
- set_insensitive (editor, "darken-background-vbox", TRUE);
- }
-
- if (!terminal_profile_get_use_system_font (profile))
- {
- set_insensitive (editor, "font-hbox", mask->font);
- }
- else
- {
- set_insensitive (editor, "font-hbox", TRUE);
- }
-
-
- if (terminal_profile_get_use_theme_colors (profile))
- {
- set_insensitive (editor, "foreground-colorpicker", TRUE);
- set_insensitive (editor, "foreground-colorpicker-label", TRUE);
- set_insensitive (editor, "background-colorpicker", TRUE);
- set_insensitive (editor, "background-colorpicker-label", TRUE);
- set_insensitive (editor, "color-scheme-combobox", TRUE);
- set_insensitive (editor, "color-scheme-combobox-label", TRUE);
- }
- else
- {
- set_insensitive (editor, "foreground-colorpicker",
- mask->foreground_color);
-
- set_insensitive (editor, "foreground-colorpicker-label",
- mask->foreground_color);
-
- set_insensitive (editor, "background-colorpicker",
- mask->background_color);
-
- set_insensitive (editor, "background-colorpicker-label",
- mask->background_color);
-
- set_insensitive (editor, "color-scheme-combobox",
- (mask->background_color) ||
- (mask->foreground_color));
-
- set_insensitive (editor, "color-scheme-combobox-label",
- (mask->background_color) ||
- (mask->foreground_color));
-
- }
-
-#if 0 /* uncomment once we've tested the sensitivity code */
- if (mask == last_mask)
- return;
- g_object_set_data (G_OBJECT (editor), "cached-lock-mask",
- GINT_TO_POINTER (mask));
-#endif
-
- set_insensitive (editor, "profile-name-entry",
- mask->visible_name);
-
- set_insensitive (editor, "profile-icon-entry",
- mask->icon_file);
-
- set_insensitive (editor, "show-menubar-checkbutton",
- mask->default_show_menubar);
-
- set_insensitive (editor, "title-entry",
- mask->title);
-
- set_insensitive (editor, "title-mode-combobox",
- mask->title_mode);
-
- set_insensitive (editor, "allow-bold-checkbutton",
- mask->allow_bold);
-
- set_insensitive (editor, "bell-checkbutton",
- mask->silent_bell);
-
- set_insensitive (editor, "word-chars-entry",
- mask->word_chars);
-
- set_insensitive (editor, "scrollbar-position-combobox",
- mask->scrollbar_position);
-
- set_insensitive (editor, "scrollback-lines-spinbutton",
- mask->scrollback_lines);
-
- set_insensitive (editor, "scrollback-kilobytes-spinbutton",
- mask->scrollback_lines);
-
- set_insensitive (editor, "scroll-on-keystroke-checkbutton",
- mask->scroll_on_keystroke);
-
- set_insensitive (editor, "scroll-on-output-checkbutton",
- mask->scroll_on_output);
-
- set_insensitive (editor, "exit-action-combobox",
- mask->exit_action);
-
- set_insensitive (editor, "login-shell-checkbutton",
- mask->login_shell);
-
- set_insensitive (editor, "update-records-checkbutton",
- mask->update_records);
-
- set_insensitive (editor, "use-custom-command-checkbutton",
- mask->use_custom_command);
-
- set_insensitive (editor, "palette-combobox",
- mask->palette);
-
- set_insensitive (editor, "solid-radiobutton",
- mask->background_type);
- set_insensitive (editor, "image-radiobutton",
- mask->background_type);
- set_insensitive (editor, "transparent-radiobutton",
- mask->background_type);
-
- set_insensitive (editor, "backspace-binding-combobox",
- mask->backspace_binding);
- set_insensitive (editor, "delete-binding-combobox",
- mask->delete_binding);
-
- set_insensitive (editor, "use-theme-colors-checkbutton",
- mask->use_theme_colors);
-
- set_insensitive (editor, "system-font-checkbutton",
- mask->use_system_font);
-
-
- {
- int i;
-
- i = 0;
- while (i < TERMINAL_PALETTE_SIZE)
- {
- char *s = g_strdup_printf ("palette-colorpicker-%d", i+1);
-
- set_insensitive (editor, s, mask->palette);
-
- g_free (s);
-
- ++i;
- }
- }
-}
-
-
-static void
-profile_editor_update_visible_name (GtkWidget *editor,
- TerminalProfile *profile)
-{
- char *s;
- GtkWidget *w;
-
- s = g_strdup_printf (_("Editing Profile \"%s\""),
- terminal_profile_get_visible_name (profile));
-
- gtk_window_set_title (GTK_WINDOW (editor), s);
-
- g_free (s);
-
- w = profile_editor_get_widget (editor, "profile-name-entry");
-
- entry_set_text_if_changed (GTK_ENTRY (w),
- terminal_profile_get_visible_name (profile));
-}
-
-static void
-profile_editor_update_icon (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- char *current_filename;
- const char *profile_filename;
-
- w = profile_editor_get_widget (editor, "profile-icon-entry");
+ GtkWidget *w;
+ char *current_filename;
+ const char *profile_filename;
+
+ w = profile_editor_get_widget (editor, "profile-icon-entry");
current_filename = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY (w));
@@ -1504,443 +1218,4 @@
gnome_icon_entry_set_filename (GNOME_ICON_ENTRY (w), profile_filename);
}
-
-static void
-profile_editor_update_default_show_menubar (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "show-menubar-checkbutton");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_default_show_menubar (profile));
-}
-
-static void
-profile_editor_update_color_pickers (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- GdkColor color1, color2;
-
- terminal_profile_get_color_scheme (profile, &color1, &color2);
-
- w = profile_editor_get_widget (editor, "foreground-colorpicker");
- colorpicker_set_if_changed (w, &color1);
-
- w = profile_editor_get_widget (editor, "background-colorpicker");
- colorpicker_set_if_changed (w, &color2);
-}
-
-static void
-profile_editor_update_color_scheme_menu (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GdkColor fg, bg;
- unsigned int i;
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "color-scheme-combobox");
-
- terminal_profile_get_color_scheme (profile, &fg, &bg);
-
- for (i = 0; i < G_N_ELEMENTS (color_schemes); i++)
- {
- if (gdk_color_equal (&color_schemes[i].foreground,
- &fg) &&
- gdk_color_equal (&color_schemes[i].background,
- &bg))
- break;
- }
-
- /* If we didn't find a match, then we want the last combo
- * box item which is "custom"
- */
- gtk_combo_box_set_active (GTK_COMBO_BOX (w), i);
-}
-
-static void
-profile_editor_update_title (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "title-entry");
-
- entry_set_text_if_changed (GTK_ENTRY (w),
- terminal_profile_get_title (profile));
-}
-
-static void
-profile_editor_update_title_mode (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "title-mode-combobox");
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (w),
- terminal_profile_get_title_mode (profile));
-}
-
-static void
-profile_editor_update_allow_bold (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "allow-bold-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_allow_bold (profile));
-}
-
-static void
-profile_editor_update_silent_bell (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "bell-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- !terminal_profile_get_silent_bell (profile));
-}
-
-static void
-profile_editor_update_word_chars (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "word-chars-entry");
-
- entry_set_text_if_changed (GTK_ENTRY (w),
- terminal_profile_get_word_chars (profile));
-}
-
-static void
-profile_editor_update_scrollbar_position (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "scrollbar-position-combobox");
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (w),
- terminal_profile_get_scrollbar_position (profile));
-}
-
-static void
-profile_editor_update_scrollback_lines (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- int lines;
-
- lines = terminal_profile_get_scrollback_lines (profile);
-
- w = profile_editor_get_widget (editor, "scrollback-lines-spinbutton");
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), lines);
-
- w = profile_editor_get_widget (editor, "scrollback-kilobytes-spinbutton");
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), (BYTES_PER_LINE * lines) / 1024);
-}
-
-static void
-profile_editor_update_scroll_on_keystroke (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "scroll-on-keystroke-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_scroll_on_keystroke (profile));
-}
-
-static void
-profile_editor_update_scroll_on_output (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "scroll-on-output-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_scroll_on_output (profile));
-}
-
-static void
-profile_editor_update_exit_action (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "exit-action-combobox");
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (w),
- terminal_profile_get_exit_action (profile));
-}
-
-static void
-profile_editor_update_login_shell (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "login-shell-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_login_shell (profile));
-}
-
-static void
-profile_editor_update_update_records (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "update-records-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_update_records (profile));
-
-}
-
-static void
-profile_editor_update_use_custom_command (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "use-custom-command-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_use_custom_command (profile));
-
-}
-
-static void
-profile_editor_update_custom_command (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- const char *command;
-
- w = profile_editor_get_widget (editor, "custom-command-entry");
-
- command = terminal_profile_get_custom_command (profile);
-
- entry_set_text_if_changed (GTK_ENTRY (w), command);
-
- /* FIXME get error from this and display it in a tooltip
- * or label
- */
- if (g_shell_parse_argv (command, NULL, NULL, NULL))
- {
- GtkRcStyle *mod;
-
- mod = gtk_widget_get_modifier_style (w);
- if (mod)
- mod->color_flags[GTK_STATE_NORMAL] &= ~GTK_RC_TEXT;
-
- gtk_widget_modify_style (w, mod);
- /* caution, mod destroyed at this point */
- }
- else
- {
- GdkColor color;
- gdk_color_parse ("red", &color);
- gtk_widget_modify_text (w, GTK_STATE_NORMAL, &color);
- }
-}
-
-static void
-profile_editor_update_palette (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- unsigned int i;
- GdkColor palette[TERMINAL_PALETTE_SIZE];
-
- terminal_profile_get_palette (profile, palette);
-
- for (i = 0; i < TERMINAL_PALETTE_SIZE; i++)
- {
- char *s = g_strdup_printf ("palette-colorpicker-%d", i+1);
- w = profile_editor_get_widget (editor, s);
- g_free (s);
-
- colorpicker_set_if_changed (w, &palette[i]);
- }
-
- w = profile_editor_get_widget (editor, "palette-combobox");
-
- for (i = 0; i < G_N_ELEMENTS (palette_schemes); i++)
- {
- int j;
- gboolean match;
-
- match = TRUE;
- j = 0;
- while (j < TERMINAL_PALETTE_SIZE)
- {
- if (!gdk_color_equal (&palette_schemes[i].palette[j],
- &palette[j]))
- {
- match = FALSE;
- break;
- }
-
- ++j;
- }
-
- if (match)
- break;
- }
-
- /* If we didn't find a match, then we want the last combo
- * box item which is "custom"
- */
- gtk_combo_box_set_active (GTK_COMBO_BOX (w), i);
-}
-
-static void
-profile_editor_update_background_type (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- switch (terminal_profile_get_background_type (profile))
- {
- case TERMINAL_BACKGROUND_SOLID:
- w = profile_editor_get_widget (editor, "solid-radiobutton");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
- break;
- case TERMINAL_BACKGROUND_IMAGE:
- w = profile_editor_get_widget (editor, "image-radiobutton");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
- break;
- case TERMINAL_BACKGROUND_TRANSPARENT:
- w = profile_editor_get_widget (editor, "transparent-radiobutton");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-profile_editor_update_background_image (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- const char *f;
-
- w = profile_editor_get_widget (editor, "background-image-filechooser");
-
- f = terminal_profile_get_background_image_file (profile);
- if (f && *f)
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (w), f);
-}
-
-static void
-profile_editor_update_scroll_background (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "scroll-background-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_scroll_background (profile));
-}
-
-static void
-profile_editor_update_background_darkness (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
- double v;
-
- w = profile_editor_get_widget (editor, "darken-background-scale");
-
- v = terminal_profile_get_background_darkness (profile);
-
- gtk_range_set_value (GTK_RANGE (w), v);
-}
-
-static void
-profile_editor_update_backspace_binding (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "backspace-binding-combobox");
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (w),
- terminal_profile_get_backspace_binding (profile));
-}
-
-static void
-profile_editor_update_delete_binding (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "delete-binding-combobox");
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (w),
- terminal_profile_get_delete_binding (profile));
-}
-
-static void
-profile_editor_update_use_theme_colors (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "use-theme-colors-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_use_theme_colors (profile));
-}
-
-static void
-profile_editor_update_use_system_font (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "system-font-checkbutton");
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
- terminal_profile_get_use_system_font (profile));
-}
-
-static void
-profile_editor_update_font (GtkWidget *editor,
- TerminalProfile *profile)
-{
- GtkWidget *w;
-
- w = profile_editor_get_widget (editor, "font-selector");
-
- fontpicker_set_if_changed (w,
- terminal_profile_get_font (profile));
-}
-
-static GtkWidget*
-profile_editor_get_widget (GtkWidget *editor,
- const char *widget_name)
-{
- GtkBuilder *builder;
-
- builder = g_object_get_data (G_OBJECT (editor), "builder");
- g_assert (builder != NULL);
-
- return (GtkWidget *) gtk_builder_get_object (builder, widget_name);
-}
+#endif
Modified: trunk/src/profile-editor.h
==============================================================================
--- trunk/src/profile-editor.h (original)
+++ trunk/src/profile-editor.h Thu May 29 19:42:24 2008
@@ -1,5 +1,3 @@
-/* dialog for editing a profile */
-
/*
* Copyright  2002 Havoc Pennington
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]