[Xfce4-commits] <xfce4-taskbar-plugin:master> 1) 'flatten buttons' is now customizable 2) Fixed enter-notify in group menu when mouse pressed 3) Added debugging messages with g_debug
Valentin Dudouyt
noreply at xfce.org
Sun Nov 18 03:36:01 CET 2012
Updating branch refs/heads/master
to 685a8fce39ee7ecf644267111876295c342eeed2 (commit)
from d7d880f979dd3b3bc4875a54a97d803f69cb3882 (commit)
commit 685a8fce39ee7ecf644267111876295c342eeed2
Author: Valentin Dudouyt <valentin.dudouyt at gmail.com>
Date: Sat Nov 17 22:50:01 2012 +0700
1) 'flatten buttons' is now customizable 2) Fixed enter-notify in group menu when mouse pressed 3) Added debugging messages with g_debug
taskbar-widget.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++------
taskbar.c | 2 +
2 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/taskbar-widget.c b/taskbar-widget.c
index 52b68ab..f5b6ce0 100644
--- a/taskbar-widget.c
+++ b/taskbar-widget.c
@@ -71,6 +71,7 @@ enum
PROP_SHOW_HANDLE,
PROP_SHOW_INSTANCES_HOVER,
PROP_DRAG_BUTTON,
+ PROP_FLAT_BUTTONS,
};
@@ -145,6 +146,7 @@ struct _XfceTaskBar
guint show_handle : 1;
guint show_instances_hover : 1;
guint drag_button; /* Middle */
+ guint flat_buttons : 1;
guint unique_id_counter ;
@@ -318,6 +320,7 @@ static void xfce_taskbar_class_init (XfceTaskBarClass *klass)
g_object_class_install_property (gobject_class, PROP_SHOW_HANDLE, g_param_spec_boolean ("show-handle", NULL, NULL, TRUE, EXO_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_SHOW_INSTANCES_HOVER, g_param_spec_boolean ("show-instances-on-hover", NULL, NULL, TRUE, EXO_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_DRAG_BUTTON, g_param_spec_int ("drag-button", NULL, NULL, -1, G_MAXINT, 0, EXO_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_FLAT_BUTTONS, g_param_spec_boolean ("flat-buttons", NULL, NULL, TRUE, EXO_PARAM_READWRITE));
gtk_widget_class_install_style_property (gtkwidget_class, g_param_spec_int ("max-button-length", NULL, "The maximum length of a window button", -1, G_MAXINT, DEFAULT_MAX_BUTTON_LENGTH, EXO_PARAM_READABLE));
gtk_widget_class_install_style_property (gtkwidget_class, g_param_spec_int ("min-button-length", NULL, "The minumum length of a window button", 1, G_MAXINT, DEFAULT_MIN_BUTTON_LENGTH, EXO_PARAM_READABLE));
@@ -352,6 +355,7 @@ static void xfce_taskbar_init (XfceTaskBar *taskbar)
taskbar->show_handle = TRUE;
taskbar->show_instances_hover = FALSE;
taskbar->drag_button = 1; /* Middle */
+ taskbar->flat_buttons = 0;
taskbar->all_monitors = TRUE;
taskbar->unique_id_counter = 0x0 ;
xfce_taskbar_geometry_set_invalid (taskbar);
@@ -412,6 +416,10 @@ static void xfce_taskbar_get_property (GObject *object, guint prop_id, GValue *v
g_value_set_int (value, taskbar->drag_button);
break;
+ case PROP_FLAT_BUTTONS:
+ g_value_set_boolean (value, taskbar->flat_buttons);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -421,6 +429,7 @@ static void xfce_taskbar_get_property (GObject *object, guint prop_id, GValue *v
static void xfce_taskbar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
XfceTaskBar *taskbar = XFCE_taskbar (object);
+ GList *gi ;
switch (prop_id)
{
@@ -454,6 +463,17 @@ static void xfce_taskbar_set_property (GObject *object, guint prop_id, const GVa
case PROP_DRAG_BUTTON:
taskbar->drag_button = g_value_get_int (value);
+ g_debug("drag_button=%d", taskbar->drag_button);
+ break;
+
+ case PROP_FLAT_BUTTONS:
+ taskbar->flat_buttons = g_value_get_boolean (value);
+ // Applying the changes immediately
+ for(gi=taskbar->wgroups; gi!=NULL; gi=gi->next)
+ {
+ XfceTaskBarGroup *group =gi->data ;
+ xfce_taskbar_group_update_visibility(group);
+ }
break;
default:
@@ -577,7 +597,7 @@ void xfce_taskbar_save_pinned_config (XfceTaskBar *taskbar)
static void xfce_taskbar_finalize (GObject *object)
{
- g_message("taskbar finalize");
+ g_debug("taskbar finalize");
XfceTaskBar *taskbar = XFCE_taskbar (object);
// data that should already be freed when disconnecting the screen
@@ -1565,6 +1585,7 @@ static void xfce_taskbar_button_geometry_changed (WnckWindow *window, XfceTaskBa
static gboolean xfce_taskbar_button_leave_notify_event (GtkWidget *button, GdkEventCrossing *event, XfceTaskBarWNode *child)
{
+ g_debug("leave_notify");
panel_return_val_if_fail (XFCE_IS_taskbar (child->taskbar), FALSE);
/* disconnect signals */
@@ -1604,6 +1625,7 @@ static gboolean xfce_taskbar_button_enter_notify_event (GtkWidget *button, GdkEv
static void wnck_action_menu_destroy(GtkWidget *wnck_widget, GtkWidget *menu_widget)
{
+ g_debug("wnck_action_menu_destroy");
gtk_widget_destroy(wnck_widget);
xfce_taskbar_group_button_menu_destroy(menu_widget, NULL);
}
@@ -1612,6 +1634,7 @@ static void wnck_action_menu_destroy(GtkWidget *wnck_widget, GtkWidget *menu_wid
//Returning FALSE will close the menu that generated the event, return TRUE will persist it
static gboolean xfce_taskbar_app_button_release_event (GtkWidget *button, GdkEventButton *event, XfceTaskBarWNode *child)
{
+ g_debug("xfce_taskbar_app_button_release_event");
panel_return_val_if_fail (XFCE_IS_taskbar (child->taskbar), FALSE);
/* only respond to in-button events */
@@ -2266,12 +2289,15 @@ static GtkWidget * xfce_taskbar_group_button_menu_group_actions (XfceTaskBarGrou
static void xfce_taskbar_group_button_menu_destroy(GtkWidget *menu_widget, XfceTaskBarGroup *group)
{
+ g_debug("xfce_taskbar_group_button_menu_destroy");
xfce_taskbar_disable_hover_menu_timeout(menu_widget);
gtk_widget_destroy (menu_widget);
#ifdef GDK_WINDOWING_X11
// Removes the wireframe associated with the currently selected window
if(group) xfce_taskbar_wireframe_hide (group->taskbar);
#endif
+ // The group button doesn't need to be activated anymore
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->button), FALSE);
}
@@ -2304,9 +2330,26 @@ static gboolean xfce_taskbar_group_button_press_event
XfceTaskBarWNode *active_child;
int visible_count;
get_active_child(group, &active_child, &visible_count);
- if(group->taskbar->drag_button == 1 && visible_count > 1) {
- GtkWidget *menu_widget = xfce_taskbar_group_button_menu_show_active (group);
- xfce_taskbar_activate_hover_menu(menu_widget, group, event->button);
+ g_debug("event_button=%d drag_button=%d", event->button, group->taskbar->drag_button);
+ if(group->taskbar->drag_button == 1
+ && event->button == LEFTMOUSE
+ && visible_count > 1) {
+ // Activating menu with gtk_widget_show is not so good here as
+ // it may prevent notify-event from being received.
+ // Considering the situation:
+ // 1) User configured drag_button to Middle in his settings
+ // 2) The user clicks the button and tries to select the menu item
+ // with left button holded
+ GtkWidget *menu = xfce_taskbar_group_button_menu_show_active (group);
+ g_signal_connect (G_OBJECT (menu), "selection-done", G_CALLBACK (xfce_taskbar_group_button_menu_destroy), group);
+
+ gtk_menu_attach_to_widget (GTK_MENU (menu), button, NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ xfce_panel_plugin_position_menu,
+ xfce_taskbar_get_panel_plugin (group->taskbar),
+ event->button,
+ event->time);
+ xfce_taskbar_disable_hover_menu_timeout(menu);
return TRUE;
}
return FALSE ;
@@ -2317,7 +2360,7 @@ static gboolean xfce_taskbar_group_button_press_event
static gboolean xfce_taskbar_group_button_release_event
(GtkWidget *button, GdkEventButton *event, XfceTaskBarGroup *group)
{
- g_message("xfce_taskbar_group_button_release_event");
+ g_debug("xfce_taskbar_group_button_release_event");
GtkWidget *panel_plugin;
GtkWidget *menu_widget;
@@ -2412,7 +2455,7 @@ static gboolean xfce_taskbar_group_button_release_event
}
}
- if(group->taskbar->drag_button == 0)
+ if(event->button == RIGHTMOUSE)
xfce_taskbar_activate_hover_menu(menu_widget, group, event->button);
return TRUE;
@@ -2424,6 +2467,7 @@ static gboolean xfce_taskbar_group_button_release_event
//This callback gets triggered if the mouse has left the group icon but has not entered the hover menu
static gboolean xfce_taskbar_hover_menu_timeout(gpointer menu_ptr)
{
+ g_debug("xfce_taskbar_hover_menu_timeout");
GtkWidget *menu_widget = (GtkWidget *)menu_ptr;
gtk_widget_destroy (menu_widget);
return FALSE ;
@@ -2452,6 +2496,7 @@ static gboolean xfce_taskbar_hover_menu_enter(GtkWidget *widget, GdkEvent *even
//Triggered when mouse focus leaves the hover menu
static gboolean xfce_taskbar_hover_menu_leave(GtkWidget *widget, GdkEvent *event, gpointer menu_ptr)
{
+ g_debug("xfce_taskbar_hover_menu_leave");
GtkWidget *menu_widget = (GtkWidget *)menu_ptr;
//We don't want to kill the hover menu immediately, so we wait a small time
size_t timeout_id = (size_t)g_timeout_add(300, xfce_taskbar_hover_menu_timeout, menu_widget);
@@ -2581,7 +2626,10 @@ static void xfce_taskbar_group_update_visibility(XfceTaskBarGroup *group)
}
else
{
- gtk_button_set_relief (GTK_BUTTON (group->button), GTK_RELIEF_NORMAL);
+ gtk_button_set_relief (GTK_BUTTON (group->button),
+ group->taskbar->flat_buttons
+ ? GTK_RELIEF_NONE
+ : GTK_RELIEF_NORMAL);
gtk_widget_show(group->button);
}
diff --git a/taskbar.c b/taskbar.c
index aec7804..d40478f 100644
--- a/taskbar.c
+++ b/taskbar.c
@@ -103,6 +103,7 @@ static void taskbar_plugin_construct (XfcePanelPlugin *panel_plugin)
{ "show-handle", G_TYPE_BOOLEAN },
{ "show-instances-on-hover", G_TYPE_BOOLEAN },
{ "drag-button", G_TYPE_INT },
+ { "flat-buttons", G_TYPE_BOOLEAN },
{ NULL }
};
@@ -181,6 +182,7 @@ static void taskbar_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
TASKBAR_DIALOG_BIND ("show-handle", "active")
TASKBAR_DIALOG_BIND ("show-instances-on-hover", "active")
TASKBAR_DIALOG_BIND ("drag-button", "active")
+ TASKBAR_DIALOG_BIND ("flat-buttons", "active")
#ifndef GDK_WINDOWING_X11
/* not functional in x11, so avoid confusion */
More information about the Xfce4-commits
mailing list