gnome-terminal r2632 - trunk/src
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-terminal r2632 - trunk/src
- Date: Thu, 29 May 2008 19:40:21 +0000 (UTC)
Author: chpe
Date: Thu May 29 19:40:21 2008
New Revision: 2632
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2632&view=rev
Log:
Port the keybinding editor to gtkbuilder.
No need to wrap the treestore into a sort model, just turn on sorting directly.
Remove obsolete button press handler to start editing the accel, since GtkCellRendererAccell does this all itself.
Added:
trunk/src/keybinding-editor.ui
Modified:
trunk/src/Makefile.am
trunk/src/gnome-terminal.glade2
trunk/src/terminal-accels.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu May 29 19:40:21 2008
@@ -92,6 +92,7 @@
ui_DATA = \
terminal.ui \
encodings-dialog.ui \
+ keybinding-editor.ui \
profile-manager.ui \
skey-challenge.ui \
$(NULL)
Modified: trunk/src/gnome-terminal.glade2
==============================================================================
--- trunk/src/gnome-terminal.glade2 (original)
+++ trunk/src/gnome-terminal.glade2 Thu May 29 19:40:21 2008
@@ -4,180 +4,6 @@
<glade-interface>
<requires lib="gnome"/>
-<widget class="GtkDialog" id="keybindings-dialog">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Keyboard Shortcuts</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">False</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">2</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="close_button1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-7</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkTable" id="table32">
- <property name="border_width">5</property>
- <property name="visible">True</property>
- <property name="n_rows">4</property>
- <property name="n_columns">1</property>
- <property name="homogeneous">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
-
- <child>
- <widget class="GtkCheckButton" id="disable-mnemonics-checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Disable all me_nu access keys (such as Alt+f to open File menu)</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="accelerators-treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">True</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- <property name="fixed_height_mode">False</property>
- <property name="hover_selection">False</property>
- <property name="hover_expand">False</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="label59">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Shortcut keys:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="mnemonic_widget">accelerators-treeview</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkCheckButton" id="disable-menu-accel-checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Disable m_enu shortcut key (F10 by default)</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">fill</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
<widget class="GtkDialog" id="new-profile-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">New Profile</property>
Added: trunk/src/keybinding-editor.ui
==============================================================================
--- (empty file)
+++ trunk/src/keybinding-editor.ui Thu May 29 19:40:21 2008
@@ -0,0 +1,115 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.12"/>
+ <object class="GtkDialog" id="keybindings-dialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Keyboard Shortcuts</property>
+ <property name="role">gnome-terminal-accels</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkTable" id="table32">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="n_rows">4</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="disable-menu-accel-checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Disable m_enu shortcut key (F10 by default)</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label59">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Shortcut keys:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">accelerators-treeview</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <object class="GtkTreeView" id="accelerators-treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="rules_hint">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable-mnemonics-checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Disable all me_nu access keys (such as Alt+f to open File menu)</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <object class="GtkButton" id="close_button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
Modified: trunk/src/terminal-accels.c
==============================================================================
--- trunk/src/terminal-accels.c (original)
+++ trunk/src/terminal-accels.c Thu May 29 19:40:21 2008
@@ -27,7 +27,6 @@
#include "terminal-util.h"
#include "terminal.h"
#include <string.h>
-#include <glade/glade.h>
#define D(x)
@@ -1050,72 +1049,14 @@
}
}
-typedef struct
-{
- GtkTreeView *tree_view;
- GtkTreePath *path;
-} IdleData;
-
-static gboolean
-real_start_editing_cb (IdleData *idle_data)
-{
- gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view));
- gtk_tree_view_set_cursor (idle_data->tree_view,
- idle_data->path,
- gtk_tree_view_get_column (idle_data->tree_view, 1),
- TRUE);
-
- gtk_tree_path_free (idle_data->path);
- g_free (idle_data);
-
- return FALSE;
-}
-
-static gboolean
-start_editing_cb (GtkTreeView *tree_view,
- GdkEventButton *event,
- gpointer data)
-{
- GtkTreePath *path;
-
- if (event->window != gtk_tree_view_get_bin_window (tree_view))
- return FALSE;
-
- if (gtk_tree_view_get_path_at_pos (tree_view,
- (gint) event->x,
- (gint) event->y,
- &path, NULL,
- NULL, NULL))
- {
- IdleData *idle_data;
-
- if (gtk_tree_path_get_depth (path) == 1)
- {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- idle_data = g_new (IdleData, 1);
- idle_data->tree_view = tree_view;
- idle_data->path = path;
- g_signal_stop_emission_by_name (G_OBJECT (tree_view), "button_press_event");
- g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data);
- }
-
- return TRUE;
-}
-
void
terminal_edit_keys_dialog_show (GtkWindow *transient_parent)
{
- GladeXML *xml;
- GtkWidget *w;
+ GtkWidget *dialog, *tree_view, *disable_mnemonics_button, *disable_menu_accel_button;
+ GtkTreeViewColumn *column;
GtkCellRenderer *cell_renderer;
- int i;
- GtkTreeModel *sort_model;
GtkTreeStore *tree;
- GtkTreeViewColumn *column;
- GtkTreeIter parent_iter;
+ int i;
if (edit_keys_dialog != NULL)
{
@@ -1124,56 +1065,46 @@
return;
}
- /* No keybindings editor yet, create one */
- xml = terminal_util_load_glade_file (TERM_GLADE_FILE,
- "keybindings-dialog",
- transient_parent);
- if (xml == NULL)
+ if (!terminal_util_load_builder_file ("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))
return;
-
- w = glade_xml_get_widget (xml, "disable-mnemonics-checkbutton");
- edit_keys_dialog_mnemonics_checkbutton = w;
- g_signal_connect (G_OBJECT (w), "destroy",
+ edit_keys_dialog_mnemonics_checkbutton = disable_mnemonics_button;
+ g_signal_connect (disable_mnemonics_button, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&edit_keys_dialog_mnemonics_checkbutton);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), !using_mnemonics);
- g_signal_connect (G_OBJECT (w), "toggled",
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_mnemonics_button), !using_mnemonics);
+ g_signal_connect (disable_mnemonics_button, "toggled",
G_CALLBACK (disable_mnemonics_toggled),
NULL);
- w = glade_xml_get_widget (xml, "disable-menu-accel-checkbutton");
-
- edit_keys_dialog_menu_accel_checkbutton = w;
- g_signal_connect (G_OBJECT (w), "destroy",
+ edit_keys_dialog_menu_accel_checkbutton = disable_menu_accel_button;
+ g_signal_connect (disable_menu_accel_button, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&edit_keys_dialog_menu_accel_checkbutton);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), !using_menu_accels);
- g_signal_connect (G_OBJECT (w), "toggled",
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_menu_accel_button), !using_menu_accels);
+ g_signal_connect (disable_menu_accel_button, "toggled",
G_CALLBACK (disable_menu_accels_toggled),
NULL);
- w = glade_xml_get_widget (xml, "accelerators-treeview");
-
- g_signal_connect (G_OBJECT (w), "button_press_event",
- G_CALLBACK (start_editing_cb), NULL);
-
- edit_keys_dialog_treeview = w;
- g_signal_connect (edit_keys_dialog_treeview, "destroy",
+ edit_keys_dialog_treeview = tree_view;
+ g_signal_connect (tree_view, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&edit_keys_dialog_treeview);
- tree = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
-
/* Column 1 */
cell_renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("_Action"),
cell_renderer,
"text", ACTION_COLUMN,
NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
gtk_tree_view_column_set_sort_column_id (column, ACTION_COLUMN);
/* Column 2 */
@@ -1183,72 +1114,61 @@
"accel_mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
NULL);
g_signal_connect (cell_renderer, "accel-edited",
- G_CALLBACK (accel_edited_callback), w);
+ G_CALLBACK (accel_edited_callback), tree_view);
g_signal_connect (cell_renderer, "accel-cleared",
- G_CALLBACK (accel_cleared_callback), w);
+ G_CALLBACK (accel_cleared_callback), tree_view);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Shortcut _Key"));
gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
gtk_tree_view_column_set_cell_data_func (column, cell_renderer, accel_set_func, NULL, NULL);
gtk_tree_view_column_set_sort_column_id (column, KEYVAL_COLUMN);
- gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
/* Add the data */
- i = 0;
- while (i < (gint) G_N_ELEMENTS (all_entries))
+ tree = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
+ for (i = 0; i < G_N_ELEMENTS (all_entries); ++i)
{
+ GtkTreeIter parent_iter;
int j;
+
gtk_tree_store_append (tree, &parent_iter, NULL);
gtk_tree_store_set (tree, &parent_iter,
ACTION_COLUMN, _(all_entries[i].user_visible_name),
-1);
- j = 0;
- while (j < all_entries[i].n_elements)
+ for (j = 0; j < all_entries[i].n_elements; ++j)
{
+ KeyEntry *key_entry = &(all_entries[i].key_entry[j]);
GtkTreeIter iter;
- KeyEntry *key_entry;
- key_entry = &(all_entries[i].key_entry[j]);
- gtk_tree_store_append (tree, &iter, &parent_iter);
- gtk_tree_store_set (tree, &iter,
- ACTION_COLUMN, _(key_entry->user_visible_name),
- KEYVAL_COLUMN, key_entry,
- -1);
- ++j;
+ gtk_tree_store_insert_with_values (tree, &iter, &parent_iter, -1,
+ ACTION_COLUMN, _(key_entry->user_visible_name),
+ KEYVAL_COLUMN, key_entry,
+ -1);
}
- ++i;
}
-
- sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model),
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (tree),
KEYVAL_COLUMN, accel_compare_func,
NULL, NULL);
- gtk_tree_view_set_model (GTK_TREE_VIEW (w), sort_model);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (tree), KEYVAL_COLUMN,
+ GTK_SORT_ASCENDING);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (w));
- g_object_unref (G_OBJECT (tree));
-
- w = glade_xml_get_widget (xml, "keybindings-dialog");
+ gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (tree));
+ g_object_unref (tree);
- g_signal_connect (G_OBJECT (w), "response",
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ edit_keys_dialog = dialog;
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &edit_keys_dialog);
+ g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
- gtk_window_set_default_size (GTK_WINDOW (w),
- -1, 350);
-
- terminal_util_set_unique_role (GTK_WINDOW (w), "gnome-terminal-accels");
-
- g_object_unref (xml);
-
- edit_keys_dialog = w;
-
- gtk_window_set_transient_for (GTK_WINDOW (edit_keys_dialog), transient_parent);
- g_signal_connect (edit_keys_dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &edit_keys_dialog);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 350);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), transient_parent);
gtk_window_present (GTK_WINDOW (edit_keys_dialog));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]