summaryrefslogtreecommitdiff
path: root/applets/wncklet/window-menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'applets/wncklet/window-menu.c')
-rw-r--r--applets/wncklet/window-menu.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/applets/wncklet/window-menu.c b/applets/wncklet/window-menu.c
index dbe09f05..4b4e48dc 100644
--- a/applets/wncklet/window-menu.c
+++ b/applets/wncklet/window-menu.c
@@ -26,7 +26,7 @@
*/
#ifdef HAVE_CONFIG_H
- #include <config.h>
+#include <config.h>
#endif
#include <string.h>
@@ -35,8 +35,15 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#ifdef HAVE_X11
+#include <gdk/gdkx.h>
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
+#endif /* HAVE_X11 */
+
+#ifdef HAVE_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif /* HAVE_WAYLAND */
#include "wncklet.h"
#include "window-menu.h"
@@ -81,13 +88,13 @@ static void window_menu_about(GtkAction* action, WindowMenu* window_menu)
"Copyright \xc2\xa9 2001 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2003 Sun Microsystems, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n"
- "Copyright \xc2\xa9 2012-2020 MATE developers"),
+ "Copyright \xc2\xa9 2012-2021 MATE developers"),
"documenters", documenters,
"icon-name", WINDOW_MENU_ICON,
"logo-icon-name", WINDOW_MENU_ICON,
"translator-credits", _("translator-credits"),
"version", VERSION,
- "website", "http://www.mate-desktop.org/",
+ "website", PACKAGE_URL,
NULL);
}
@@ -151,6 +158,9 @@ static void window_menu_size_allocate(MatePanelApplet* applet, GtkAllocation* al
orient = mate_panel_applet_get_orient(applet);
+ if (!GTK_IS_CONTAINER (window_menu->selector))
+ return;
+
children = gtk_container_get_children(GTK_CONTAINER(window_menu->selector));
child = GTK_WIDGET(children->data);
g_list_free(children);
@@ -178,7 +188,6 @@ static void window_menu_size_allocate(MatePanelApplet* applet, GtkAllocation* al
static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* event, WindowMenu* window_menu)
{
GtkMenuShell* menu_shell;
- WnckSelector* selector;
switch (event->keyval)
{
@@ -188,7 +197,6 @@ static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* even
case GDK_KEY_Return:
case GDK_KEY_space:
case GDK_KEY_KP_Space:
- selector = WNCK_SELECTOR(window_menu->selector);
/*
* We need to call _gtk_menu_shell_activate() here as is done in
* window_key_press_handler in gtkmenubar.c which pops up menu
@@ -196,7 +204,7 @@ static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* even
*
* As that function is private its code is replicated here.
*/
- menu_shell = GTK_MENU_SHELL(selector);
+ menu_shell = GTK_MENU_SHELL(window_menu->selector);
gtk_menu_shell_select_first(menu_shell, FALSE);
return TRUE;
@@ -210,7 +218,7 @@ static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* even
static gboolean filter_button_press(GtkWidget* widget, GdkEventButton* event, gpointer data)
{
if (event->button != 1)
- g_signal_stop_emission_by_name(widget, "button_press_event");
+ g_signal_stop_emission_by_name(widget, "button-press-event");
return FALSE;
}
@@ -231,6 +239,7 @@ gboolean window_menu_applet_fill(MatePanelApplet* applet)
window_menu->orient = mate_panel_applet_get_orient(applet);
g_signal_connect(window_menu->applet, "destroy", G_CALLBACK(window_menu_destroy), window_menu);
+ g_signal_connect(window_menu->applet, "key-press-event", G_CALLBACK(window_menu_key_press_event), window_menu);
action_group = gtk_action_group_new("WindowMenu Applet Actions");
gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
@@ -240,19 +249,45 @@ gboolean window_menu_applet_fill(MatePanelApplet* applet)
action_group);
g_object_unref(action_group);
- window_menu->selector = wnck_selector_new();
- gtk_container_add(GTK_CONTAINER(window_menu->applet), window_menu->selector);
+#ifdef HAVE_X11
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ window_menu->selector = wnck_selector_new();
+ }
+ else
+#endif /* HAVE_X11 */
- mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(window_menu->applet), GTK_WIDGET(window_menu->selector));
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+ {
+ window_menu->selector = gtk_label_new ("[Window menu not supported on Wayland]");
+ }
+ else
+#endif /* HAVE_WAYLAND */
- g_signal_connect(window_menu->applet, "key_press_event", G_CALLBACK(window_menu_key_press_event), window_menu);
- g_signal_connect(window_menu->applet, "size-allocate", G_CALLBACK(window_menu_size_allocate), window_menu);
+ {
+ window_menu->selector = gtk_label_new ("[Window menu not supported on this platform]");
+ }
- g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), window_menu);
- g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), window_menu);
- g_signal_connect_after(G_OBJECT(window_menu->selector), "draw", G_CALLBACK(window_menu_on_draw), window_menu);
+ gtk_container_add(GTK_CONTAINER(window_menu->applet), window_menu->selector);
- g_signal_connect(G_OBJECT(window_menu->selector), "button_press_event", G_CALLBACK(filter_button_press), window_menu);
+ g_signal_connect (window_menu->applet, "size-allocate",
+ G_CALLBACK(window_menu_size_allocate),
+ window_menu);
+
+ g_signal_connect_after (window_menu->applet, "focus-in-event",
+ G_CALLBACK (gtk_widget_queue_draw),
+ window_menu);
+ g_signal_connect_after (window_menu->applet, "focus-out-event",
+ G_CALLBACK (gtk_widget_queue_draw),
+ window_menu);
+ g_signal_connect_after (window_menu->selector, "draw",
+ G_CALLBACK (window_menu_on_draw),
+ window_menu);
+
+ g_signal_connect (window_menu->selector, "button_press_event",
+ G_CALLBACK (filter_button_press),
+ window_menu);
gtk_widget_show_all(GTK_WIDGET(window_menu->applet));