2002-04-10 06:08:08 +00:00
|
|
|
/* This program was written with lots of love under the GPL by Jonathan
|
|
|
|
* Blandford <jrb@gnome.org>
|
|
|
|
*/
|
|
|
|
|
2002-03-17 21:27:09 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2009-07-10 16:46:41 +02:00
|
|
|
#include <stdlib.h>
|
2002-03-17 21:27:09 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
Update to latest eggcellrendererkeys.
2002-05-06 Anders Carlsson <andersca@gnu.org>
* eggcellrendererkeys.c: (grab_key_callback), (ungrab_stuff),
(pointless_eventbox_start_editing),
(egg_cell_renderer_keys_start_editing):
* eggcellrendererkeys.h:
Update to latest eggcellrendererkeys.
* gnome-keybinding-properties.c: (get_wm_name),
(is_metacity_running), (update_wm_window),
(wm_window_event_filter), (initialize_wm_handling),
(binding_from_string), (accel_set_func), (keybinding_key_changed),
(clear_old_model), (count_rows_foreach), (should_show_key),
(append_keys_to_tree), (reload_key_entries),
(key_entry_controlling_key_changed), (disable_collapsing_cb),
(setup_dialog), (main):
* gnome-keybinding-properties.glade:
Hard-code the list of keybindings. Add Metacity keybindings
and code for handling WM changes.
2002-05-05 23:04:45 +00:00
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#include <X11/Xatom.h>
|
2008-10-24 21:19:15 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2010-11-16 12:13:01 +00:00
|
|
|
#include <libgnome-control-center/cc-shell.h>
|
2002-03-17 21:27:09 +00:00
|
|
|
|
2010-10-31 23:58:35 -04:00
|
|
|
#include "gnome-keyboard-panel.h"
|
2002-03-17 21:27:09 +00:00
|
|
|
|
2004-03-24 02:58:55 +00:00
|
|
|
#define MAX_ELEMENTS_BEFORE_SCROLLING 10
|
2008-10-26 18:41:34 +00:00
|
|
|
#define RESPONSE_ADD 0
|
|
|
|
#define RESPONSE_REMOVE 1
|
2002-03-17 21:27:09 +00:00
|
|
|
|
2008-10-20 00:34:57 +00:00
|
|
|
typedef struct {
|
|
|
|
const char *key;
|
|
|
|
gboolean found;
|
|
|
|
} KeyMatchData;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
key_match (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
|
|
|
{
|
|
|
|
KeyMatchData *match_data = data;
|
|
|
|
KeyEntry *element;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter,
|
|
|
|
KEYENTRY_COLUMN, &element,
|
|
|
|
-1);
|
|
|
|
|
2009-01-25 11:28:25 +00:00
|
|
|
if (element && g_strcmp0 (element->gconf_key, match_data->key) == 0)
|
2008-10-20 00:34:57 +00:00
|
|
|
{
|
|
|
|
match_data->found = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-25 11:28:25 +00:00
|
|
|
static gboolean
|
2008-10-20 00:34:57 +00:00
|
|
|
key_is_already_shown (GtkTreeModel *model, const KeyListEntry *entry)
|
|
|
|
{
|
|
|
|
KeyMatchData data;
|
|
|
|
|
|
|
|
data.key = entry->name;
|
2009-01-25 11:28:25 +00:00
|
|
|
data.found = FALSE;
|
2008-10-20 00:34:57 +00:00
|
|
|
gtk_tree_model_foreach (model, key_match, &data);
|
|
|
|
|
|
|
|
return data.found;
|
|
|
|
}
|
|
|
|
|
Update to latest eggcellrendererkeys.
2002-05-06 Anders Carlsson <andersca@gnu.org>
* eggcellrendererkeys.c: (grab_key_callback), (ungrab_stuff),
(pointless_eventbox_start_editing),
(egg_cell_renderer_keys_start_editing):
* eggcellrendererkeys.h:
Update to latest eggcellrendererkeys.
* gnome-keybinding-properties.c: (get_wm_name),
(is_metacity_running), (update_wm_window),
(wm_window_event_filter), (initialize_wm_handling),
(binding_from_string), (accel_set_func), (keybinding_key_changed),
(clear_old_model), (count_rows_foreach), (should_show_key),
(append_keys_to_tree), (reload_key_entries),
(key_entry_controlling_key_changed), (disable_collapsing_cb),
(setup_dialog), (main):
* gnome-keybinding-properties.glade:
Hard-code the list of keybindings. Add Metacity keybindings
and code for handling WM changes.
2002-05-05 23:04:45 +00:00
|
|
|
static gboolean
|
2007-03-19 15:14:06 +00:00
|
|
|
count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
Update to latest eggcellrendererkeys.
2002-05-06 Anders Carlsson <andersca@gnu.org>
* eggcellrendererkeys.c: (grab_key_callback), (ungrab_stuff),
(pointless_eventbox_start_editing),
(egg_cell_renderer_keys_start_editing):
* eggcellrendererkeys.h:
Update to latest eggcellrendererkeys.
* gnome-keybinding-properties.c: (get_wm_name),
(is_metacity_running), (update_wm_window),
(wm_window_event_filter), (initialize_wm_handling),
(binding_from_string), (accel_set_func), (keybinding_key_changed),
(clear_old_model), (count_rows_foreach), (should_show_key),
(append_keys_to_tree), (reload_key_entries),
(key_entry_controlling_key_changed), (disable_collapsing_cb),
(setup_dialog), (main):
* gnome-keybinding-properties.glade:
Hard-code the list of keybindings. Add Metacity keybindings
and code for handling WM changes.
2002-05-05 23:04:45 +00:00
|
|
|
{
|
2007-03-19 15:14:06 +00:00
|
|
|
gint *rows = data;
|
2005-05-22 15:46:45 +00:00
|
|
|
|
2007-03-19 15:14:06 +00:00
|
|
|
(*rows)++;
|
Update to latest eggcellrendererkeys.
2002-05-06 Anders Carlsson <andersca@gnu.org>
* eggcellrendererkeys.c: (grab_key_callback), (ungrab_stuff),
(pointless_eventbox_start_editing),
(egg_cell_renderer_keys_start_editing):
* eggcellrendererkeys.h:
Update to latest eggcellrendererkeys.
* gnome-keybinding-properties.c: (get_wm_name),
(is_metacity_running), (update_wm_window),
(wm_window_event_filter), (initialize_wm_handling),
(binding_from_string), (accel_set_func), (keybinding_key_changed),
(clear_old_model), (count_rows_foreach), (should_show_key),
(append_keys_to_tree), (reload_key_entries),
(key_entry_controlling_key_changed), (disable_collapsing_cb),
(setup_dialog), (main):
* gnome-keybinding-properties.glade:
Hard-code the list of keybindings. Add Metacity keybindings
and code for handling WM changes.
2002-05-05 23:04:45 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:14:06 +00:00
|
|
|
static void
|
2009-07-10 16:46:41 +02:00
|
|
|
ensure_scrollbar (GtkBuilder *builder, int i)
|
2007-03-19 15:14:06 +00:00
|
|
|
{
|
|
|
|
if (i == MAX_ELEMENTS_BEFORE_SCROLLING)
|
|
|
|
{
|
|
|
|
GtkRequisition rectangle;
|
2009-07-10 16:46:41 +02:00
|
|
|
GObject *actions_swindow = gtk_builder_get_object (builder,
|
|
|
|
"actions_swindow");
|
2010-11-16 12:13:01 +00:00
|
|
|
GtkWidget *treeview = WID (builder,
|
2009-07-10 16:46:41 +02:00
|
|
|
"shortcut_treeview");
|
|
|
|
gtk_widget_ensure_style (treeview);
|
|
|
|
gtk_widget_size_request (treeview, &rectangle);
|
|
|
|
gtk_widget_set_size_request (treeview, -1, rectangle.height);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow),
|
2007-03-19 15:14:06 +00:00
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
}
|
|
|
|
}
|