static gboolean title_clicked (GtkWidget *title, GdkEventButton *event, WTApplet *wtapplet) { // only allow left and right mouse button //if (event->button != 1 && event->button != 3) return FALSE; WnckWindow *controlledwindow; if (wtapplet->prefs->only_maximized) { controlledwindow = wtapplet->umaxedwindow; } else { controlledwindow = wtapplet->activewindow; } if (!controlledwindow) return FALSE; // single click (left/right) if (event->button == 1) { // left-click wnck_window_activate(controlledwindow, gtk_get_current_event_time()); if (event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS) { // double/tripple click //if (event->type==GDK_2BUTTON_PRESS) { if (wnck_window_is_maximized(controlledwindow)) { wnck_window_unmaximize(controlledwindow); } else { wnck_window_maximize(controlledwindow); } } } else if (event->button == 3) { // right-click if (wtapplet->prefs->show_window_menu) { wnck_window_activate(controlledwindow, gtk_get_current_event_time()); GtkMenu *window_menu = GTK_MENU(wnck_action_menu_new(controlledwindow)); gtk_menu_popup(window_menu, NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time()); //TODO: somehow alter the panel action menu to also display the wnck_action_menu ! } else { return FALSE; } } else { return FALSE; } return TRUE; }
gboolean on_icon_released(GtkWidget *title, GdkEventButton *event, WindowckPlugin *wckp) { GtkWidget *menu; if ((event->button != 1) || (wnck_window_get_window_type (wckp->win->controlwindow) == WNCK_WINDOW_DESKTOP)) return FALSE; menu = wnck_action_menu_new (wckp->win->controlwindow); gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(wckp->icon->eventbox), NULL); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, xfce_panel_plugin_position_menu, wckp->plugin, 1, gtk_get_current_event_time ()); return TRUE; }
static gboolean on_button_pressed (GtkWidget *button, GdkEventButton *event, TaskItem *item) { WnckWindow *window; g_return_val_if_fail (TASK_IS_ITEM (item), FALSE); window = item->priv->window; g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); if (event->button == 3) { GtkWidget *menu = wnck_action_menu_new (window); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); return TRUE; } return FALSE; }
/** * Event handler for clicking on the title (not the close button) * On double click unmaximized the window * On right click it shows the context menu for the current window */ static gboolean on_button_press (GtkWidget *title, GdkEventButton *event) { g_return_val_if_fail (TASK_IS_TITLE (title), FALSE); TaskTitlePrivate *priv = TASK_TITLE (title)->priv; WnckWindow *window = wnck_screen_get_active_window (priv->screen); g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); if (event->button == 3) { //right click if (wnck_window_get_window_type (window) != WNCK_WINDOW_DESKTOP) { GtkWidget *menu = wnck_action_menu_new (window); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); return TRUE; } } else if (event->button == 1) { //left button double click if (event->type == GDK_2BUTTON_PRESS && wnck_window_is_maximized (window)) { wnck_window_unmaximize (window); } } return FALSE; }
/** * wnck_create_window_action_menu: * @window: the #WnckWindow for which a menu will be created. * * Creates a new #WnckActionMenu. The #WnckActionMenu will be filled with menu * items for window operations on @window. * * Return value: a newly created #WnckActionMenu. * * Deprecated:2.22: Use wnck_action_menu_new() instead. */ GtkWidget* wnck_create_window_action_menu (WnckWindow *window) { return wnck_action_menu_new (window); }
void action_menu_map (WnckWindow *win, long button, Time time) { GdkDisplay *gdkdisplay; GdkScreen *screen; gdkdisplay = gdk_display_get_default (); screen = gdk_display_get_default_screen (gdkdisplay); if (action_menu) { if (action_menu_mapped) { gtk_widget_destroy (action_menu); return; } else gtk_widget_destroy (action_menu); } switch (wnck_window_get_window_type (win)) { case WNCK_WINDOW_DESKTOP: case WNCK_WINDOW_DOCK: /* don't allow window action */ return; case WNCK_WINDOW_NORMAL: case WNCK_WINDOW_DIALOG: case WNCK_WINDOW_TOOLBAR: case WNCK_WINDOW_MENU: case WNCK_WINDOW_UTILITY: case WNCK_WINDOW_SPLASHSCREEN: /* allow window action menu */ break; } action_menu = wnck_action_menu_new (win); g_object_ref_sink (action_menu); gtk_menu_set_screen (GTK_MENU (action_menu), screen); g_signal_connect (G_OBJECT (action_menu), "destroy", G_CALLBACK (action_menu_destroyed), NULL); g_signal_connect (G_OBJECT (action_menu), "unmap", G_CALLBACK (action_menu_unmap), NULL); gtk_widget_show (action_menu); if (!button || button == 1) { gtk_menu_popup (GTK_MENU (action_menu), NULL, NULL, position_action_menu, (gpointer) win, button, time); } else { gtk_menu_popup (GTK_MENU (action_menu), NULL, NULL, NULL, NULL, button, time); } action_menu_mapped = TRUE; }