gnome-terminal r2723 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2723 - trunk/src
- Date: Thu, 29 May 2008 19:48:22 +0000 (UTC)
Author: chpe
Date: Thu May 29 19:48:22 2008
New Revision: 2723
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2723&view=rev
Log:
Make enable-mnemonics a property on TerminalApp instead of adding a gconf notification to each window.
Modified:
trunk/src/terminal-app.c
trunk/src/terminal-window.c
Modified: trunk/src/terminal-app.c
==============================================================================
--- trunk/src/terminal-app.c (original)
+++ trunk/src/terminal-app.c Thu May 29 19:48:22 2008
@@ -91,6 +91,7 @@
guint profile_list_notify_id;
guint default_profile_notify_id;
guint system_font_notify_id;
+ guint enable_mnemonics_notify_id;
GHashTable *profiles;
char* default_profile_id;
@@ -98,6 +99,7 @@
gboolean default_profile_locked;
PangoFontDescription *system_font_desc;
+ gboolean enable_mnemonics;
gboolean use_factory;
};
@@ -106,6 +108,7 @@
{
PROP_0,
PROP_DEFAULT_PROFILE,
+ PROP_ENABLE_MNEMONICS,
PROP_SYSTEM_FONT,
};
@@ -130,11 +133,16 @@
#define MONOSPACE_FONT_KEY MONOSPACE_FONT_DIR "/monospace_font_name"
#define DEFAULT_MONOSPACE_FONT ("Monospace 10")
+#define ENABLE_MNEMONICS_KEY CONF_GLOBAL_PREFIX "/use_mnemonics"
+#define DEFAULT_ENABLE_MNEMONICS (TRUE)
+
#define PROFILE_LIST_KEY CONF_GLOBAL_PREFIX "/profile_list"
#define DEFAULT_PROFILE_KEY CONF_GLOBAL_PREFIX "/default_profile"
/* Helper functions */
+/* Menubar mnemonics settings handling */
+
static int
profiles_alphabetic_cmp (gconstpointer pa,
gconstpointer pb)
@@ -917,6 +925,27 @@
}
static void
+terminal_app_enable_mnemonics_notify_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ TerminalApp *app = TERMINAL_APP (user_data);
+ GConfValue *gconf_value;
+
+ if (strcmp (gconf_entry_get_key (entry),
+ CONF_GLOBAL_PREFIX "/use_mnemonics") != 0)
+ return;
+
+ gconf_value = gconf_entry_get_value (entry);
+ if (!gconf_value || gconf_value->type != GCONF_VALUE_BOOL)
+ return;
+
+ app->enable_mnemonics = gconf_value_get_bool (gconf_value);
+ g_object_notify (G_OBJECT (app), "enable-mnemonics");
+}
+
+static void
new_profile_response_cb (GtkWidget *new_profile_dialog,
int response_id,
TerminalApp *app)
@@ -1417,9 +1446,16 @@
terminal_app_system_font_notify_cb,
app, NULL, NULL);
+ app->enable_mnemonics_notify_id =
+ gconf_client_notify_add (app->conf,
+ ENABLE_MNEMONICS_KEY,
+ terminal_app_enable_mnemonics_notify_cb,
+ app, NULL, NULL);
+
gconf_client_notify (app->conf, PROFILE_LIST_KEY);
gconf_client_notify (app->conf, DEFAULT_PROFILE_KEY);
gconf_client_notify (app->conf, MONOSPACE_FONT_KEY);
+ gconf_client_notify (app->conf, ENABLE_MNEMONICS_KEY);
terminal_accels_init ();
terminal_encoding_init ();
@@ -1446,6 +1482,8 @@
gconf_client_notify_remove (app->conf, app->default_profile_notify_id);
if (app->system_font_notify_id != 0)
gconf_client_notify_remove (app->conf, app->system_font_notify_id);
+ if (app->enable_mnemonics_notify_id != 0)
+ gconf_client_notify_remove (app->conf, app->enable_mnemonics_notify_id);
gconf_client_remove_dir (app->conf, CONF_GLOBAL_PREFIX, NULL);
gconf_client_remove_dir (app->conf, MONOSPACE_FONT_DIR, NULL);
@@ -1480,6 +1518,12 @@
else
g_value_take_boxed (value, pango_font_description_from_string (DEFAULT_MONOSPACE_FONT));
break;
+ case PROP_ENABLE_MNEMONICS:
+ g_value_set_boolean (value, app->enable_mnemonics);
+ break;
+ case PROP_DEFAULT_PROFILE:
+ g_value_set_object (value, app->default_profile);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1514,6 +1558,13 @@
g_object_class_install_property
(object_class,
+ PROP_ENABLE_MNEMONICS,
+ g_param_spec_boolean ("enable-mnemonics", NULL, NULL,
+ DEFAULT_ENABLE_MNEMONICS,
+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property
+ (object_class,
PROP_SYSTEM_FONT,
g_param_spec_boxed ("system-font", NULL, NULL,
PANGO_TYPE_FONT_DESCRIPTION,
Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c (original)
+++ trunk/src/terminal-window.c Thu May 29 19:48:22 2008
@@ -192,43 +192,25 @@
/* Menubar mnemonics settings handling */
static void
-mnemonics_setting_change_notify (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+mnemonics_setting_change_notify_cb (TerminalApp *app,
+ GParamSpec *pspec,
+ GdkScreen *screen)
{
- GdkScreen *screen;
- GtkSettings *settings;
- GConfValue *val;
+ gboolean enable_mnemonics;
- if (strcmp (gconf_entry_get_key (entry),
- CONF_GLOBAL_PREFIX"/use_mnemonics") != 0)
- return;
-
- val = gconf_entry_get_value (entry);
- if (!val || val->type != GCONF_VALUE_BOOL)
- return;
+ g_object_get (app, "enable-mnemonics", &enable_mnemonics, NULL);
- screen = GDK_SCREEN (user_data);
- settings = gtk_settings_get_for_screen (screen);
- g_object_set (settings,
- "gtk-enable-mnemonics",
- gconf_value_get_bool (val),
+ g_object_set (gtk_settings_get_for_screen (screen),
+ "gtk-enable-mnemonics", enable_mnemonics,
NULL);
}
static void
mnemonics_setting_change_destroy (GdkScreen *screen)
{
- GConfClient *client;
- guint id;
-
- id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (screen), "terminal-settings-connection"));
- g_assert (id != 0);
-
- client = gconf_client_get_default ();
- gconf_client_notify_remove (client, id);
- g_object_unref (client);
+ g_signal_handlers_disconnect_by_func (terminal_app_get (),
+ G_CALLBACK (mnemonics_setting_change_notify_cb),
+ screen);
}
/* utility functions */
@@ -1052,37 +1034,24 @@
static void
terminal_window_settings_update (GtkWidget *widget)
{
+ TerminalApp *app;
GdkScreen *screen;
- GConfClient *client;
- gboolean use_mnemonics;
- guint id;
if (!gtk_widget_has_screen (widget))
return;
screen = gtk_widget_get_screen (widget);
- if (0 != GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (screen), "terminal-settings-connection")))
+ if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (screen), "GT::HasSettingsConnection")))
return;
- client = gconf_client_get_default ();
- id = gconf_client_notify_add (client,
- CONF_GLOBAL_PREFIX "/use_mnemonics",
- mnemonics_setting_change_notify,
- screen,
- NULL, NULL);
- g_object_set_data_full (G_OBJECT (screen), "terminal-settings-connection",
- GUINT_TO_POINTER (id),
+ g_object_set_data_full (G_OBJECT (screen), "GT::HasSettingsConnection",
+ GINT_TO_POINTER (TRUE),
(GDestroyNotify) mnemonics_setting_change_destroy);
- use_mnemonics = gconf_client_get_bool (client,
- CONF_GLOBAL_PREFIX "/use_mnemonics",
- NULL);
- g_object_unref (client);
-
- g_object_set (gtk_settings_get_for_screen (screen),
- "gtk-enable-mnemonics",
- use_mnemonics,
- NULL);
+ app = terminal_app_get ();
+ mnemonics_setting_change_notify_cb (app, NULL, screen);
+ g_signal_connect (app, "notify::enable-mnemonics",
+ G_CALLBACK (mnemonics_setting_change_notify_cb), screen);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]