[Xfce4-commits] <xfce4-taskbar-plugin:master> Comment tweaks.
Gearoid Murphy
noreply at xfce.org
Tue Oct 9 15:02:05 CEST 2012
Updating branch refs/heads/master
to 654baa449c4af3243c7c54ccc158404e69917ecb (commit)
from 6a95ca9192dab043e60407017ec49103ad6c331f (commit)
commit 654baa449c4af3243c7c54ccc158404e69917ecb
Author: Gearoid Murphy <gearoid.murphy at hp.com>
Date: Tue Oct 9 11:51:20 2012 +0100
Comment tweaks.
taskbar-widget.c | 145 +++++++++++++++++++++++++-----------------------------
1 files changed, 67 insertions(+), 78 deletions(-)
diff --git a/taskbar-widget.c b/taskbar-widget.c
index 2dfcac3..bc79951 100644
--- a/taskbar-widget.c
+++ b/taskbar-widget.c
@@ -141,11 +141,11 @@ struct _XfceTaskBar
HotkeysHandler *hotkeys_handler;
#ifdef GDK_WINDOWING_X11
- /* wireframe window */
+ // wireframe window
Window wireframe_window;
#endif
- /* gtk style properties */
+ // gtk style properties
gint max_button_length;
gint min_button_length;
gint max_button_size;
@@ -188,18 +188,10 @@ struct _XfceTaskBarGroup
gboolean pinned ;
gchar *command ;
guint popup_timeout ;
- gulong enter_signal ;
- gulong leave_signal ;
};
#define DISABLE_HOVER_TIMEOUT(group) if(group->popup_timeout != 0) {g_source_remove(group->popup_timeout); group->popup_timeout=0;}
-#define ENABLE_ENTER_SIGNAL(group) { group->enter_signal = g_signal_connect(G_OBJECT(group->button), "enter-notify-event", G_CALLBACK(xfce_taskbar_group_button_enter_event), group); }
-#define DISABLE_ENTER_SIGNAL(group) if(group->enter_signal != 0) {g_signal_handler_disconnect(G_OBJECT(group->button), group->enter_signal); group->enter_signal=0;}
-
-#define ENABLE_EXIT_SIGNAL(group) { group->leave_signal = g_signal_connect(G_OBJECT(group->button),"leave-notify-event", G_CALLBACK(xfce_taskbar_group_button_leave_event), group); }
-#define DISABLE_EXIT_SIGNAL(group) if(group->leave_signal != 0) {g_signal_handler_disconnect(G_OBJECT(group->button), group->leave_signal); group->leave_signal=0;}
-
static const GtkTargetEntry source_targets[] =
{
{ "application/x-wnck-window-id", 0, 0 }
@@ -229,21 +221,21 @@ static gboolean xfce_taskbar_update_icon_geometries (gpointer data);
static void xfce_taskbar_skipped_windows_state_changed (WnckWindow *window, WnckWindowState changed_state, WnckWindowState new_state, XfceTaskBar *taskbar);
static void xfce_taskbar_update_icon_geometries_destroyed (gpointer data);
-/* wireframe */
+// wireframe
#ifdef GDK_WINDOWING_X11
static void xfce_taskbar_wireframe_hide (XfceTaskBar *taskbar);
static void xfce_taskbar_wireframe_destroy (XfceTaskBar *taskbar);
static void xfce_taskbar_wireframe_update (XfceTaskBar *taskbar, XfceTaskBarWNode *child);
#endif
-/* taskbar buttons */
+// taskbar buttons
static inline gboolean xfce_taskbar_button_visible (XfceTaskBarWNode *child, WnckWorkspace *active_ws);
static GtkWidget* xfce_taskbar_button_proxy_menu_item (XfceTaskBarWNode *child, gboolean allow_wireframe);
static void xfce_taskbar_button_activate (XfceTaskBarWNode *child, guint32 timestamp);
static XfceTaskBarWNode* xfce_taskbar_wnode_new (WnckWindow *window, XfceTaskBar *taskbar);
static void xfce_taskbar_wnode_del (XfceTaskBarWNode *wnode);
-/* taskbar group buttons */
+// taskbar group buttons
static int xfce_taskbar_group_visible_count (XfceTaskBarGroup *group, WnckWorkspace *active_ws);
static void xfce_taskbar_group_update_visibility (XfceTaskBarGroup *group);
static void xfce_taskbar_group_button_remove (XfceTaskBarGroup *group);
@@ -254,14 +246,14 @@ static gboolean xfce_taskbar_group_button_leave_event (GtkWidget *butt
static XfceTaskBarGroup*
xfce_taskbar_group_button_new (const char *, XfceTaskBar *taskbar);
-/* pinning functions */
+// pinning functions
static void xfce_taskbar_group_button_toggle_pinned (XfceTaskBarGroup *group);
static void xfce_taskbar_group_button_launch_pinned (XfceTaskBarGroup *group);
static void xfce_taskbar_group_button_build_launch_menu (XfceTaskBarGroup *group, GtkWidget *menu, gboolean use_sep);
static void xfce_taskbar_group_button_build_pin_menu (XfceTaskBarGroup *group, GtkWidget *menu);
static void cache_pinned_configuration (XfceTaskBar *taskbar);
-/* potential public functions */
+// potential public functions
static void xfce_taskbar_set_include_all_workspaces (XfceTaskBar *taskbar, gboolean all_workspaces);
static void xfce_taskbar_set_include_all_monitors (XfceTaskBar *taskbar, gboolean all_monitors);
static void xfce_taskbar_set_show_only_minimized (XfceTaskBar *taskbar, gboolean only_minimized);
@@ -452,7 +444,8 @@ void xfce_taskbar_load_pinned_config (XfceTaskBar *taskbar)
char *group_name = groups[group_index] ;
const char *command_string ;
- printf("Found group: %s\n", group_name);
+ //printf("Found group: %s\n", group_name);
+
xfce_rc_set_group (rc, group_name);
XfceTaskBarGroup *group = xfce_taskbar_group_button_new (group_name, taskbar);
@@ -474,7 +467,7 @@ void xfce_taskbar_load_pinned_config (XfceTaskBar *taskbar)
return ;
}
group->command = g_strdup(command_string);
- printf("Load the pinned command: '%s'\n", group->command);
+ //printf("Load the pinned command: '%s'\n", group->command);
group->pinned = TRUE ;
//add in the icon and add it to the list of groups
@@ -497,7 +490,8 @@ void xfce_taskbar_save_pinned_config (XfceTaskBar *taskbar)
GList *gi ;
XfceRc *rc;
- printf("xfce_taskbar_save_pinned_config\n");
+ //printf("xfce_taskbar_save_pinned_config\n");
+
sprintf(rc_path, "%s/.config/xfce4/panel/taskbar", getenv("HOME"));
if(!xfce_mkdirhier(rc_path, 0700, NULL))
{
@@ -527,7 +521,7 @@ void xfce_taskbar_save_pinned_config (XfceTaskBar *taskbar)
xfce_rc_set_group (rc, group->window_class_name);
xfce_rc_write_entry (rc, "command", group->command);
- /* Now save the icon in the cache */
+ // Now save the icon in the cache
{
char png_path [512] ;
sprintf(png_path, "%s/.config/xfce4/panel/taskbar/%s.png", getenv("HOME"), group->window_class_name);
@@ -538,7 +532,7 @@ void xfce_taskbar_save_pinned_config (XfceTaskBar *taskbar)
}
}
}
- printf("closing configuration after successful save\n");
+ //printf("closing configuration after successful save\n");
xfce_rc_close (rc);
}
@@ -547,12 +541,12 @@ static void xfce_taskbar_finalize (GObject *object)
g_message("taskbar finalize");
XfceTaskBar *taskbar = XFCE_taskbar (object);
- /* data that should already be freed when disconnecting the screen */
+ // data that should already be freed when disconnecting the screen
panel_return_if_fail (taskbar->wgroups == NULL);
panel_return_if_fail (taskbar->skipped_windows == NULL);
panel_return_if_fail (taskbar->screen == NULL);
- /* stop pending timeouts */
+ // stop pending timeouts
if (taskbar->update_icon_geometries_id != 0)
{
g_source_remove (taskbar->update_icon_geometries_id);
@@ -562,15 +556,15 @@ static void xfce_taskbar_finalize (GObject *object)
g_source_remove (taskbar->update_monitor_geometry_id);
}
- /* free the class group hash table */
+ // free the class group hash table
g_hash_table_destroy (taskbar->groups);
#ifdef GDK_WINDOWING_X11
- /* destroy the wireframe window */
+ // destroy the wireframe window
xfce_taskbar_wireframe_destroy (taskbar);
#endif
if(taskbar->hotkeys_handler)
- finish_global_hotkeys(taskbar->hotkeys_handler);
+ finish_global_hotkeys(taskbar->hotkeys_handler);
(*G_OBJECT_CLASS (xfce_taskbar_parent_class)->finalize) (object);
}
@@ -636,13 +630,13 @@ static void xfce_taskbar_size_request (GtkWidget *widget, GtkRequisition *requis
}
}
-static void xfce_taskbar_size_layout (XfceTaskBar *taskbar, GtkAllocation *alloc, gint *n_rows, gint *n_cols)
+static void xfce_taskbar_size_layout (XfceTaskBar *taskbar, GtkAllocation *alloc, gint *n_rows, gint *n_cols)
{
gint rows;
gint min_button_length;
gint cols;
- /* if we're in the opposite vertical mode, there are no columns */
+ // if we're in the opposite vertical mode, there are no columns
if (taskbar->horizontal != xfce_taskbar_horizontal (taskbar))
rows = taskbar->n_group_icons;
else
@@ -657,12 +651,12 @@ static void xfce_taskbar_size_layout (XfceTaskBar *taskbar, GtkAllocation *al
min_button_length = alloc->height / rows;
- /* jam all the icons in, lets see what happens */
+ // jam all the icons in, lets see what happens
*n_rows = rows;
*n_cols = cols;
}
-static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
XfceTaskBar *taskbar = XFCE_taskbar (widget);
gint rows, cols;
@@ -677,23 +671,22 @@ static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *all
gint area_x, area_width;
GtkRequisition child_req;
- /* set widget allocation */
+ //set widget allocation
widget->allocation = *allocation;
- /* swap integers with vertical orientation */
+ // swap integers with vertical orientation
if (!xfce_taskbar_horizontal (taskbar))
TRANSPOSE_AREA (area);
- /*panel_return_if_fail (area.height == taskbar->size);*/
- /* TODO if we compare the allocation with the requisition we can
- * do a fast path to the child allocation, i think */
+ // TODO if we compare the allocation with the requisition we can
+ // do a fast path to the child allocation, i think
- /* useless but hides compiler warning */
+ // useless but hides compiler warning
w = h = x = y = rows = cols = 0;
xfce_taskbar_size_layout (taskbar, &area, &rows, &cols);
- /* allocate the arrow button for the overflow menu */
+ // allocate the arrow button for the overflow menu
child_alloc.width = area.height;
child_alloc.height = area.height;
@@ -702,12 +695,12 @@ static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *all
area_x = area.x;
area_width = area.width;
- /* allocate all the children */
+ // allocate all the children
for (li = taskbar->wgroups, i = 0; li != NULL; li = li->next)
{
group = li->data;
- /* skip hidden buttons */
+ // skip hidden buttons
if (!GTK_WIDGET_VISIBLE (group->button))
continue;
@@ -727,7 +720,7 @@ static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *all
child_alloc.y = y;
child_alloc.x = x;
- child_alloc.width = MAX (w, 1); /* TODO this is a workaround */
+ child_alloc.width = MAX (w, 1); // TODO this is a workaround
child_alloc.height = h / (rows - row);
if (!taskbar->horizontal && xfce_taskbar_horizontal (taskbar))
@@ -742,17 +735,17 @@ static void xfce_taskbar_size_allocate (GtkWidget *widget, GtkAllocation *all
if (direction_rtl)
child_alloc.x = area.x + area.width - (child_alloc.x - area.x) - child_alloc.width;
- /* allocate the group */
+ // allocate the group
if (!xfce_taskbar_horizontal (taskbar))
TRANSPOSE_AREA (child_alloc);
- /* increase the position counter */
+ // increase the position counter
i++;
gtk_widget_size_allocate (group->button, &child_alloc);
}
- /* update icon geometries */
+ // update icon geometries
if (taskbar->update_icon_geometries_id == 0)
{
taskbar->update_icon_geometries_id = g_idle_add_full(G_PRIORITY_LOW, xfce_taskbar_update_icon_geometries,
@@ -768,10 +761,10 @@ static void xfce_taskbar_style_set (GtkWidget *widget, GtkStyle *previous_sty
gint min_button_length;
gint w, h;
- /* let gtk update the widget style */
+ // let gtk update the widget style
(*GTK_WIDGET_CLASS (xfce_taskbar_parent_class)->style_set) (widget, previous_style);
- /* read the style properties */
+ // read the style properties
gtk_widget_style_get (GTK_WIDGET (taskbar),
"max-button-length", &max_button_length,
"min-button-length", &min_button_length,
@@ -784,14 +777,14 @@ static void xfce_taskbar_style_set (GtkWidget *widget, GtkStyle *previous_sty
if (gtk_icon_size_lookup (menu_icon_size, &w, &h))
taskbar->menu_icon_size = MIN (w, h);
- /* update the widget */
+ // update the widget
if (taskbar->max_button_length != max_button_length
|| taskbar->max_button_size != max_button_size
|| taskbar->min_button_length != min_button_length)
{
if (max_button_length > 0)
{
- /* prevent abuse of the min/max button length */
+ // prevent abuse of the min/max button length
taskbar->max_button_length = MAX (min_button_length, max_button_length);
taskbar->min_button_length = MIN (min_button_length, max_button_length);
}
@@ -811,19 +804,17 @@ static void xfce_taskbar_realize (GtkWidget *widget)
{
XfceTaskBar *taskbar = XFCE_taskbar (widget);
(*GTK_WIDGET_CLASS (xfce_taskbar_parent_class)->realize) (widget);
- /* we now have a screen */
xfce_taskbar_connect_screen (taskbar);
}
static void xfce_taskbar_unrealize (GtkWidget *widget)
{
XfceTaskBar *taskbar = XFCE_taskbar (widget);
- /* we're going to loose the screen */
xfce_taskbar_disconnect_screen (taskbar);
(*GTK_WIDGET_CLASS (xfce_taskbar_parent_class)->unrealize) (widget);
}
-/*we handle the memory frees elsewhere.. */
+// we handle the memory frees elsewhere..
static void xfce_taskbar_remove (GtkContainer *container, GtkWidget *widget)
{
XfceTaskBar *taskbar = XFCE_taskbar (container);
@@ -857,35 +848,35 @@ static void xfce_taskbar_connect_screen (XfceTaskBar *taskbar)
panel_return_if_fail (taskbar->screen == NULL);
panel_return_if_fail (taskbar->gdk_screen == NULL);
- /* set the new screen */
+ // set the new screen
taskbar->gdk_screen = gtk_widget_get_screen (GTK_WIDGET (taskbar));
taskbar->screen = wnck_screen_get (gdk_screen_get_number (taskbar->gdk_screen));
- /* initialize global hotkeys */
+ // initialize global hotkeys
taskbar->hotkeys_handler = init_global_hotkeys(taskbar);
- /* add all existing windows on this screen */
+ // add all existing windows on this screen
windows = wnck_screen_get_windows (taskbar->screen);
for (li = windows; li != NULL; li = li->next)
{
xfce_taskbar_window_added (taskbar->screen, li->data, taskbar);
}
- /* load the pinned items */
+ // load the pinned items
xfce_taskbar_load_pinned_config (taskbar);
- /* monitor gdk changes */
+ // monitor gdk changes
g_signal_connect (G_OBJECT (taskbar->gdk_screen), "monitors-changed", G_CALLBACK (xfce_taskbar_gdk_screen_changed), taskbar);
g_signal_connect (G_OBJECT (taskbar->gdk_screen), "size-changed", G_CALLBACK (xfce_taskbar_gdk_screen_changed), taskbar);
- /* monitor screen changes */
+ // monitor screen changes
g_signal_connect (G_OBJECT (taskbar->screen), "active-window-changed", G_CALLBACK (xfce_taskbar_active_window_changed), taskbar);
g_signal_connect (G_OBJECT (taskbar->screen), "active-workspace-changed", G_CALLBACK (xfce_taskbar_active_workspace_changed), taskbar);
g_signal_connect (G_OBJECT (taskbar->screen), "window-opened", G_CALLBACK (xfce_taskbar_window_added), taskbar);
g_signal_connect (G_OBJECT (taskbar->screen), "window-closed", G_CALLBACK (xfce_taskbar_window_removed), taskbar);
g_signal_connect (G_OBJECT (taskbar->screen), "viewports-changed", G_CALLBACK (xfce_taskbar_viewports_changed), taskbar);
- /* update the viewport if not all monitors are shown */
+ // update the viewport if not all monitors are shown
xfce_taskbar_gdk_screen_changed (taskbar->gdk_screen, taskbar);
}
@@ -900,17 +891,17 @@ static void xfce_taskbar_disconnect_screen (XfceTaskBar *taskbar)
panel_return_if_fail (WNCK_IS_SCREEN (taskbar->screen));
panel_return_if_fail (GDK_IS_SCREEN (taskbar->gdk_screen));
- /* disconnect monitor signals */
+ // disconnect monitor signals
n = g_signal_handlers_disconnect_matched (G_OBJECT (taskbar->screen), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, taskbar);
panel_return_if_fail (n == 5);
- /* disconnect geometry changed signals */
+ // disconnect geometry changed signals
g_signal_handlers_disconnect_by_func (G_OBJECT (taskbar->gdk_screen), G_CALLBACK (xfce_taskbar_gdk_screen_changed), taskbar);
- /* delete all known class groups (and their buttons) */
+ // delete all known class groups (and their buttons)
g_hash_table_remove_all (taskbar->groups);
- /* disconnect from all skipped windows */
+ // disconnect from all skipped windows
for (li = taskbar->skipped_windows; li != NULL; li = lnext)
{
lnext = li->next;
@@ -940,7 +931,7 @@ static void xfce_taskbar_gdk_screen_changed (GdkScreen *gdk_screen, XfceTaskBar
if (!taskbar->all_monitors)
{
- /* update the monitor geometry */
+ // update the monitor geometry
xfce_taskbar_update_monitor_geometry (taskbar);
}
}
@@ -956,10 +947,10 @@ static void xfce_taskbar_active_window_changed (WnckScreen *screen, WnckWindow *
panel_return_if_fail (XFCE_IS_taskbar (taskbar));
panel_return_if_fail (taskbar->screen == screen);
- /* get the new active window */
+ // get the new active window
active_window = wnck_screen_get_active_window (screen);
- /* lock the taskbar */
+ // lock the taskbar
xfce_taskbar_lock (taskbar);
for (li = taskbar->wgroups; li != NULL; li = li->next)
@@ -982,7 +973,7 @@ static void xfce_taskbar_active_window_changed (WnckScreen *screen, WnckWindow *
}
}
- /* release the lock */
+ // release the lock
xfce_taskbar_unlock (taskbar);
}
@@ -996,13 +987,13 @@ static void xfce_taskbar_active_workspace_changed (WnckScreen *screen, WnckWorks
panel_return_if_fail (XFCE_IS_taskbar (taskbar));
panel_return_if_fail (taskbar->screen == screen);
- /* leave when we are locked or show all workspaces. the null
- * check for @previous_workspace is used to update the taskbar
- * on setting changes */
+ // leave when we are locked or show all workspaces. the null
+ // check for @previous_workspace is used to update the taskbar
+ // on setting changes
if (xfce_taskbar_is_locked (taskbar) || (previous_workspace != NULL && taskbar->all_workspaces))
return;
- /* walk all the group buttons and check their visibility */
+ // walk all the group buttons and check their visibility
active_ws = wnck_screen_get_active_workspace (screen);
for (gi = taskbar->wgroups; gi != NULL; gi = gi->next)
{
@@ -1029,7 +1020,7 @@ static void xfce_taskbar_window_added (WnckScreen *screen, WnckWindow *window, X
panel_return_if_fail (wnck_window_get_screen (window) == screen);
panel_return_if_fail (wnck_window_get_application(window) != NULL);
- /* ignore this window, but watch it for state changes */
+ // ignore this window, but watch it for state changes
if (wnck_window_is_skip_tasklist (window))
{
taskbar->skipped_windows = g_slist_prepend (taskbar->skipped_windows, window);
@@ -1037,14 +1028,14 @@ static void xfce_taskbar_window_added (WnckScreen *screen, WnckWindow *window, X
return;
}
- /* create new window button */
+ // create new window button
wnode = xfce_taskbar_wnode_new (window, taskbar);
g_hash_table_lookup_extended (taskbar->groups, wnode->group_name, NULL, (gpointer *) &group);
if (group == NULL)
{
- /* create group button for this window and add it */
+ // create group button for this window and add it
group = xfce_taskbar_group_button_new (wnode->group_name, taskbar);
group->pixbuf = wnck_window_get_icon (window);
@@ -1056,7 +1047,7 @@ static void xfce_taskbar_window_added (WnckScreen *screen, WnckWindow *window, X
wnode->group = group ;
- /* add window to the group button */
+ // add window to the group button
xfce_taskbar_group_button_add_window (group, wnode);
gtk_widget_queue_resize (GTK_WIDGET (taskbar));
@@ -1074,7 +1065,7 @@ static void xfce_taskbar_window_removed (WnckScreen *screen, WnckWindow *window,
panel_return_if_fail (XFCE_IS_taskbar (taskbar));
panel_return_if_fail (taskbar->screen == screen);
- /* check if the window is in our skipped window list */
+ // check if the window is in our skipped window list
if (wnck_window_is_skip_tasklist (window) && (lp = g_slist_find (taskbar->skipped_windows, window)) != NULL)
{
taskbar->skipped_windows = g_slist_delete_link (taskbar->skipped_windows, lp);
@@ -2593,9 +2584,6 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
//The timeout id, used when tracking a mouse hovering over the button
group->popup_timeout = 0 ;
- //Signals ids for quickly enabling and disabling mouse hover events
- group->enter_signal = 0 ;
- group->leave_signal = 0 ;
group->button = xfce_arrow_button_new (GTK_ARROW_NONE);
gtk_widget_set_parent (group->button, GTK_WIDGET (taskbar));
@@ -2606,8 +2594,9 @@ static XfceTaskBarGroup * xfce_taskbar_group_button_new (const char *group_name,
gtk_container_add (GTK_CONTAINER (group->button), group->align);
g_signal_connect (G_OBJECT (group->button), "button-release-event", G_CALLBACK (xfce_taskbar_group_button_release_event), group);
- ENABLE_ENTER_SIGNAL(group);
- ENABLE_EXIT_SIGNAL(group);
+
+ g_signal_connect(G_OBJECT(group->button), "enter-notify-event", G_CALLBACK(xfce_taskbar_group_button_enter_event), group);
+ g_signal_connect(G_OBJECT(group->button),"leave-notify-event", G_CALLBACK(xfce_taskbar_group_button_leave_event), group);
/* insert */
taskbar->wgroups = g_list_append(taskbar->wgroups, group);
More information about the Xfce4-commits
mailing list