From: Darren S. <ds...@us...> - 2005-05-10 17:27:06
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2563/src Modified Files: key_events.c ui.c ui.h Log Message: Migration away from GtkItemFactory. Index: key_events.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/key_events.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- key_events.c 6 May 2005 18:24:19 -0000 1.61 +++ key_events.c 10 May 2005 17:26:57 -0000 1.62 @@ -784,6 +784,7 @@ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (kb_binding_quote))) { +printf("%04x %02x\n", event->keyval, event->state); if (event->state == 0) { switch (event->keyval) @@ -1333,20 +1334,11 @@ } } -static GtkItemFactoryEntry kb_menu_data[] = { - { N_("/_Reload..."), NULL, NULL, 0, "<Branch>" }, - { N_("/Reload.../_Reload bindings"), NULL, kb_reload_keymap, 0 }, - { N_("/Reload.../_Add new default bindings"), NULL, kb_add_defaults, 0 }, - { N_("/Reload.../_Merge default bindings"), NULL, kb_merge_defaults, 0 }, - { N_("/Reload.../Replace with _default bindings"), NULL, kb_reset_keymap, 0 }, -}; - void key_events_init (void) { GtkWidget *b, *scrolled_window, *hbox; GtkCellRenderer *cell; GtkTreeViewColumn *column; - GtkItemFactory *kb_menu_factory; /* * init list store @@ -1417,9 +1409,35 @@ g_signal_connect (GTK_OBJECT(b), "clicked", G_CALLBACK(kb_delete_binding), kb_bindings_list_dlg); - b = create_menu_tree (&kb_menu_factory, kb_bindings_list_dlg, NULL, - kb_menu_data, num_menu_items (kb_menu_data)); - gtk_box_pack_end_defaults (GTK_BOX(hbox), b); + { + static const GtkActionEntry kb_menu_data[] = { + { "binding", NULL, N_("_Reload...") }, + { "reload", GTK_STOCK_REVERT_TO_SAVED, N_("_Reload bindings"), NULL, NULL, kb_reload_keymap }, + { "addnew", NULL, N_("_Add new default bindings"), NULL, NULL, kb_add_defaults }, + { "merge", NULL, N_("_Merge default bindings"), NULL, NULL, kb_merge_defaults }, + { "replace", NULL, N_("Replace with _default bindings"), NULL, NULL, kb_reset_keymap }, + }; + static const char kb_menu_structure[] = + "<ui>" + "<menubar>" + "<menu action='binding'>" + "<menuitem action='reload' />" + "<menuitem action='addnew' />" + "<menuitem action='merge' />" + "<menuitem action='replace' />" + "</menu>" + "</menubar>" + "</ui>"; + + GError *error; + GtkUIManager *ui = ui_create ("bindings", kb_bindings_list_dlg); + gtk_action_group_add_actions (ui_get_action_group (ui), + kb_menu_data, G_N_ELEMENTS(kb_menu_data), + kb_bindings_list_dlg); + gtk_ui_manager_add_ui_from_string (ui, kb_menu_structure, -1, &error); + gtk_box_pack_end_defaults + (GTK_BOX(hbox), gtk_ui_manager_get_widget (ui, "/menubar")); + } gtk_box_pack_start (GTK_BOX(GTK_DIALOG(kb_bindings_list_dlg)->vbox), hbox, FALSE, FALSE, 0); Index: ui.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/ui.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ui.c 6 May 2005 18:19:55 -0000 1.8 +++ ui.c 10 May 2005 17:26:57 -0000 1.9 @@ -297,6 +297,20 @@ gtk_adjustment_value_changed (GTK_ADJUSTMENT(c_adjustments[item])); } +/* Menu/toolbar basics */ + +GtkUIManager *ui_create_manager (const char *label, GtkWidget *window) +{ + GtkUIManager *ui = gtk_ui_manager_new (); + GtkActionGroup *action = gtk_action_group_new (label); + gtk_action_group_set_translation_domain (action, PACKAGE); + gtk_ui_manager_insert_action_group (ui, action, 0); + if (window) + gtk_window_add_accel_group (GTK_WINDOW(window), + gtk_ui_manager_get_accel_group (ui)); + return ui; +} + /* Toolbar control and JS functions */ void ui_toolbar_toggle (void) Index: ui.h =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/ui.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ui.h 29 Apr 2005 19:50:06 -0000 1.2 +++ ui.h 10 May 2005 17:26:57 -0000 1.3 @@ -106,6 +106,11 @@ void ui_preferences_register (xine_t *); +/* Menu/toolbar basics */ +GtkUIManager *ui_create (const char *label, GtkWidget *window); +#define ui_get_action_group(ui) \ + ((GtkActionGroup *)(gtk_ui_manager_get_action_groups ((ui))->data)) + /* In noskin_window.c, skin_window.c: */ void window_toolbar_show (gboolean); void window_toolbar_position (gboolean top); |