This is an automated email from the git hooks/post-receive script. n i n e t l s p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository panel-plugins/xfce4-statusnotifier-plugin.
commit 38494dbcd532aa62efa8a58fa8d3d09667e674d4 Author: Viktor Odintsev <nine...@xfce.org> Date: Fri Jul 14 11:02:13 2017 +0300 Allow to make menu primary action --- panel-plugin/sn-button.c | 23 ++++++++++++--- panel-plugin/sn-config.c | 37 +++++++++++++++++++++++ panel-plugin/sn-config.h | 2 ++ panel-plugin/sn-dialog.c | 6 ++++ panel-plugin/sn-dialog.glade | 70 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 127 insertions(+), 11 deletions(-) diff --git a/panel-plugin/sn-button.c b/panel-plugin/sn-button.c index 513bdfb..779c2d0 100644 --- a/panel-plugin/sn-button.c +++ b/panel-plugin/sn-button.c @@ -64,6 +64,8 @@ struct _SnButton GtkButton __parent__; SnItem *item; + SnConfig *config; + GtkMenuPositionFunc pos_func; gpointer pos_func_data; @@ -120,6 +122,8 @@ sn_button_init (SnButton *button) gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK); button->item = NULL; + button->config = NULL; + button->pos_func = NULL; button->pos_func_data = NULL; @@ -171,6 +175,8 @@ sn_button_new (SnItem *item, g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), NULL); button->item = item; + button->config = config; + button->pos_func = pos_func; button->pos_func_data = pos_func_data; @@ -235,14 +241,17 @@ sn_button_button_press (GtkWidget *widget, GdkEventButton *event) { SnButton *button = XFCE_SN_BUTTON (widget); + gboolean menu_is_primary; + + menu_is_primary = sn_config_get_menu_is_primary (button->config); - if (event->button == 3 && button->menu_only) + if (event->button == 3 && (button->menu_only || menu_is_primary)) { /* menu is available by left click, so show the panel menu instead */ return FALSE; } - if ((event->button == 1 && button->menu_only) || event->button == 3) + if ((event->button == 1 && (button->menu_only || menu_is_primary)) || event->button == 3) { if (button->menu != NULL) { @@ -283,16 +292,22 @@ sn_button_button_release (GtkWidget *widget, GdkEventButton *event) { SnButton *button = XFCE_SN_BUTTON (widget); + gboolean menu_is_primary; + + menu_is_primary = sn_config_get_menu_is_primary (button->config); if (event->button == 1) { /* menu could be handled in button-press-event, check this */ - if (button->menu == NULL || !button->menu_only) + if (button->menu == NULL || !(button->menu_only || menu_is_primary)) sn_item_activate (button->item, (gint) event->x_root, (gint) event->y_root); } else if (event->button == 2) { - sn_item_secondary_activate (button->item, (gint) event->x_root, (gint) event->y_root); + if (menu_is_primary && !button->menu_only) + sn_item_activate (button->item, (gint) event->x_root, (gint) event->y_root); + else + sn_item_secondary_activate (button->item, (gint) event->x_root, (gint) event->y_root); } /* process animations */ diff --git a/panel-plugin/sn-config.c b/panel-plugin/sn-config.c index b83a51d..80a56d5 100644 --- a/panel-plugin/sn-config.c +++ b/panel-plugin/sn-config.c @@ -42,6 +42,7 @@ #define DEFAULT_ICON_SIZE 22 #define DEFAULT_SINGLE_ROW FALSE #define DEFAULT_SQUARE_ICONS FALSE +#define DEFAULT_MENU_IS_PRIMARY FALSE #define DEFAULT_ORIENTATION GTK_ORIENTATION_HORIZONTAL #define DEFAULT_PANEL_ORIENTATION GTK_ORIENTATION_HORIZONTAL #define DEFAULT_PANEL_SIZE 28 @@ -75,6 +76,7 @@ struct _SnConfig gint icon_size; gboolean single_row; gboolean square_icons; + gboolean menu_is_primary; gboolean mode_whitelist; GList *known_items; GHashTable *hidden_items; @@ -96,6 +98,7 @@ enum PROP_ICON_SIZE, PROP_SINGLE_ROW, PROP_SQUARE_ICONS, + PROP_MENU_IS_PRIMARY, PROP_MODE_WHITELIST, PROP_KNOWN_ITEMS, PROP_HIDDEN_ITEMS @@ -171,6 +174,13 @@ sn_config_class_init (SnConfigClass *klass) G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, + PROP_MENU_IS_PRIMARY, + g_param_spec_boolean ("menu-is-primary", NULL, NULL, + DEFAULT_MENU_IS_PRIMARY, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (object_class, PROP_MODE_WHITELIST, g_param_spec_boolean ("mode-whitelist", NULL, NULL, DEFAULT_MODE_WHITELIST, @@ -304,6 +314,10 @@ sn_config_get_property (GObject *object, g_value_set_boolean (value, config->square_icons); break; + case PROP_MENU_IS_PRIMARY: + g_value_set_boolean (value, config->menu_is_primary); + break; + case PROP_MODE_WHITELIST: g_value_set_boolean (value, config->mode_whitelist); break; @@ -378,6 +392,15 @@ sn_config_set_property (GObject *object, } break; + case PROP_MENU_IS_PRIMARY: + val = g_value_get_boolean (value); + if (config->menu_is_primary != val) + { + config->menu_is_primary = val; + g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0); + } + break; + case PROP_MODE_WHITELIST: val = g_value_get_boolean (value); if (config->mode_whitelist != val) @@ -458,6 +481,16 @@ sn_config_get_square_icons (SnConfig *config) +gboolean +sn_config_get_menu_is_primary (SnConfig *config) +{ + g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_MENU_IS_PRIMARY); + + return config->menu_is_primary; +} + + + void sn_config_set_orientation (SnConfig *config, GtkOrientation panel_orientation, @@ -746,6 +779,10 @@ sn_config_new (const gchar *property_base) xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "square-icons"); g_free (property); + property = g_strconcat (property_base, "/menu-is-primary", NULL); + xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "menu-is-primary"); + g_free (property); + property = g_strconcat (property_base, "/mode-whitelist", NULL); xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "mode-whitelist"); g_free (property); diff --git a/panel-plugin/sn-config.h b/panel-plugin/sn-config.h index 30576b0..7506cc8 100644 --- a/panel-plugin/sn-config.h +++ b/panel-plugin/sn-config.h @@ -58,6 +58,8 @@ gboolean sn_config_get_single_row (SnConfig gboolean sn_config_get_square_icons (SnConfig *config); +gboolean sn_config_get_menu_is_primary (SnConfig *config); + gint sn_config_get_icon_size (SnConfig *config); gboolean sn_config_is_hidden (SnConfig *config, diff --git a/panel-plugin/sn-dialog.c b/panel-plugin/sn-dialog.c index 20dad32..2c3ca7f 100644 --- a/panel-plugin/sn-dialog.c +++ b/panel-plugin/sn-dialog.c @@ -433,6 +433,12 @@ sn_dialog_build (SnDialog *dialog) G_OBJECT (object), "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + object = gtk_builder_get_object (dialog->builder, "checkbutton-menu-is-primary"); + g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE); + g_object_bind_property (G_OBJECT (dialog->config), "menu-is-primary", + G_OBJECT (object), "active", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + object = gtk_builder_get_object (dialog->builder, "checkbutton-whitelist"); g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE); g_object_bind_property (G_OBJECT (dialog->config), "mode-whitelist", diff --git a/panel-plugin/sn-dialog.glade b/panel-plugin/sn-dialog.glade index 6282799..077b09f 100644 --- a/panel-plugin/sn-dialog.glade +++ b/panel-plugin/sn-dialog.glade @@ -7,7 +7,7 @@ <property name="can_focus">False</property> <property name="title" translatable="yes">Status Notifier Items</property> <property name="default_width">425</property> - <property name="default_height">525</property> + <property name="default_height">575</property> <property name="icon_name">gtk-properties</property> <property name="type_hint">normal</property> <child internal-child="vbox"> @@ -53,13 +53,13 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkFrame" id="frame3"> + <object class="GtkFrame" id="frame2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <object class="GtkAlignment" id="alignment3"> + <object class="GtkAlignment" id="alignment2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="left_padding">12</property> @@ -163,6 +163,62 @@ <property name="position">0</property> </packing> </child> + + <child> + <object class="GtkFrame" id="frame3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <child> + <object class="GtkBox" id="vbox3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkCheckButton" id="checkbutton-menu-is-primary"> + <property name="label" translatable="yes">Menu is primary action</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Left click will always display the menu for item.</property> + <property name="use_action_appearance">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Behavior</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkFrame" id="frame1"> <property name="visible">True</property> @@ -175,7 +231,7 @@ <property name="can_focus">False</property> <property name="left_padding">12</property> <child> - <object class="GtkBox" id="vbox3"> + <object class="GtkBox" id="vbox4"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -262,7 +318,7 @@ </packing> </child> <child> - <object class="GtkBox" id="vbox4"> + <object class="GtkBox" id="vbox5"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> @@ -358,7 +414,7 @@ </object> </child> <child type="label"> - <object class="GtkLabel" id="label3"> + <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">Known Items</property> @@ -371,7 +427,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits