From 1cdfa9b1b52ed625741423b827032688aed03c8c Mon Sep 17 00:00:00 2001 From: msdelos Date: Sun, 21 Nov 2010 12:44:49 -0300 Subject: [PATCH] Port-xfce4-clipman-plugin-to-xfce48pre1 --- configure.ac.in | 9 +- panel-plugin/Makefile.am | 22 +- panel-plugin/actions.c | 7 +- panel-plugin/main-panel-plugin.c | 28 +-- panel-plugin/main-status-icon.c | 2 +- panel-plugin/menu.c | 4 +- panel-plugin/settings-dialog.glade | 456 ++++++++++++++++----------------- panel-plugin/xfce4-clipman-settings.c | 183 +++++++------- 8 files changed, 338 insertions(+), 373 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 9b3f094..3d2ce16 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -55,15 +55,14 @@ dnl *** Check for required packages *** dnl *********************************** XDT_CHECK_LIBX11_REQUIRE() XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0]) -XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.0]) +XDT_CHECK_PACKAGE([EXO], [exo-1], [0.5.3]) XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.16.0]) XDT_CHECK_PACKAGE([GDKX], [gdk-x11-2.0], [2.10.0]) XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0]) -XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0]) -XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0]) -XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0]) +XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.7.0]) +XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.7.0]) +XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.7.0]) XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0]) -XDT_CHECK_PACKAGE([GLADE], [libglade-2.0], [2.6.0]) dnl *************************** dnl *** Check for libunique *** diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am index 3770397..51ffbbe 100644 --- a/panel-plugin/Makefile.am +++ b/panel-plugin/Makefile.am @@ -16,9 +16,9 @@ bin_PROGRAMS = xfce4-clipman xfce4-popup-clipman xfce4-clipman-settings # if MAINTAINER_MODE -BUILT_SOURCES = settings-dialog_glade.h -settings-dialog_glade.h: settings-dialog.glade - $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=settings_dialog_glade $< >$@ +BUILT_SOURCES = settings-dialog.ui.h +settings-dialog.ui.h: settings-dialog.glade + $(AM_V_GEN) exo-csource --static --strip-comments --strip-content --name=settings_dialog_ui $< >$@ endif # @@ -50,7 +50,7 @@ xfce4_popup_clipman_LDADD = \ xfce4_clipman_settings_SOURCES = \ xfce4-clipman-settings.c \ common.h \ - settings-dialog_glade.h \ + settings-dialog_ui.h \ actions.c actions.h \ $(NULL) @@ -60,9 +60,8 @@ xfce4_clipman_settings_CFLAGS = \ @EXO_CFLAGS@ \ @LIBX11_CFLAGS@ \ @GTK_CFLAGS@ \ - @LIBXFCEGUI4_CFLAGS@ \ + @LIBXFCE4UI_CFLAGS@ \ @XFCONF_CFLAGS@ \ - @GLADE_CFLAGS@ \ @UNIQUE_CFLAGS@ \ $(NULL) @@ -71,9 +70,8 @@ xfce4_clipman_settings_LDADD = \ @EXO_LIBS@ \ @LIBX11_LIBS@ \ @GTK_LIBS@ \ - @LIBXFCEGUI4_LIBS@ \ + @LIBXFCE4UI_LIBS@ \ @XFCONF_LIBS@ \ - @GLADE_LIBS@ \ @UNIQUE_LIBS@ \ $(NULL) @@ -100,7 +98,7 @@ xfce4_clipman_CFLAGS = \ @GDKX_CFLAGS@ \ @GTK_CFLAGS@ \ @LIBXFCE4UTIL_CFLAGS@ \ - @LIBXFCEGUI4_CFLAGS@ \ + @LIBXFCE4UI_CFLAGS@ \ @XFCONF_CFLAGS@ \ $(NULL) @@ -112,7 +110,7 @@ xfce4_clipman_LDADD = \ @GDKX_LIBS@ \ @GTK_LIBS@ \ @LIBXFCE4UTIL_LIBS@ \ - @LIBXFCEGUI4_LIBS@ \ + @LIBXFCE4UI_LIBS@ \ @XFCONF_LIBS@ \ $(NULL) @@ -141,7 +139,7 @@ xfce4_clipman_plugin_CFLAGS = \ @GDKX_CFLAGS@ \ @GTK_CFLAGS@ \ @LIBXFCE4UTIL_CFLAGS@ \ - @LIBXFCEGUI4_CFLAGS@ \ + @LIBXFCE4UI_CFLAGS@ \ @LIBXFCE4PANEL_CFLAGS@ \ @XFCONF_CFLAGS@ \ $(NULL) @@ -154,7 +152,7 @@ xfce4_clipman_plugin_LDADD = \ @GDKX_LIBS@ \ @GTK_LIBS@ \ @LIBXFCE4UTIL_LIBS@ \ - @LIBXFCEGUI4_LIBS@ \ + @LIBXFCE4UI_LIBS@ \ @LIBXFCE4PANEL_LIBS@ \ @XFCONF_LIBS@ \ $(NULL) diff --git a/panel-plugin/actions.c b/panel-plugin/actions.c index 589eba5..2c132c7 100644 --- a/panel-plugin/actions.c +++ b/panel-plugin/actions.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "common.h" @@ -359,10 +359,9 @@ cb_entry_activated (GtkMenuItem *mi, DBG ("Execute command `%s'", real_command); - xfce_exec (real_command, FALSE, FALSE, &error); - if (error != NULL) + if (!gdk_spawn_command_line_on_screen (NULL, real_command, &error)) { - xfce_err (_("Unable to execute the command \"%s\"\n\n%s"), real_command, error->message); + xfce_dialog_show_error (NULL, error, _("Unable to execute the command \"%s\"\n\n%s"), real_command, error->message); g_error_free (error); } g_free (real_command); diff --git a/panel-plugin/main-panel-plugin.c b/panel-plugin/main-panel-plugin.c index 2777400..c57f251 100644 --- a/panel-plugin/main-panel-plugin.c +++ b/panel-plugin/main-panel-plugin.c @@ -26,9 +26,8 @@ #include #include -#include -#include -#include +#include +#include #include "common.h" #include "plugin.h" @@ -40,8 +39,6 @@ static void panel_plugin_register (XfcePanelPlugin *panel_plugin); XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (panel_plugin_register); -static gboolean panel_plugin_set_size (MyPlugin *plugin, - gint size); static gboolean cb_button_pressed (GtkButton *button, GdkEventButton *event, MyPlugin *plugin); @@ -76,7 +73,7 @@ panel_plugin_register (XfcePanelPlugin *panel_plugin) /* Panel Button */ plugin->button = xfce_create_panel_toggle_button (); /* The image is set through the set_size callback */ - plugin->image = gtk_image_new (); + plugin->image = xfce_panel_image_new_from_source (GTK_STOCK_PASTE); gtk_container_add (GTK_CONTAINER (plugin->button), plugin->image); gtk_container_add (GTK_CONTAINER (panel_plugin), plugin->button); xfce_panel_plugin_add_action_widget (panel_plugin, plugin->button); @@ -84,8 +81,6 @@ panel_plugin_register (XfcePanelPlugin *panel_plugin) G_CALLBACK (cb_button_pressed), plugin); /* Signals */ - g_signal_connect_swapped (panel_plugin, "size-changed", - G_CALLBACK (panel_plugin_set_size), plugin); xfce_panel_plugin_menu_show_about (panel_plugin); g_signal_connect_swapped (panel_plugin, "about", G_CALLBACK (plugin_about), plugin); @@ -103,23 +98,6 @@ panel_plugin_register (XfcePanelPlugin *panel_plugin) } static gboolean -panel_plugin_set_size (MyPlugin *plugin, - gint size) -{ - GdkPixbuf *pixbuf; - - gtk_widget_set_size_request (plugin->button, size, size); - - size -= 2 + 2 * MAX (gtk_widget_get_style (plugin->button)->xthickness, - gtk_widget_get_style (plugin->button)->ythickness); - pixbuf = xfce_themed_icon_load (GTK_STOCK_PASTE, size); - gtk_image_set_from_pixbuf (GTK_IMAGE (plugin->image), pixbuf); - g_object_unref (G_OBJECT (pixbuf)); - - return TRUE; -} - -static gboolean cb_button_pressed (GtkButton *button, GdkEventButton *event, MyPlugin *plugin) diff --git a/panel-plugin/main-status-icon.c b/panel-plugin/main-status-icon.c index efef0bd..3ea10d5 100644 --- a/panel-plugin/main-status-icon.c +++ b/panel-plugin/main-status-icon.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "common.h" #include "plugin.h" diff --git a/panel-plugin/menu.c b/panel-plugin/menu.c index 5a673c5..279752b 100644 --- a/panel-plugin/menu.c +++ b/panel-plugin/menu.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include "collector.h" @@ -122,7 +122,7 @@ cb_clear_history (ClipmanMenu *menu) { GtkClipboard *clipboard; - if (!xfce_confirm (_("Are you sure you want to clear the history?"), GTK_STOCK_YES, NULL)) + if (!xfce_dialog_confirm (NULL, GTK_STOCK_YES, NULL, _("Are you sure you want to clear the history?"), NULL)) return; clipman_history_clear (menu->priv->history); diff --git a/panel-plugin/settings-dialog.glade b/panel-plugin/settings-dialog.glade index ea14415..52f9136 100644 --- a/panel-plugin/settings-dialog.glade +++ b/panel-plugin/settings-dialog.glade @@ -1,10 +1,20 @@ - + + + 1000 + 5 + 10 + 5 + 0 + 5 + + + Type here your custom text, for example an URL, a filename, etc. + - - + Clipman center 340 @@ -15,67 +25,64 @@ False Configure the plugin - + True vertical 2 - + True True 6 - + True 6 vertical 2 - + True 0 none - + True 6 6 12 - + True vertical 6 - + Sync _selections True True False True - If checked, the selections will be synced with the default clipboard in a way that you can paste what you select + If checked, the selections will be synced with the default clipboard in a way that you can paste what you select True True - + 0 - + - + - - + + True <b>Behavior</b> True - - - label_item - + - + False False @@ -83,76 +90,76 @@ - + True 0 none - + True 6 6 12 - + True vertical 6 - + Save on _quit True True False - If checked, this option will restore the history on every new Xfce session + If checked, this option will restore the history on every new Xfce session True True - + 0 - + Store an _image True True False - If checked, this option allows to store one image inside the history + If checked, this option allows to store one image inside the history True True - + 1 - + Ignore s_elections True True False True - If checked, the selections won't affect the history except the manual copies + If checked, the selections won't affect the history except the manual copies True True - + 2 - + True 4 - + True 0 Size of the _history: True max-texts-in-history - + False False @@ -160,72 +167,68 @@ - + True True - 5 5 1000 5 10 0 - + adjustment1 + False False 1 - + 3 - + - + - - + + True <b>History</b> True - - - label_item - + - + False False 1 - + - - + + True General - + False - tab - + True 6 vertical 6 - + Enable _actions True True False - If checked, the clipboard texts will be matched against regular expressions and a menu will display possible actions + If checked, the clipboard texts will be matched against regular expressions and a menu will display possible actions True True - + False False @@ -233,49 +236,47 @@ - + True 6 - + True True automatic automatic in - + True True False True - - + - + 0 - + True vertical 6 - + True True True - - + True gtk-add 1 - + - + False False @@ -283,20 +284,19 @@ - + True False True True - - + True gtk-edit 1 - + - + False False @@ -304,20 +304,19 @@ - + True False True True - - + True gtk-delete 1 - + - + False False @@ -325,19 +324,18 @@ - + True True True - - + True gtk-clear 1 - + - + False False @@ -345,53 +343,47 @@ 3 - + False False 1 - + 1 - - - 1 - + - - + + True Actions - + 1 False - tab - + 1 - + True edge - + gtk-help - 2 True True True True - - + False False @@ -399,30 +391,30 @@ - + gtk-close True True True True - + False False 1 - + False end 0 - + - - + + Edit Action True center-on-parent @@ -435,21 +427,21 @@ settings-dialog False - + True vertical 2 - + True 2 6 - + True gtk-dialog-info 6 - + False False @@ -457,17 +449,17 @@ - + True 0 You can use the substitution parameters "\1", "\2" and so on in the commands. The parameter "\0" represents the complete text. If you don't know regular expressions, have a look at the documentation of Clipman that has an introdution for them. True - + 1 - + False False @@ -475,32 +467,32 @@ - + True 6 0 none - + True 6 6 12 - + True vertical 6 - + True 4 - + True 0 Name: - + False False @@ -508,30 +500,30 @@ - + True True - + 1 - + 0 - + True 4 - + True 0 Pattern: - + False False @@ -539,59 +531,58 @@ - + True 4 - + True True - + 0 - + True True True - - + True gtk-edit 1 - + - + False False 1 - + 1 - + 1 - + True 2 - + True gtk-dialog-info 1 - + False False @@ -599,49 +590,46 @@ - + True 0 The pattern is always anchored within the special characters ^$ - + 1 - + 2 - + Activate only on manual copy True True False True - By default the action is triggerred by a selection, check this option to trigger the action only when you make a manual copy + By default the action is triggerred by a selection, check this option to trigger the action only when you make a manual copy True - + 3 - + - + - - + + True <b>Action</b> True - - - label_item - + - + False False @@ -649,36 +637,36 @@ - + True 6 0 none - + True 6 6 12 - + True 6 - + True vertical 6 - + True 4 - + True 0 Name: - + False False @@ -686,16 +674,16 @@ - + True True - + 1 - + False False @@ -703,15 +691,15 @@ - + True 4 - + True 0 Command: - + False False @@ -719,16 +707,16 @@ - + True True - + 1 - + False False @@ -736,49 +724,48 @@ - + True True automatic automatic in - + True True False True - + - + 2 - + 0 - + True vertical 6 - + True True True - - + True gtk-add 1 - + - + False False @@ -786,20 +773,19 @@ - + True False True True - - + True gtk-refresh 1 - + - + False False @@ -807,64 +793,60 @@ - + True False True True - - + True gtk-delete 1 - + - + False False 2 - + False False 1 - + - + - - + + True <b>Commands</b> True - - - label_item - + - + 3 - + True end - + gtk-cancel True True True True - + False False @@ -872,31 +854,33 @@ - + gtk-ok - 1 True True True True - + False False 1 - + False end 0 - + - - + + action-dialog-button-ok + + + Regular expression True 260 @@ -908,19 +892,18 @@ action-dialog False - + True vertical 2 - + True True gtk-apply True - - + False False @@ -928,50 +911,46 @@ - + True 0 in - + True - + True True 2 2 4 word - Type here your custom text, for example an URL, a filename, etc. - + textbuffer1 + - + - + - - label_item - - + 2 - + True end - + gtk-cancel - -6 True True True True - + False False @@ -979,28 +958,31 @@ - + gtk-ok - -10 True True True True - + False False 1 - + False end 0 - + - - + + regex-dialog-button-cancel + regex-dialog-button-ok + + + diff --git a/panel-plugin/xfce4-clipman-settings.c b/panel-plugin/xfce4-clipman-settings.c index 170e657..72e101f 100644 --- a/panel-plugin/xfce4-clipman-settings.c +++ b/panel-plugin/xfce4-clipman-settings.c @@ -30,12 +30,11 @@ #include #include -#include -#include +#include #include #include "common.h" -#include "settings-dialog_glade.h" +#include "settings-dialog.ui.h" #include "actions.h" static void prop_dialog_run (); @@ -70,7 +69,7 @@ static void update_test_regex_textview_tags (); static void cb_set_action_dialog_button_ok (GtkWidget *widget); static XfconfChannel *xfconf_channel = NULL; -static GladeXML *gxml = NULL; +static GtkBuilder *builder = NULL; static ClipmanActions *actions = NULL; static GtkWidget *settings_dialog = NULL; static guint test_regex_changed_timeout = 0; @@ -82,73 +81,83 @@ prop_dialog_run (void) { GtkWidget *action_dialog; - /* GladeXML */ - gxml = glade_xml_new_from_buffer (settings_dialog_glade, settings_dialog_glade_length, NULL, NULL); + builder = gtk_builder_new (); + gtk_builder_add_from_string (builder, settings_dialog_ui, settings_dialog_ui_length, NULL); /* Dialogs */ - settings_dialog = glade_xml_get_widget (gxml, "settings-dialog"); - action_dialog = glade_xml_get_widget (gxml, "action-dialog"); + settings_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog")); + action_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog")); /* General settings */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "add-selections")), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "add-selections")), DEFAULT_ADD_PRIMARY_CLIPBOARD); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "history-ignore-selections")), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "history-ignore-selections")), DEFAULT_HISTORY_IGNORE_PRIMARY_CLIPBOARD); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "save-on-quit")), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "save-on-quit")), DEFAULT_SAVE_ON_QUIT); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "store-an-image")), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "store-an-image")), (gboolean)DEFAULT_MAX_IMAGES_IN_HISTORY); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (glade_xml_get_widget (gxml, "max-texts-in-history")), + gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "max-texts-in-history")), (gdouble)DEFAULT_MAX_TEXTS_IN_HISTORY); + xfconf_g_property_bind (xfconf_channel, "/settings/add-primary-clipboard", G_TYPE_BOOLEAN, - G_OBJECT (glade_xml_get_widget (gxml, "add-selections")), "active"); + gtk_builder_get_object (builder, "add-selections"), "active"); xfconf_g_property_bind (xfconf_channel, "/settings/history-ignore-primary-clipboard", G_TYPE_BOOLEAN, - G_OBJECT (glade_xml_get_widget (gxml, "history-ignore-selections")), "active"); + gtk_builder_get_object (builder, "history-ignore-selections"), "active"); xfconf_g_property_bind (xfconf_channel, "/settings/save-on-quit", G_TYPE_BOOLEAN, - G_OBJECT (glade_xml_get_widget (gxml, "save-on-quit")), "active"); + gtk_builder_get_object (builder, "save-on-quit"), "active"); xfconf_g_property_bind (xfconf_channel, "/settings/max-images-in-history", G_TYPE_UINT, - G_OBJECT (glade_xml_get_widget (gxml, "store-an-image")), "active"); + gtk_builder_get_object (builder, "store-an-image"), "active"); xfconf_g_property_bind (xfconf_channel, "/settings/max-texts-in-history", G_TYPE_UINT, - G_OBJECT (glade_xml_get_widget (gxml, "max-texts-in-history")), "value"); + gtk_builder_get_object (builder, "max-texts-in-history"), "value"); /* Actions tab and dialog */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "enable-actions")), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "enable-actions")), DEFAULT_ENABLE_ACTIONS); xfconf_g_property_bind (xfconf_channel, "/settings/enable-actions", G_TYPE_BOOLEAN, - G_OBJECT (glade_xml_get_widget (gxml, "enable-actions")), "active"); - - glade_xml_signal_connect_data (gxml, "cb_add_action", G_CALLBACK (cb_add_action), NULL); - glade_xml_signal_connect_data (gxml, "cb_edit_action", G_CALLBACK (cb_edit_action), NULL); - glade_xml_signal_connect_data (gxml, "cb_delete_action", G_CALLBACK (cb_delete_action), NULL); - glade_xml_signal_connect_data (gxml, "cb_reset_actions", G_CALLBACK (cb_reset_actions), NULL); - glade_xml_signal_connect_data (gxml, "cb_actions_row_activated", G_CALLBACK (cb_actions_row_activated), NULL); - glade_xml_signal_connect_data (gxml, "cb_add_command", G_CALLBACK (cb_add_command), NULL); - glade_xml_signal_connect_data (gxml, "cb_refresh_command", G_CALLBACK (cb_refresh_command), NULL); - glade_xml_signal_connect_data (gxml, "cb_delete_command", G_CALLBACK (cb_delete_command), NULL); - glade_xml_signal_connect_data (gxml, "cb_show_help", G_CALLBACK (cb_show_help), NULL); - glade_xml_signal_connect_data (gxml, "cb_test_regex", G_CALLBACK (cb_test_regex), NULL); - glade_xml_signal_connect_data (gxml, "cb_test_regex_changed", G_CALLBACK (cb_test_regex_changed), NULL); - - setup_actions_treeview (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "actions"))); - setup_commands_treeview (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "commands"))); + gtk_builder_get_object (builder, "enable-actions"), "active"); + + g_signal_connect (gtk_builder_get_object (builder, "button-add-action"), "clicked", G_CALLBACK(cb_add_action), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-edit-action"), "clicked", G_CALLBACK(cb_edit_action), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-delete-action"), "clicked", G_CALLBACK(cb_delete_action), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-reset-actions"), "clicked", G_CALLBACK(cb_reset_actions), NULL); + g_signal_connect (gtk_builder_get_object (builder, "actions"), "row_activated", G_CALLBACK(cb_actions_row_activated), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-add-command"), "clicked", G_CALLBACK(cb_add_command), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-refresh-command"), "clicked", G_CALLBACK(cb_refresh_command), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-delete-command"), "clicked", G_CALLBACK(cb_delete_command), NULL); + g_signal_connect (gtk_builder_get_object (builder, "settings-dialog-button-help"), "clicked", G_CALLBACK(cb_show_help), NULL); + g_signal_connect (gtk_builder_get_object (builder, "button-action-pattern"), "clicked", G_CALLBACK(cb_test_regex), NULL); + g_signal_connect (gtk_builder_get_object (builder, "regex-entry"), "changed", G_CALLBACK(cb_test_regex_changed), NULL); + + g_signal_connect_swapped (gtk_builder_get_object (builder, "settings-dialog-button-close"), "clicked", + G_CALLBACK(gtk_dialog_response), settings_dialog); + + setup_actions_treeview (GTK_TREE_VIEW (gtk_builder_get_object (builder, "actions"))); + setup_commands_treeview (GTK_TREE_VIEW (gtk_builder_get_object (builder, "commands"))); setup_test_regex_dialog (); /* Callbacks for the OK button sensitivity in the edit action dialog */ - g_signal_connect_after (glade_xml_get_widget (gxml, "action-name"), "changed", + g_signal_connect_after (gtk_builder_get_object (builder, "action-name"), "changed", G_CALLBACK (cb_set_action_dialog_button_ok), NULL); - g_signal_connect_after (glade_xml_get_widget (gxml, "regex"), "changed", + g_signal_connect_after (gtk_builder_get_object (builder, "regex"), "changed", G_CALLBACK (cb_set_action_dialog_button_ok), NULL); - g_signal_connect_after (glade_xml_get_widget (gxml, "button-add-command"), "clicked", + g_signal_connect_after (gtk_builder_get_object (builder, "button-add-command"), "clicked", G_CALLBACK (cb_set_action_dialog_button_ok), NULL); - g_signal_connect_after (glade_xml_get_widget (gxml, "button-delete-command"), "clicked", + g_signal_connect_after (gtk_builder_get_object (builder, "button-delete-command"), "clicked", G_CALLBACK (cb_set_action_dialog_button_ok), NULL); + g_signal_connect_after (gtk_builder_get_object (builder, "button-delete-command"), "clicked", + G_CALLBACK (gtk_dialog_response), NULL); + + g_signal_connect_swapped (gtk_builder_get_object (builder, "action-dialog-button-cancel"), "clicked", + G_CALLBACK(gtk_dialog_response), action_dialog); + /* Run the dialog */ while ((gtk_dialog_run (GTK_DIALOG (settings_dialog))) == 2); gtk_widget_destroy (action_dialog); gtk_widget_destroy (settings_dialog); - g_object_unref (gxml); + g_object_unref (G_OBJECT(builder)); /* Save the actions */ clipman_actions_save (actions); @@ -215,7 +224,8 @@ cb_show_help (GtkButton *button) if (gdk_spawn_command_line_on_screen (screen, command, NULL)) goto out; - xfce_err ("Unable to open documentation \"%s\"", filename); + xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))), + NULL, "Unable to open documentation \"%s\"", filename); out: g_free (filename); @@ -285,11 +295,11 @@ apply_action (const gchar *original_action_name) gchar *command_name; gchar *command; - action_name = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (gxml, "action-name"))); - regex = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (gxml, "regex"))); - group = (gint)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "manual"))); + action_name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "action-name"))); + regex = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "regex"))); + group = (gint)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "manual"))); - treeview = glade_xml_get_widget (gxml, "commands"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "commands")); model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)); if (!gtk_tree_model_get_iter_first (model, &iter)) return; @@ -310,7 +320,7 @@ apply_action (const gchar *original_action_name) while (gtk_tree_model_iter_next (model, &iter)); /* Refresh the actions treeview */ - treeview = glade_xml_get_widget (gxml, "actions"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "actions")); refresh_actions_treeview (GTK_TREE_VIEW (treeview)); } @@ -322,8 +332,8 @@ cb_actions_selection_changed (GtkTreeSelection *selection) sensitive = gtk_tree_selection_get_selected (selection, &model, NULL); - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "button-edit-action"), sensitive); - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "button-delete-action"), sensitive); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "button-edit-action")), sensitive); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "button-delete-action")), sensitive); } static void @@ -332,7 +342,7 @@ cb_add_action (GtkButton *button) GtkWidget *action_dialog; gint res; - action_dialog = glade_xml_get_widget (gxml, "action-dialog"); + action_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog")); entry_dialog_cleanup (); res = gtk_dialog_run (GTK_DIALOG (action_dialog)); @@ -352,7 +362,7 @@ cb_edit_action (GtkButton *button) GtkTreePath *path; GtkTreeViewColumn *column; - treeview = glade_xml_get_widget (gxml, "actions"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "actions")); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) @@ -379,14 +389,14 @@ cb_actions_row_activated (GtkTreeView *treeview, gchar *title; gint res; - action_dialog = glade_xml_get_widget (gxml, "action-dialog"); + action_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog")); entry_dialog_cleanup (); actions_model = gtk_tree_view_get_model (treeview); gtk_tree_model_get_iter (actions_model, &iter, path); gtk_tree_model_get (actions_model, &iter, 0, &entry, -1); - commands_model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "commands"))); + commands_model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "commands"))); #if GLIB_CHECK_VERSION (2,16,0) { GHashTableIter hiter; @@ -404,9 +414,9 @@ cb_actions_row_activated (GtkTreeView *treeview, g_hash_table_foreach (entry->commands, (GHFunc)__foreach_command_fill_commands, commands_model); #endif - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "action-name")), entry->action_name); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "regex")), entry->pattern); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "manual")), entry->group); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "action-name")), entry->action_name); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "regex")), entry->pattern); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "manual")), entry->group); res = gtk_dialog_run (GTK_DIALOG (action_dialog)); gtk_widget_hide (action_dialog); @@ -424,7 +434,7 @@ cb_delete_action (GtkButton *button) GtkTreeModel *model; GtkTreeIter iter; - treeview = glade_xml_get_widget (gxml, "actions"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "actions")); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) @@ -463,7 +473,7 @@ cb_reset_actions (GtkButton *button) g_object_unref (actions); actions = clipman_actions_get (); - refresh_actions_treeview (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "actions"))); + refresh_actions_treeview (GTK_TREE_VIEW (gtk_builder_get_object (builder, "actions"))); } @@ -495,13 +505,13 @@ entry_dialog_cleanup (void) { GtkTreeModel *model; - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "action-dialog-button-ok"), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog-button-ok")), FALSE); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "action-name")), ""); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "regex")), ""); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (glade_xml_get_widget (gxml, "manual")), FALSE); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "action-name")), ""); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "regex")), ""); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "manual")), FALSE); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "commands"))); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "commands"))); gtk_list_store_clear (GTK_LIST_STORE (model)); } @@ -533,21 +543,21 @@ cb_commands_selection_changed (GtkTreeSelection *selection) sensitive = gtk_tree_selection_get_selected (selection, &model, &iter); - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "button-refresh-command"), sensitive); - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "button-delete-command"), sensitive); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "button-refresh-command")), sensitive); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "button-delete-command")), sensitive); if (sensitive) { gtk_tree_model_get (model, &iter, 1, &command_name, 2, &command, -1); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "command-name")), command_name); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "command")), command); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "command-name")), command_name); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "command")), command); g_free (command_name); g_free (command); } else { - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "command-name")), ""); - gtk_entry_set_text (GTK_ENTRY (glade_xml_get_widget (gxml, "command")), ""); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "command-name")), ""); + gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "command")), ""); } } @@ -560,8 +570,8 @@ cb_add_command (GtkButton *button) GtkTreeIter iter; gchar *title; - command_name = glade_xml_get_widget (gxml, "command-name"); - command = glade_xml_get_widget (gxml, "command"); + command_name = GTK_WIDGET (gtk_builder_get_object (builder, "command-name")); + command = GTK_WIDGET (gtk_builder_get_object (builder, "command")); if (gtk_entry_get_text (GTK_ENTRY (command_name))[0] == '\0' || gtk_entry_get_text (GTK_ENTRY (command))[0] == '\0') @@ -570,7 +580,7 @@ cb_add_command (GtkButton *button) title = g_markup_printf_escaped ("%s\n%s", gtk_entry_get_text (GTK_ENTRY (command_name)), gtk_entry_get_text (GTK_ENTRY (command))); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "commands"))); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "commands"))); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, title, 1, gtk_entry_get_text (GTK_ENTRY (command_name)), @@ -592,14 +602,14 @@ cb_refresh_command (GtkButton *button) GtkWidget *command; gchar *title; - command_name = glade_xml_get_widget (gxml, "command-name"); - command = glade_xml_get_widget (gxml, "command"); + command_name = GTK_WIDGET (gtk_builder_get_object (builder, "command-name")); + command = GTK_WIDGET (gtk_builder_get_object (builder, "command")); if (gtk_entry_get_text (GTK_ENTRY (command_name))[0] == '\0' || gtk_entry_get_text (GTK_ENTRY (command))[0] == '\0') return; - treeview = glade_xml_get_widget (gxml, "commands"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "commands")); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -626,7 +636,7 @@ cb_delete_command (GtkButton *button) GtkTreeModel *model; GtkTreeIter iter; - treeview = glade_xml_get_widget (gxml, "commands"); + treeview = GTK_WIDGET (gtk_builder_get_object (builder, "commands")); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) @@ -647,7 +657,7 @@ setup_test_regex_dialog (void) GtkWidget *textview; GtkTextBuffer *buffer; - textview = glade_xml_get_widget (gxml, "regex-textview"); + textview = GTK_WIDGET (gtk_builder_get_object (builder, "regex-textview")); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); gtk_text_buffer_create_tag (buffer, "match", @@ -670,9 +680,9 @@ cb_test_regex (GtkButton *button) GtkWidget *entry; const gchar *pattern; - regex = glade_xml_get_widget (gxml, "regex"); - dialog = glade_xml_get_widget (gxml, "regex-dialog"); - entry = glade_xml_get_widget (gxml, "regex-entry"); + regex = GTK_WIDGET (gtk_builder_get_object (builder, "regex")); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "regex-dialog")); + entry = GTK_WIDGET (gtk_builder_get_object (builder, "regex-entry")); pattern = gtk_entry_get_text (GTK_ENTRY (regex)); gtk_entry_set_text (GTK_ENTRY (entry), pattern); @@ -691,7 +701,7 @@ cb_test_regex_changed (GtkWidget *widget) { #if GTK_CHECK_VERSION (2, 16, 0) if (test_regex_changed_timeout == 0) - gtk_entry_set_icon_from_stock (GTK_ENTRY (glade_xml_get_widget (gxml, "regex-entry")), + gtk_entry_set_icon_from_stock (GTK_ENTRY (gtk_builder_get_object (builder, "regex-entry")), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_REFRESH); #endif @@ -721,8 +731,8 @@ update_test_regex_textview_tags (void) const gchar *pattern; gchar *text; - entry = glade_xml_get_widget (gxml, "regex-entry"); - textview = glade_xml_get_widget (gxml, "regex-textview"); + entry = GTK_WIDGET (gtk_builder_get_object (builder, "regex-entry")); + textview = GTK_WIDGET (gtk_builder_get_object (builder, "regex-textview")); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); gtk_text_buffer_get_iter_at_offset (buffer, &start, 0); gtk_text_buffer_get_iter_at_offset (buffer, &end, -1); @@ -798,9 +808,9 @@ cb_set_action_dialog_button_ok (GtkWidget *widget) gboolean has_commands; gboolean sensitive = FALSE; - action_name = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (gxml, "action-name"))); - regex_pattern = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (gxml, "regex"))); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (glade_xml_get_widget (gxml, "commands"))); + action_name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "action-name"))); + regex_pattern = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "regex"))); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "commands"))); has_commands = gtk_tree_model_get_iter_first (model, &iter); if (action_name[0] != '\0' && regex_pattern[0] != '\0' && has_commands) @@ -813,7 +823,7 @@ cb_set_action_dialog_button_ok (GtkWidget *widget) } } - gtk_widget_set_sensitive (glade_xml_get_widget (gxml, "action-dialog-button-ok"), sensitive); + gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog-button-ok")), sensitive); return; } @@ -869,4 +879,3 @@ main (gint argc, xfconf_shutdown (); return 0; } - -- 1.7.3.2