[gnome-terminal] prefs: Move keybinding prefs dialogue to its own source file



commit bdc5730f5c4adace314562c08ee1b6f5dacac3fa
Author: Christian Persch <chpe gnome org>
Date:   Mon Jan 28 11:31:48 2013 +0100

    prefs: Move keybinding prefs dialogue to its own source file

 po/POTFILES.in                               |    2 +-
 src/Makefile.am                              |    4 +-
 src/{keybinding-editor.ui => preferences.ui} |    2 +-
 src/terminal-accels.c                        |   61 ++---------------
 src/terminal-accels.h                        |    2 +-
 src/terminal-app.c                           |    5 +-
 src/terminal-app.h                           |    2 +-
 src/terminal-prefs.c                         |   93 ++++++++++++++++++++++++++
 src/terminal-prefs.h                         |   29 ++++++++
 src/terminal-window.c                        |   14 ++--
 src/terminal.gresource.xml                   |    2 +-
 src/terminal.xml                             |    2 +-
 12 files changed, 145 insertions(+), 73 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3a5db73..42b4cce 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,7 +7,7 @@ src/migration.c
 src/profile-editor.c
 src/org.gnome.Terminal.gschema.xml.in
 [type: gettext/glade]src/find-dialog.ui
-[type: gettext/glade]src/keybinding-editor.ui
+[type: gettext/glade]src/preferences.ui
 [type: gettext/glade]src/profile-manager.ui
 [type: gettext/glade]src/profile-preferences.ui
 [type: gettext/glade]src/terminal-appmenu.ui
diff --git a/src/Makefile.am b/src/Makefile.am
index b111a8f..100975e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,6 +50,8 @@ gnome_terminal_server_SOURCES = \
 	terminal-mdi-container.h \
 	terminal-notebook.c \
 	terminal-notebook.h \
+	terminal-prefs.c \
+	terminal-prefs.h \
 	terminal-profile-utils.c \
 	terminal-profile-utils.h \
 	terminal-schemas.h \
@@ -298,7 +300,7 @@ EXTRA_DIST = \
 	nautilus.symbols \
 	encodings-dialog.ui \
 	find-dialog.ui \
-	keybinding-editor.ui \
+	preferences.ui \
 	profile-manager.ui \
 	profile-preferences.ui \
 	$(about_DATA) \
diff --git a/src/keybinding-editor.ui b/src/preferences.ui
similarity index 99%
rename from src/keybinding-editor.ui
rename to src/preferences.ui
index 0d1653b..510d07e 100644
--- a/src/keybinding-editor.ui
+++ b/src/preferences.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkDialog" id="keybindings-dialog">
+  <object class="GtkDialog" id="preferences-dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Keyboard Shortcuts</property>
diff --git a/src/terminal-accels.c b/src/terminal-accels.c
index 1976e05..f8f1b9d 100644
--- a/src/terminal-accels.c
+++ b/src/terminal-accels.c
@@ -271,7 +271,6 @@ static guint sync_idle_id = 0;
 static GtkAccelGroup *notification_group = NULL;
 /* never set settings keys in response to receiving a settings notify. */
 static int inside_settings_notify = 0;
-static GtkWidget *edit_keys_dialog = NULL;
 static GtkTreeStore *edit_keys_store = NULL;
 static GHashTable *settings_key_to_entry;
 static GSettings *keybinding_settings = NULL;
@@ -701,28 +700,13 @@ accel_cleared_callback (GtkCellRendererAccel *cell,
 }
 
 static void
-edit_keys_dialog_destroy_cb (GtkWidget *widget,
-                             gpointer user_data)
+treeview_destroy_cb (GtkWidget *tree_view,
+                     gpointer user_data)
 {
   g_signal_handlers_disconnect_by_func (notification_group, G_CALLBACK (treeview_accel_changed_cb), user_data);
-  edit_keys_dialog = NULL;
   edit_keys_store = NULL;
 }
 
-static void
-edit_keys_dialog_response_cb (GtkWidget *editor,
-                              int response,
-                              gpointer use_data)
-{  
-  if (response == GTK_RESPONSE_HELP)
-    {
-      terminal_util_show_help ("gnome-terminal-shortcuts", GTK_WINDOW (editor));
-      return;
-    }
-    
-  gtk_widget_destroy (editor);
-}
-
 #ifdef GNOME_ENABLE_DEBUG
 static void
 row_changed (GtkTreeModel *tree_model,
@@ -736,38 +720,12 @@ row_changed (GtkTreeModel *tree_model,
 #endif
 
 void
-terminal_edit_keys_dialog_show (GtkWindow *transient_parent)
+terminal_accels_fill_treeview (GtkWidget *tree_view)
 {
-  GtkWidget *dialog, *tree_view, *disable_mnemonics_button, *disable_menu_accel_button;
   GtkTreeViewColumn *column;
   GtkCellRenderer *cell_renderer;
   GtkTreeStore *tree;
   guint i;
-  GSettings *settings;
-
-  if (edit_keys_dialog != NULL)
-    goto done;
-
-  terminal_util_load_builder_resource ("/org/gnome/terminal/ui/keybinding-editor.ui",
-                                       "keybindings-dialog", &dialog,
-                                       "disable-mnemonics-checkbutton", &disable_mnemonics_button,
-                                       "disable-menu-accel-checkbutton", &disable_menu_accel_button,
-                                       "accelerators-treeview", &tree_view,
-                                       NULL);
-
-  terminal_util_bind_mnemonic_label_sensitivity (dialog);
-
-  settings = terminal_app_get_global_settings (terminal_app_get ());
-  g_settings_bind (settings,
-                   TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
-                   disable_mnemonics_button,
-                   "active",
-                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-  g_settings_bind (settings,
-                   TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY,
-                   disable_menu_accel_button,
-                   "active",
-                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
 
   /* Column 1 */
   cell_renderer = gtk_cell_renderer_text_new ();
@@ -833,15 +791,6 @@ terminal_edit_keys_dialog_show (GtkWindow *transient_parent)
   g_signal_connect (notification_group, "accel-changed",
                     G_CALLBACK (treeview_accel_changed_cb), tree);
 
-  edit_keys_dialog = dialog;
-  g_signal_connect (dialog, "destroy",
-                    G_CALLBACK (edit_keys_dialog_destroy_cb), tree);
-  g_signal_connect (dialog, "response",
-                    G_CALLBACK (edit_keys_dialog_response_cb),
-                    NULL);
-  gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 350);
-
-done:
-  gtk_window_set_transient_for (GTK_WINDOW (edit_keys_dialog), transient_parent);
-  gtk_window_present (GTK_WINDOW (edit_keys_dialog));
+  g_signal_connect (tree_view, "destroy",
+                    G_CALLBACK (treeview_destroy_cb), tree);
 }
diff --git a/src/terminal-accels.h b/src/terminal-accels.h
index f12c5df..bbefddf 100644
--- a/src/terminal-accels.h
+++ b/src/terminal-accels.h
@@ -26,7 +26,7 @@ void terminal_accels_init (void);
  
 void terminal_accels_shutdown (void);
 
-void terminal_edit_keys_dialog_show (GtkWindow *transient_parent);
+void terminal_accels_fill_treeview (GtkWidget *treeview);
 
 G_END_DECLS
 
diff --git a/src/terminal-app.c b/src/terminal-app.c
index ce203bc..5fd8c42 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -39,6 +39,7 @@
 #include "terminal-schemas.h"
 #include "terminal-gdbus.h"
 #include "terminal-defines.h"
+#include "terminal-prefs.h"
 
 #include <errno.h>
 #include <string.h>
@@ -1353,10 +1354,10 @@ terminal_app_edit_profile (TerminalApp     *app,
 }
 
 void
-terminal_app_edit_keybindings (TerminalApp     *app,
+terminal_app_edit_preferences (TerminalApp     *app,
                                GtkWindow       *transient_parent)
 {
-  terminal_edit_keys_dialog_show (transient_parent);
+  terminal_prefs_show_preferences (transient_parent);
 }
 
 void
diff --git a/src/terminal-app.h b/src/terminal-app.h
index 43fa338..1820b94 100644
--- a/src/terminal-app.h
+++ b/src/terminal-app.h
@@ -76,7 +76,7 @@ TerminalScreen *terminal_app_new_terminal (TerminalApp     *app,
 void terminal_app_manage_profiles (TerminalApp     *app,
                                    GtkWindow       *transient_parent);
 
-void terminal_app_edit_keybindings (TerminalApp     *app,
+void terminal_app_edit_preferences (TerminalApp     *app,
                                     GtkWindow       *transient_parent);
 void terminal_app_edit_encodings   (TerminalApp     *app,
                                     GtkWindow       *transient_parent);
diff --git a/src/terminal-prefs.c b/src/terminal-prefs.c
new file mode 100644
index 0000000..c6035e8
--- /dev/null
+++ b/src/terminal-prefs.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright  2001, 2002 Havoc Pennington, Red Hat Inc.
+ * Copyright  2008, 2011, 2012, 2013 Christian Persch
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "terminal-prefs.h"
+#include "terminal-accels.h"
+#include "terminal-app.h"
+#include "terminal-debug.h"
+#include "terminal-intl.h"
+#include "terminal-schemas.h"
+#include "terminal-util.h"
+
+static GtkWidget *prefs_dialog = NULL;
+
+static void
+prefs_dialog_response_cb (GtkWidget *editor,
+                          int response,
+                          gpointer use_data)
+{
+  if (response == GTK_RESPONSE_HELP)
+    {
+      terminal_util_show_help ("gnome-terminal-shortcuts", GTK_WINDOW (editor));
+      return;
+    }
+
+  gtk_widget_destroy (editor);
+}
+
+void
+terminal_prefs_show_preferences (GtkWindow *transient_parent)
+{
+  GtkWidget *dialog, *tree_view, *disable_mnemonics_button, *disable_menu_accel_button;
+  GSettings *settings;
+
+  if (prefs_dialog != NULL)
+    goto done;
+
+  terminal_util_load_builder_resource ("/org/gnome/terminal/ui/preferences.ui",
+                                       "preferences-dialog", &dialog,
+                                       "disable-mnemonics-checkbutton", &disable_mnemonics_button,
+                                       "disable-menu-accel-checkbutton", &disable_menu_accel_button,
+                                       "accelerators-treeview", &tree_view,
+                                       NULL);
+
+  terminal_util_bind_mnemonic_label_sensitivity (dialog);
+
+  settings = terminal_app_get_global_settings (terminal_app_get ());
+  g_settings_bind (settings,
+                   TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
+                   disable_mnemonics_button,
+                   "active",
+                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+  g_settings_bind (settings,
+                   TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY,
+                   disable_menu_accel_button,
+                   "active",
+                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+  terminal_accels_fill_treeview (tree_view);
+
+
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (prefs_dialog_response_cb),
+                    NULL);
+  gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 350);
+
+  prefs_dialog = dialog;
+  g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &prefs_dialog);
+
+done:
+  gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog), transient_parent);
+  gtk_window_present (GTK_WINDOW (prefs_dialog));
+}
diff --git a/src/terminal-prefs.h b/src/terminal-prefs.h
new file mode 100644
index 0000000..ba7e2ae
--- /dev/null
+++ b/src/terminal-prefs.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright  2013 Christian Persch
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TERMINAL_PREFS_H
+#define TERMINAL_PREFS_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void terminal_prefs_show_preferences (GtkWindow *transient_parent);
+
+G_END_DECLS
+
+#endif /* TERMINAL_PREFS_H */
diff --git a/src/terminal-window.c b/src/terminal-window.c
index e6c923b..212b354 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -26,7 +26,6 @@
 #include <gdk/gdkx.h>
 #endif
 
-#include "terminal-accels.h"
 #include "terminal-app.h"
 #include "terminal-debug.h"
 #include "terminal-enums.h"
@@ -166,7 +165,7 @@ static void edit_paste_callback               (GtkAction *action,
                                                TerminalWindow *window);
 static void edit_select_all_callback          (GtkAction *action,
                                                TerminalWindow *window);
-static void edit_keybindings_callback         (GtkAction *action,
+static void edit_preferences_callback         (GtkAction *action,
                                                TerminalWindow *window);
 static void edit_profiles_callback            (GtkAction *action,
                                                TerminalWindow *window);
@@ -1667,10 +1666,10 @@ terminal_window_init (TerminalWindow *window)
       { "EditProfiles", NULL, N_("P_rofilesâ"), NULL,
         NULL,
         G_CALLBACK (edit_profiles_callback) },
-      { "EditKeybindings", NULL, N_("_Keyboard Shortcutsâ"), NULL,
+      { "EditPreferences", NULL, N_("Pre_ferencesâ"), NULL,
         NULL,
-        G_CALLBACK (edit_keybindings_callback) },
-      { "EditCurrentProfile", GTK_STOCK_PREFERENCES, N_("_Preferencesâ"), NULL,
+        G_CALLBACK (edit_preferences_callback) },
+      { "EditCurrentProfile", GTK_STOCK_PREFERENCES, N_("_Profile Preferencesâ"), NULL,
         NULL,
         G_CALLBACK (edit_current_profile_callback) },
 
@@ -3116,11 +3115,10 @@ edit_select_all_callback (GtkAction *action,
 }
       
 static void
-edit_keybindings_callback (GtkAction *action,
+edit_preferences_callback (GtkAction *action,
                            TerminalWindow *window)
 {
-  terminal_app_edit_keybindings (terminal_app_get (),
-                                 GTK_WINDOW (window));
+  terminal_app_edit_preferences (terminal_app_get (), GTK_WINDOW (window));
 }
 
 static void
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index 23993c9..e23f789 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -22,7 +22,7 @@
     <file alias="ui/terminal.about" compressed="true">terminal.about</file>
     <file alias="ui/encodings-dialog.ui" compressed="true" preprocess="xml-stripblanks">encodings-dialog.ui</file>
     <file alias="ui/find-dialog.ui" compressed="true" preprocess="xml-stripblanks">find-dialog.ui</file>
-    <file alias="ui/keybinding-editor.ui" compressed="true" preprocess="xml-stripblanks">keybinding-editor.ui</file>
+    <file alias="ui/preferences.ui" compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
     <file alias="ui/profile-manager.ui" compressed="true" preprocess="xml-stripblanks">profile-manager.ui</file>
     <file alias="ui/profile-preferences.ui" compressed="true" preprocess="xml-stripblanks">profile-preferences.ui</file>
   </gresource>
diff --git a/src/terminal.xml b/src/terminal.xml
index dbadf16..9fee096 100644
--- a/src/terminal.xml
+++ b/src/terminal.xml
@@ -20,7 +20,7 @@
       <menuitem action="EditSelectAll" />
       <separator />
       <menuitem action="EditProfiles" />
-      <menuitem action="EditKeybindings" />
+      <menuitem action="EditPreferences" />
       <menuitem action="EditCurrentProfile" />
     </menu>
     <menu action="View">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]