Skip to content

Commit

Permalink
panel/icontasklist: Show action menus on right click
Browse files Browse the repository at this point in the history
When right clicking on an icon in our tasklist, we now show a WnckActionMenu
which supports all possible operations for the window, including minimize,
maximize, close, etc.

In the future, this will probably be wrapped up or reimplemented within
a BudgiePopover to ensure consistency of menu appearance.
  • Loading branch information
ikeydoherty committed Feb 22, 2014
1 parent a36a174 commit 0f03105
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion panel/icon-tasklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static gboolean button_clicked(GtkWidget *widget,
gpointer data)
{
WnckWindow *bwindow = NULL;
GtkWidget *menu = NULL;
guint32 timestamp = gtk_get_current_event_time();

/* Only interested in presses */
Expand All @@ -150,6 +151,12 @@ static gboolean button_clicked(GtkWidget *widget,
if(!bwindow)
return TRUE;

if (event->button.button == 3) {
menu = (GtkWidget*)g_object_get_data(G_OBJECT(widget), "bmenu");
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL,
NULL, event->button.button, timestamp);
return TRUE;
}
if(wnck_window_is_minimized(bwindow)) {
wnck_window_unminimize(bwindow, timestamp);
wnck_window_activate(bwindow, timestamp);
Expand All @@ -168,6 +175,7 @@ static void window_opened(WnckScreen *screen,
{
GtkWidget *button = NULL;
GtkWidget *image = NULL;
GtkWidget *menu = NULL;
const gchar *title;
IconTasklist *self = ICON_TASKLIST(userdata);

Expand Down Expand Up @@ -197,6 +205,10 @@ static void window_opened(WnckScreen *screen,
/* Store a reference to this window for destroy ops, etc. */
g_object_set_data(G_OBJECT(button), "bwindow", window);

/* Add an action menu */
menu = wnck_action_menu_new(window);
g_object_set_data(G_OBJECT(button), "bmenu", menu);

/* When the window changes, update the button
* Icon change is separate so we dont keep reloading images and wasting resources */
g_signal_connect(window, "name-changed", G_CALLBACK(window_update_title), button);
Expand Down Expand Up @@ -224,6 +236,7 @@ static void window_closed(WnckScreen *screen,
IconTasklist *self = ICON_TASKLIST(userdata);
GList *list, *elem;
GtkWidget *toggle;
GtkWidget *menu;
WnckWindow *bwindow;

/* If a buttons window matches the closing window, destroy the button */
Expand All @@ -233,8 +246,11 @@ static void window_closed(WnckScreen *screen,
continue;
toggle = GTK_WIDGET(elem->data);
bwindow = (WnckWindow*)g_object_get_data(G_OBJECT(toggle), "bwindow");
if (bwindow == window)
if (bwindow == window) {
menu = (GtkWidget*)g_object_get_data(G_OBJECT(toggle), "bmenu");
gtk_widget_destroy(menu);
gtk_widget_destroy(toggle);
}
}
}

Expand Down

0 comments on commit 0f03105

Please sign in to comment.