summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/Makefile.am14
-rw-r--r--mate-panel/applet.c44
-rw-r--r--mate-panel/applet.h3
-rw-r--r--mate-panel/button-widget.c1245
-rw-r--r--mate-panel/button-widget.h40
-rw-r--r--mate-panel/drawer-private.h4
-rw-r--r--mate-panel/drawer.c22
-rw-r--r--mate-panel/drawer.h3
-rw-r--r--mate-panel/launcher.c81
-rw-r--r--mate-panel/launcher.h3
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applet-container.c245
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applet-container.h2
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c4
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.h1
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c16
-rw-r--r--mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.h1
-rw-r--r--mate-panel/libpanel-util/panel-cleanup.c1
-rw-r--r--mate-panel/libpanel-util/panel-cleanup.h1
-rw-r--r--mate-panel/libpanel-util/panel-color.c22
-rw-r--r--mate-panel/libpanel-util/panel-error.c7
-rw-r--r--mate-panel/libpanel-util/panel-error.h1
-rw-r--r--mate-panel/libpanel-util/panel-glib.c1
-rw-r--r--mate-panel/libpanel-util/panel-glib.h1
-rw-r--r--mate-panel/libpanel-util/panel-gtk.c5
-rw-r--r--mate-panel/libpanel-util/panel-gtk.h1
-rw-r--r--mate-panel/libpanel-util/panel-icon-chooser.c41
-rw-r--r--mate-panel/libpanel-util/panel-icon-chooser.h1
-rw-r--r--mate-panel/libpanel-util/panel-keyfile.c9
-rw-r--r--mate-panel/libpanel-util/panel-keyfile.h2
-rw-r--r--mate-panel/libpanel-util/panel-launch.c1
-rw-r--r--mate-panel/libpanel-util/panel-launch.h1
-rw-r--r--mate-panel/libpanel-util/panel-list.c1
-rw-r--r--mate-panel/libpanel-util/panel-list.h1
-rw-r--r--mate-panel/libpanel-util/panel-session-manager.c4
-rw-r--r--mate-panel/libpanel-util/panel-session-manager.h1
-rw-r--r--mate-panel/libpanel-util/panel-show.c1
-rw-r--r--mate-panel/libpanel-util/panel-show.h1
-rw-r--r--mate-panel/libpanel-util/panel-xdg.c11
-rw-r--r--mate-panel/libpanel-util/panel-xdg.h1
-rw-r--r--mate-panel/main.c3
-rw-r--r--mate-panel/mate-desktop-item-edit.c15
-rw-r--r--mate-panel/menu.c79
-rw-r--r--mate-panel/menu.h2
-rw-r--r--mate-panel/panel-a11y.c1
-rw-r--r--mate-panel/panel-a11y.h1
-rw-r--r--mate-panel/panel-action-button.c226
-rw-r--r--mate-panel/panel-action-button.h1
-rw-r--r--mate-panel/panel-action-protocol.c14
-rw-r--r--mate-panel/panel-action-protocol.h1
-rw-r--r--mate-panel/panel-addto.c122
-rw-r--r--mate-panel/panel-addto.h1
-rw-r--r--mate-panel/panel-applet-frame.c15
-rw-r--r--mate-panel/panel-applet-frame.h6
-rw-r--r--mate-panel/panel-applet-info.c1
-rw-r--r--mate-panel/panel-applet-info.h1
-rw-r--r--mate-panel/panel-applets-manager.c1
-rw-r--r--mate-panel/panel-applets-manager.h89
-rw-r--r--mate-panel/panel-background-monitor.c410
-rw-r--r--mate-panel/panel-background-monitor.h68
-rw-r--r--mate-panel/panel-background.c294
-rw-r--r--mate-panel/panel-background.h15
-rw-r--r--mate-panel/panel-bindings.c5
-rw-r--r--mate-panel/panel-bindings.h1
-rw-r--r--mate-panel/panel-config-global.c11
-rw-r--r--mate-panel/panel-config-global.h1
-rw-r--r--mate-panel/panel-context-menu.c24
-rw-r--r--mate-panel/panel-context-menu.h1
-rw-r--r--mate-panel/panel-ditem-editor-dialog.ui322
-rw-r--r--mate-panel/panel-ditem-editor.c375
-rw-r--r--mate-panel/panel-ditem-editor.h1
-rw-r--r--mate-panel/panel-enums-gsettings.h1
-rw-r--r--mate-panel/panel-enums.h1
-rw-r--r--mate-panel/panel-force-quit.c19
-rw-r--r--mate-panel/panel-force-quit.h1
-rw-r--r--mate-panel/panel-frame.c2
-rw-r--r--mate-panel/panel-frame.h1
-rw-r--r--mate-panel/panel-globals.h1
-rw-r--r--mate-panel/panel-layout.c1
-rw-r--r--mate-panel/panel-layout.h1
-rw-r--r--mate-panel/panel-lockdown.c60
-rw-r--r--mate-panel/panel-lockdown.h1
-rw-r--r--mate-panel/panel-menu-bar.c9
-rw-r--r--mate-panel/panel-menu-bar.h1
-rw-r--r--mate-panel/panel-menu-button.c51
-rw-r--r--mate-panel/panel-menu-button.h1
-rw-r--r--mate-panel/panel-menu-items.c273
-rw-r--r--mate-panel/panel-menu-items.h5
-rw-r--r--mate-panel/panel-modules.c1
-rw-r--r--mate-panel/panel-modules.h1
-rw-r--r--mate-panel/panel-multimonitor.c68
-rw-r--r--mate-panel/panel-multimonitor.h1
-rw-r--r--mate-panel/panel-profile.c113
-rw-r--r--mate-panel/panel-profile.h12
-rw-r--r--mate-panel/panel-properties-dialog.c86
-rw-r--r--mate-panel/panel-properties-dialog.h1
-rw-r--r--mate-panel/panel-properties-dialog.ui30
-rw-r--r--mate-panel/panel-recent.c22
-rw-r--r--mate-panel/panel-recent.h4
-rw-r--r--mate-panel/panel-reset.c1
-rw-r--r--mate-panel/panel-reset.h1
-rw-r--r--mate-panel/panel-run-dialog.c332
-rw-r--r--mate-panel/panel-run-dialog.h1
-rw-r--r--mate-panel/panel-schemas.h1
-rw-r--r--mate-panel/panel-separator.c1
-rw-r--r--mate-panel/panel-separator.h1
-rw-r--r--mate-panel/panel-session.c1
-rw-r--r--mate-panel/panel-session.h1
-rw-r--r--mate-panel/panel-shell.c1
-rw-r--r--mate-panel/panel-shell.h1
-rw-r--r--mate-panel/panel-stock-icons.c14
-rw-r--r--mate-panel/panel-stock-icons.h1
-rw-r--r--mate-panel/panel-struts.c781
-rw-r--r--mate-panel/panel-struts.h24
-rw-r--r--mate-panel/panel-test-applets.c14
-rw-r--r--mate-panel/panel-toplevel.c136
-rw-r--r--mate-panel/panel-toplevel.h113
-rw-r--r--mate-panel/panel-util.c2
-rw-r--r--mate-panel/panel-widget.c102
-rw-r--r--mate-panel/panel-widget.h3
-rw-r--r--mate-panel/panel-xutils.c374
-rw-r--r--mate-panel/panel-xutils.h19
-rw-r--r--mate-panel/panel.c35
-rw-r--r--mate-panel/panel.gresource.xml1
-rw-r--r--mate-panel/panel.h1
-rw-r--r--mate-panel/wayland-backend.c1
-rw-r--r--mate-panel/wayland-backend.h1
-rw-r--r--mate-panel/xstuff.c8
127 files changed, 3212 insertions, 3479 deletions
diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am
index 1a2a8ee3..f2f04d27 100644
--- a/mate-panel/Makefile.am
+++ b/mate-panel/Makefile.am
@@ -72,7 +72,6 @@ panel_sources += \
panel-xutils.c \
panel-force-quit.c \
panel-action-protocol.c \
- panel-background-monitor.c \
panel-struts.c
endif
@@ -133,7 +132,6 @@ panel_sources += \
panel-xutils.h \
panel-force-quit.h \
panel-action-protocol.h \
- panel-background-monitor.h \
panel-struts.h
endif
@@ -160,8 +158,7 @@ mate_panel_LDADD = \
$(DCONF_LIBS) \
$(XRANDR_LIBS) \
$(X_LIBS) \
- $(WAYLAND_LIBS) \
- -lm
+ $(WAYLAND_LIBS)
if ENABLE_WAYLAND
mate_panel_LDADD += \
@@ -173,6 +170,8 @@ mate_panel_LDFLAGS = -export-dynamic
mate_desktop_item_edit_SOURCES = \
mate-desktop-item-edit.c \
panel-ditem-editor.c \
+ panel-resources.c \
+ panel-resources.h \
panel-marshal.c \
panel-util.c
@@ -191,6 +190,8 @@ mate_desktop_item_edit_LDADD += \
-lX11
endif
+mate_desktop_item_edit_LDFLAGS = -export-dynamic
+
mate_panel_test_applets_SOURCES = \
$(panel_test_applets_BUILT_SOURCES) \
panel-modules.c \
@@ -269,8 +270,9 @@ BUILT_SOURCES = \
$(mate_panel_BUILT_SOURCES) \
$(panel_test_applets_BUILT_SOURCES)
-ui_FILES = \
- panel-properties-dialog.ui \
+ui_FILES = \
+ panel-ditem-editor-dialog.ui \
+ panel-properties-dialog.ui \
panel-run-dialog.ui
panel-resources.c: panel.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/panel.gresource.xml)
diff --git a/mate-panel/applet.c b/mate-panel/applet.c
index 5df797be..c41f9d85 100644
--- a/mate-panel/applet.c
+++ b/mate-panel/applet.c
@@ -1,5 +1,6 @@
/* Mate panel: general applet functionality
* (C) 1997 the Free Software Foundation
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: George Lebl
* Federico Mena
@@ -35,8 +36,6 @@
#include "panel-lockdown.h"
#include "panel-schemas.h"
-#define SMALL_ICON_SIZE 20
-
static GSList *registered_applets = NULL;
static GSList *queued_position_saves = NULL;
static guint queued_position_source = 0;
@@ -312,7 +311,6 @@ applet_menu_show (GtkWidget *w,
panel_toplevel_push_autohide_disabler (panel_widget->toplevel);
}
-
static void
applet_menu_deactivate (GtkWidget *w,
AppletInfo *info)
@@ -395,9 +393,9 @@ setup_an_item (AppletUserMenu *menu,
gtk_widget_show (menu->menuitem);
- g_signal_connect (G_OBJECT (menu->menuitem), "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &menu->menuitem);
+ g_signal_connect (menu->menuitem, "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &menu->menuitem);
if(submenu)
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menu->menuitem);
@@ -405,11 +403,11 @@ setup_an_item (AppletUserMenu *menu,
/*if an item not a submenu*/
if (!is_submenu) {
g_signal_connect (menu->menuitem, "activate",
- G_CALLBACK (applet_callback_callback),
- menu);
+ G_CALLBACK (applet_callback_callback),
+ menu);
g_signal_connect (submenu, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &menu->submenu);
+ G_CALLBACK (gtk_widget_destroyed),
+ &menu->submenu);
/* if the item is a submenu and doesn't have it's menu
created yet*/
} else if (!menu->submenu) {
@@ -419,9 +417,9 @@ setup_an_item (AppletUserMenu *menu,
if(menu->submenu) {
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->menuitem),
menu->submenu);
- g_signal_connect (G_OBJECT (menu->submenu), "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &menu->submenu);
+ g_signal_connect (menu->submenu, "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &menu->submenu);
}
gtk_widget_set_sensitive(menu->menuitem,menu->sensitive);
@@ -643,14 +641,11 @@ applet_show_menu (AppletInfo *info,
g_return_if_fail (info != NULL);
- panel_widget = mate_panel_applet_get_panel_widget (info);
-
- if (info->menu == NULL)
- info->menu = mate_panel_applet_create_menu (info);
-
- if (info->menu == NULL)
+ if ((info->menu == NULL) && ((info->menu = mate_panel_applet_create_menu (info)) == NULL))
return;
+ panel_widget = mate_panel_applet_get_panel_widget (info);
+
mate_panel_applet_menu_set_recurse (GTK_MENU (info->menu),
"menu_panel",
panel_widget);
@@ -765,8 +760,6 @@ mate_panel_applet_destroy (GtkWidget *widget,
mate_panel_applet_clear_user_menu (info);
g_free (info->id);
- info->id = NULL;
-
g_free (info);
}
@@ -794,11 +787,7 @@ static void
free_applet_to_load (MatePanelAppletToLoad *applet)
{
g_free (applet->id);
- applet->id = NULL;
-
g_free (applet->toplevel_id);
- applet->toplevel_id = NULL;
-
g_free (applet);
}
@@ -1318,11 +1307,11 @@ mate_panel_applet_register (GtkWidget *applet,
if (BUTTON_IS_WIDGET (applet) ||
gtk_widget_get_has_window (applet)) {
- g_signal_connect (applet, "button_press_event",
+ g_signal_connect (applet, "button-press-event",
G_CALLBACK (applet_button_press),
info);
- g_signal_connect (applet, "popup_menu",
+ g_signal_connect (applet, "popup-menu",
G_CALLBACK (applet_popup_menu),
info);
}
@@ -1384,6 +1373,5 @@ mate_panel_applet_lockable (AppletInfo *applet)
if (panel_lockdown_get_locked_down ())
return FALSE;
-
return g_settings_is_writable (applet->settings, PANEL_OBJECT_LOCKED_KEY);
}
diff --git a/mate-panel/applet.h b/mate-panel/applet.h
index 380e1f21..b7b3603b 100644
--- a/mate-panel/applet.h
+++ b/mate-panel/applet.h
@@ -11,7 +11,6 @@
extern "C" {
#endif
-
#define APPLET_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_POINTER_MOTION_MASK | \
@@ -77,7 +76,6 @@ void mate_panel_applet_queue_applet_to_load (const char *id,
void mate_panel_applet_load_queued_applets (gboolean initial_load);
gboolean mate_panel_applet_on_load_queue (const char *id);
-
void mate_panel_applet_add_callback (AppletInfo *info,
const gchar *callback_name,
const gchar *stock_item,
@@ -89,7 +87,6 @@ void mate_panel_applet_clear_user_menu (AppletInfo *info);
AppletUserMenu *mate_panel_applet_get_callback (GList *user_menu,
const gchar *name);
-
void mate_panel_applet_save_position (AppletInfo *applet_info,
const char *id,
gboolean immediate);
diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c
index f2deb0e5..00753b99 100644
--- a/mate-panel/button-widget.c
+++ b/mate-panel/button-widget.c
@@ -1,11 +1,11 @@
#include <config.h>
-#include <math.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
#include "button-widget.h"
#include "panel-widget.h"
@@ -19,33 +19,34 @@
#include "panel-enums-gsettings.h"
struct _ButtonWidgetPrivate {
- GtkIconTheme *icon_theme;
- cairo_surface_t *surface;
- cairo_surface_t *surface_hc;
+ GtkIconTheme *icon_theme;
+ cairo_surface_t *surface;
+ cairo_surface_t *surface_hc;
- char *filename;
+ char *filename;
- PanelOrientation orientation;
+ PanelOrientation orientation;
- int size;
+ int size;
- guint activatable : 1;
- guint ignore_leave : 1;
- guint arrow : 1;
- guint dnd_highlight : 1;
+ guint activatable : 1;
+ guint ignore_leave : 1;
+ guint arrow : 1;
+ guint dnd_highlight : 1;
+ gboolean needs_move;
};
static void button_widget_icon_theme_changed (ButtonWidget *button);
static void button_widget_reload_surface (ButtonWidget *button);
enum {
- PROP_0,
- PROP_ACTIVATABLE,
- PROP_IGNORE_LEAVE,
- PROP_HAS_ARROW,
- PROP_DND_HIGHLIGHT,
- PROP_ORIENTATION,
- PROP_ICON_NAME
+ PROP_0,
+ PROP_ACTIVATABLE,
+ PROP_IGNORE_LEAVE,
+ PROP_HAS_ARROW,
+ PROP_DND_HIGHLIGHT,
+ PROP_ORIENTATION,
+ PROP_ICON_NAME
};
#define BUTTON_WIDGET_DISPLACEMENT 2
@@ -56,836 +57,876 @@ G_DEFINE_TYPE_WITH_PRIVATE (ButtonWidget, button_widget, GTK_TYPE_BUTTON)
static void
do_colorshift (cairo_surface_t *dest, cairo_surface_t *src, int shift)
{
- gint i, j;
- gint width, height, has_alpha, srcrowstride, destrowstride;
- guchar *target_pixels;
- guchar *original_pixels;
- int val;
- guchar r,g,b;
-
- has_alpha = cairo_surface_get_content (src) != CAIRO_CONTENT_COLOR;
- width = cairo_image_surface_get_width (src);
- height = cairo_image_surface_get_height (src);
- srcrowstride = cairo_image_surface_get_stride (src);
- destrowstride = cairo_image_surface_get_stride (dest);
- original_pixels = cairo_image_surface_get_data (src);
- target_pixels = cairo_image_surface_get_data (dest);
-
- for (i = 0; i < height; i++) {
- guchar *pixdest = target_pixels + i*destrowstride;
- guchar *pixsrc = original_pixels + i*srcrowstride;
- for (j = 0; j < width; j++) {
- r = *(pixsrc++);
- g = *(pixsrc++);
- b = *(pixsrc++);
- val = r + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- val = g + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- val = b + shift;
- *(pixdest++) = CLAMP(val, 0, 255);
- if (has_alpha)
- *(pixdest++) = *(pixsrc++);
- }
- }
+ gint i, j;
+ gint width, height, has_alpha, srcrowstride, destrowstride;
+ guchar *target_pixels;
+ guchar *original_pixels;
+ int val;
+ guchar r,g,b;
+
+ has_alpha = cairo_surface_get_content (src) != CAIRO_CONTENT_COLOR;
+ width = cairo_image_surface_get_width (src);
+ height = cairo_image_surface_get_height (src);
+ srcrowstride = cairo_image_surface_get_stride (src);
+ destrowstride = cairo_image_surface_get_stride (dest);
+ original_pixels = cairo_image_surface_get_data (src);
+ target_pixels = cairo_image_surface_get_data (dest);
+
+ for (i = 0; i < height; i++) {
+ guchar *pixdest = target_pixels + i*destrowstride;
+ guchar *pixsrc = original_pixels + i*srcrowstride;
+ for (j = 0; j < width; j++) {
+ r = *(pixsrc++);
+ g = *(pixsrc++);
+ b = *(pixsrc++);
+ val = r + shift;
+ *(pixdest++) = CLAMP(val, 0, 255);
+ val = g + shift;
+ *(pixdest++) = CLAMP(val, 0, 255);
+ val = b + shift;
+ *(pixdest++) = CLAMP(val, 0, 255);
+ if (has_alpha)
+ *(pixdest++) = *(pixsrc++);
+ }
+ }
}
static cairo_surface_t *
make_hc_surface (cairo_surface_t *surface)
{
- cairo_t *cr;
- cairo_surface_t *new;
+ cairo_t *cr;
+ cairo_surface_t *new;
- if (!surface)
- return NULL;
+ if (!surface)
+ return NULL;
- new = cairo_surface_create_similar (surface,
- cairo_surface_get_content (surface),
- cairo_image_surface_get_width (surface),
- cairo_image_surface_get_height (surface));
+ new = cairo_surface_create_similar (surface,
+ cairo_surface_get_content (surface),
+ cairo_image_surface_get_width (surface),
+ cairo_image_surface_get_height (surface));
- do_colorshift (new, surface, 30);
+ do_colorshift (new, surface, 30);
- cr = cairo_create (new);
- cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
- cairo_mask_surface (cr, surface, 0, 0);
- cairo_destroy (cr);
+ cr = cairo_create (new);
+ cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
+ cairo_mask_surface (cr, surface, 0, 0);
+ cairo_destroy (cr);
- return new;
+ return new;
}
static void
button_widget_realize(GtkWidget *widget)
{
- gtk_widget_add_events (widget, GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_KEY_PRESS_MASK);
+ gtk_widget_add_events (widget, GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_KEY_PRESS_MASK);
- GTK_WIDGET_CLASS (button_widget_parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (button_widget_parent_class)->realize (widget);
- BUTTON_WIDGET (widget)->priv->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
- g_signal_connect_object (BUTTON_WIDGET (widget)->priv->icon_theme,
- "changed",
- G_CALLBACK (button_widget_icon_theme_changed),
- widget,
- G_CONNECT_SWAPPED);
+ BUTTON_WIDGET (widget)->priv->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
+ g_signal_connect_object (BUTTON_WIDGET (widget)->priv->icon_theme,
+ "changed",
+ G_CALLBACK (button_widget_icon_theme_changed),
+ widget,
+ G_CONNECT_SWAPPED);
- button_widget_reload_surface (BUTTON_WIDGET (widget));
+ button_widget_reload_surface (BUTTON_WIDGET (widget));
}
static void
button_widget_unrealize (GtkWidget *widget)
{
- g_signal_handlers_disconnect_by_func (BUTTON_WIDGET (widget)->priv->icon_theme,
- G_CALLBACK (button_widget_icon_theme_changed),
- widget);
+ g_signal_handlers_disconnect_by_func (BUTTON_WIDGET (widget)->priv->icon_theme,
+ G_CALLBACK (button_widget_icon_theme_changed),
+ widget);
- GTK_WIDGET_CLASS (button_widget_parent_class)->unrealize (widget);
+ GTK_WIDGET_CLASS (button_widget_parent_class)->unrealize (widget);
}
static void
button_widget_unset_surfaces (ButtonWidget *button)
{
- if (button->priv->surface)
- cairo_surface_destroy (button->priv->surface);
- button->priv->surface = NULL;
+ if (button->priv->surface)
+ cairo_surface_destroy (button->priv->surface);
- if (button->priv->surface_hc)
- cairo_surface_destroy (button->priv->surface_hc);
- button->priv->surface_hc = NULL;
+ button->priv->surface = NULL;
+
+ if (button->priv->surface_hc)
+ cairo_surface_destroy (button->priv->surface_hc);
+
+ button->priv->surface_hc = NULL;
}
static void
button_widget_reload_surface (ButtonWidget *button)
{
- button_widget_unset_surfaces (button);
-
- if (button->priv->size <= 1 || button->priv->icon_theme == NULL)
- return;
-
- if (button->priv->filename != NULL &&
- button->priv->filename [0] != '\0') {
- gint scale;
- char *error = NULL;
-
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (button));
-
- button->priv->surface =
- panel_load_icon (button->priv->icon_theme,
- button->priv->filename,
- button->priv->size * scale,
- (button->priv->orientation & PANEL_VERTICAL_MASK) ? button->priv->size * scale : -1,
- (button->priv->orientation & PANEL_HORIZONTAL_MASK) ? button->priv->size * scale: -1,
- &error);
- if (error) {
- /* FIXME: this is not rendered at button->priv->size */
- GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
- button->priv->surface = gtk_icon_theme_load_surface (icon_theme,
- "image-missing",
- GTK_ICON_SIZE_BUTTON,
- scale,
- NULL,
- GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_USE_BUILTIN,
- NULL);
- g_free (error);
- }
- }
-
- button->priv->surface_hc = make_hc_surface (button->priv->surface);
-
- gtk_widget_queue_resize (GTK_WIDGET (button));
+ button_widget_unset_surfaces (button);
+
+ button->priv->needs_move = FALSE;
+ if (button->priv->size <= 1 || button->priv->icon_theme == NULL)
+ return;
+
+ if (button->priv->filename != NULL && button->priv->filename [0] != '\0') {
+ GdkDisplay *display;
+ gint scale;
+ char *error = NULL;
+ /* icons findable in the icon theme can be handled by gtk directly*/
+ display = gdk_display_get_default ();
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (button));
+ GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
+ button->priv->surface =
+ gtk_icon_theme_load_surface (icon_theme,
+ button->priv->filename,
+ button->priv->size,
+ scale,
+ NULL,
+ GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_FORCE_SVG,
+ NULL);
+
+ /*fallback to catch the case of custom icons in x11*/
+ if (!button->priv->surface && GDK_IS_X11_DISPLAY (display)) {
+ button->priv->surface =
+ panel_load_icon (button->priv->icon_theme,
+ button->priv->filename,
+ button->priv->size * scale,
+ (button->priv->orientation & PANEL_VERTICAL_MASK) ? button->priv->size * scale : -1,
+ (button->priv->orientation & PANEL_HORIZONTAL_MASK) ? button->priv->size * scale: -1,
+ &error);
+ }
+ else if (!button->priv->surface) {
+ /*fallback to catch the case of custom icons not in x11*/
+ button->priv->needs_move = TRUE;
+ button->priv->surface =
+ panel_load_icon (button->priv->icon_theme,
+ button->priv->filename,
+ button->priv->size * scale,
+ (button->priv->orientation & PANEL_VERTICAL_MASK) ? button->priv->size : -1,
+ (button->priv->orientation & PANEL_HORIZONTAL_MASK) ? button->priv->size : -1,
+ &error);
+ }
+ if (error) {
+ /*Last fallback for case of icon not found
+ * FIXME: this is not rendered at button->priv->size
+ */
+ button->priv->needs_move = FALSE;
+ button->priv->surface =
+ gtk_icon_theme_load_surface (icon_theme,
+ "image-missing",
+ GTK_ICON_SIZE_BUTTON,
+ scale,
+ NULL,
+ GTK_ICON_LOOKUP_FORCE_SVG | GTK_ICON_LOOKUP_USE_BUILTIN,
+ NULL);
+
+ g_free (error);
+ }
+ }
+
+ button->priv->surface_hc = make_hc_surface (button->priv->surface);
+
+ gtk_widget_queue_resize (GTK_WIDGET (button));
}
static void
button_widget_icon_theme_changed (ButtonWidget *button)
{
- if (button->priv->filename != NULL)
- button_widget_reload_surface (button);
+ if (button->priv->filename != NULL)
+ button_widget_reload_surface (button);
}
static void
button_widget_finalize (GObject *object)
{
- ButtonWidget *button = (ButtonWidget *) object;
+ ButtonWidget *button = (ButtonWidget *) object;
- button_widget_unset_surfaces (button);
+ button_widget_unset_surfaces (button);
- g_free (button->priv->filename);
- button->priv->filename = NULL;
+ g_clear_pointer (&button->priv->filename, g_free);
- G_OBJECT_CLASS (button_widget_parent_class)->finalize (object);
+ G_OBJECT_CLASS (button_widget_parent_class)->finalize (object);
}
static void
button_widget_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ButtonWidget *button;
-
- g_return_if_fail (BUTTON_IS_WIDGET (object));
-
- button = BUTTON_WIDGET (object);
-
- switch (prop_id) {
- case PROP_ACTIVATABLE:
- g_value_set_boolean (value, button->priv->activatable);
- break;
- case PROP_IGNORE_LEAVE:
- g_value_set_boolean (value, button->priv->ignore_leave);
- break;
- case PROP_HAS_ARROW:
- g_value_set_boolean (value, button->priv->arrow);
- break;
- case PROP_DND_HIGHLIGHT:
- g_value_set_boolean (value, button->priv->dnd_highlight);
- break;
- case PROP_ORIENTATION:
- g_value_set_enum (value, button->priv->orientation);
- break;
- case PROP_ICON_NAME:
- g_value_set_string (value, button->priv->filename);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ButtonWidget *button;
+
+ g_return_if_fail (BUTTON_IS_WIDGET (object));
+
+ button = BUTTON_WIDGET (object);
+
+ switch (prop_id) {
+ case PROP_ACTIVATABLE:
+ g_value_set_boolean (value, button->priv->activatable);
+ break;
+ case PROP_IGNORE_LEAVE:
+ g_value_set_boolean (value, button->priv->ignore_leave);
+ break;
+ case PROP_HAS_ARROW:
+ g_value_set_boolean (value, button->priv->arrow);
+ break;
+ case PROP_DND_HIGHLIGHT:
+ g_value_set_boolean (value, button->priv->dnd_highlight);
+ break;
+ case PROP_ORIENTATION:
+ g_value_set_enum (value, button->priv->orientation);
+ break;
+ case PROP_ICON_NAME:
+ g_value_set_string (value, button->priv->filename);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
button_widget_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ButtonWidget *button;
-
- g_return_if_fail (BUTTON_IS_WIDGET (object));
-
- button = BUTTON_WIDGET (object);
-
- switch (prop_id) {
- case PROP_ACTIVATABLE:
- button_widget_set_activatable (button, g_value_get_boolean (value));
- break;
- case PROP_IGNORE_LEAVE:
- button_widget_set_ignore_leave (button, g_value_get_boolean (value));
- break;
- case PROP_HAS_ARROW:
- button_widget_set_has_arrow (button, g_value_get_boolean (value));
- break;
- case PROP_DND_HIGHLIGHT:
- button_widget_set_dnd_highlight (button, g_value_get_boolean (value));
- break;
- case PROP_ORIENTATION:
- button_widget_set_orientation (button, g_value_get_enum (value));
- break;
- case PROP_ICON_NAME:
- button_widget_set_icon_name (button, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ButtonWidget *button;
+
+ g_return_if_fail (BUTTON_IS_WIDGET (object));
+
+ button = BUTTON_WIDGET (object);
+
+ switch (prop_id) {
+ case PROP_ACTIVATABLE:
+ button_widget_set_activatable (button, g_value_get_boolean (value));
+ break;
+ case PROP_IGNORE_LEAVE:
+ button_widget_set_ignore_leave (button, g_value_get_boolean (value));
+ break;
+ case PROP_HAS_ARROW:
+ button_widget_set_has_arrow (button, g_value_get_boolean (value));
+ break;
+ case PROP_DND_HIGHLIGHT:
+ button_widget_set_dnd_highlight (button, g_value_get_boolean (value));
+ break;
+ case PROP_ORIENTATION:
+ button_widget_set_orientation (button, g_value_get_enum (value));
+ break;
+ case PROP_ICON_NAME:
+ button_widget_set_icon_name (button, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GtkArrowType
calc_arrow (PanelOrientation orientation,
- int button_width,
- int button_height,
- int *x,
- int *y,
- gdouble *angle,
- gdouble *size)
-{
- GtkArrowType retval = GTK_ARROW_UP;
-
- if (orientation & PANEL_HORIZONTAL_MASK) {
- if (button_width > 50)
- button_width = 50;
- } else {
- if (button_height > 50)
- button_height = 50;
- }
-
- *size = ((orientation & PANEL_HORIZONTAL_MASK) ? button_width : button_height) / 2;
- *angle = 0;
-
- switch (orientation) {
- case PANEL_ORIENTATION_TOP:
- *x = (button_width - (*size)) / 2;
- *y = button_height * .99 - (*size) / (3/2); /* 3/2 is the approximate ratio of GTK arrows */
- *angle = G_PI;
- retval = GTK_ARROW_DOWN;
- break;
- case PANEL_ORIENTATION_BOTTOM:
- *x = (button_width - (*size)) / 2;
- *y = button_height * .01;
- *angle = 0;
- retval = GTK_ARROW_UP;
- break;
- case PANEL_ORIENTATION_LEFT:
- *x = button_width * .99 - (*size) / (3/2); /* 3/2 is the approximate ratio of GTK arrows */
- *y = (button_height - (*size)) / 2;
- *angle = G_PI / 2;
- retval = GTK_ARROW_RIGHT;
- break;
- case PANEL_ORIENTATION_RIGHT:
- *x = button_width * .01;
- *y = (button_height - (*size)) / 2;
- *angle = 3 * (G_PI / 2);
- retval = GTK_ARROW_LEFT;
- break;
- }
-
- return retval;
+ int button_width,
+ int button_height,
+ int *x,
+ int *y,
+ gdouble *angle,
+ gdouble *size)
+{
+ GtkArrowType retval = GTK_ARROW_UP;
+
+ if (orientation & PANEL_HORIZONTAL_MASK) {
+ if (button_width > 50)
+ button_width = 50;
+ } else {
+ if (button_height > 50)
+ button_height = 50;
+ }
+
+ *size = ((orientation & PANEL_HORIZONTAL_MASK) ? button_width : button_height) / 2;
+ *angle = 0;
+
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ *x = (button_width - (*size)) / 2;
+ *y = button_height * .99 - (*size) / (3/2); /* 3/2 is the approximate ratio of GTK arrows */
+ *angle = G_PI;
+ retval = GTK_ARROW_DOWN;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ *x = (button_width - (*size)) / 2;
+ *y = button_height * .01;
+ *angle = 0;
+ retval = GTK_ARROW_UP;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ *x = button_width * .99 - (*size) / (3/2); /* 3/2 is the approximate ratio of GTK arrows */
+ *y = (button_height - (*size)) / 2;
+ *angle = G_PI / 2;
+ retval = GTK_ARROW_RIGHT;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ *x = button_width * .01;
+ *y = (button_height - (*size)) / 2;
+ *angle = 3 * (G_PI / 2);
+ retval = GTK_ARROW_LEFT;
+ break;
+ }
+
+ return retval;
}
static gboolean
button_widget_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- ButtonWidget *button_widget;
- int width;
- int height;
- GtkStyleContext *context;
- GtkStateFlags state_flags;
- int off;
- int x, y, w, h;
- int scale;
-
- g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
-
- button_widget = BUTTON_WIDGET (widget);
-
- if (!button_widget->priv->surface_hc && !button_widget->priv->surface)
- return FALSE;
-
- state_flags = gtk_widget_get_state_flags (widget);
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
- scale = gtk_widget_get_scale_factor (widget);
-
- /* offset for pressed buttons */
- off = (button_widget->priv->activatable &&
- (state_flags & GTK_STATE_FLAG_PRELIGHT) && (state_flags & GTK_STATE_FLAG_ACTIVE)) ?
- BUTTON_WIDGET_DISPLACEMENT * height / 48.0 : 0;
-
- w = cairo_image_surface_get_width (button_widget->priv->surface) / scale;
- h = cairo_image_surface_get_height (button_widget->priv->surface) / scale;
- x = off + (width - w) / 2;
- y = off + (height - h) / 2;
-
- cairo_save (cr);
-
- if (!button_widget->priv->activatable) {
- cairo_set_source_surface (cr, button_widget->priv->surface, x, y);
- cairo_mask_surface (cr, button_widget->priv->surface, x, y);
- cairo_set_operator (cr, CAIRO_OPERATOR_HSL_SATURATION);
- cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
- } else if (panel_global_config_get_highlight_when_over () &&
- (state_flags & GTK_STATE_FLAG_PRELIGHT || gtk_widget_has_focus (widget))) {
- cairo_set_source_surface (cr, button_widget->priv->surface_hc, x, y);
- } else {
- cairo_set_source_surface (cr, button_widget->priv->surface, x, y);
- }
-
- cairo_paint (cr);
- cairo_restore (cr);
-
- context = gtk_widget_get_style_context (widget);
-
- if (button_widget->priv->arrow) {
- gdouble angle, size;
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, state_flags);
-
- calc_arrow (button_widget->priv->orientation,
- width, height,
- &x, &y,
- &angle, &size);
-
- cairo_save (cr);
- gtk_render_arrow (context, cr, angle, x, y, size);
- cairo_restore (cr);
-
- gtk_style_context_restore (context);
- }
-
- if (button_widget->priv->dnd_highlight) {
-
- cairo_save (cr);
- cairo_set_line_width (cr, 1);
- cairo_set_source_rgb (cr, 0., 0., 0.);
- cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
- cairo_stroke (cr);
- cairo_restore (cr);
- }
-
- if (gtk_widget_has_focus (widget)) {
- gtk_style_context_save (context);
- gtk_style_context_set_state (context, state_flags);
-
- cairo_save (cr);
- gtk_render_focus (context, cr, 0, 0, width, height);
- cairo_restore (cr);
-
- gtk_style_context_restore (context);
- }
-
- return FALSE;
+ cairo_t *cr)
+{
+ ButtonWidget *button_widget;
+ int width;
+ int height;
+ GtkStyleContext *context;
+ GtkStateFlags state_flags;
+ int off;
+ int x, y, w, h;
+ int scale;
+
+ g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
+
+ button_widget = BUTTON_WIDGET (widget);
+
+ if (!button_widget->priv->surface_hc && !button_widget->priv->surface)
+ return FALSE;
+
+ state_flags = gtk_widget_get_state_flags (widget);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+ scale = gtk_widget_get_scale_factor (widget);
+
+ /* offset for pressed buttons */
+ off = (button_widget->priv->activatable &&
+ (state_flags & GTK_STATE_FLAG_PRELIGHT) && (state_flags & GTK_STATE_FLAG_ACTIVE)) ?
+ BUTTON_WIDGET_DISPLACEMENT * height / 48.0 : 0;
+
+ if (button_widget->priv->needs_move) {
+ /*This is for custom icons using the older code in wayland*/
+ w = cairo_image_surface_get_width (button_widget->priv->surface);
+ h = cairo_image_surface_get_height (button_widget->priv->surface);
+ }
+ else {
+ w = cairo_image_surface_get_width (button_widget->priv->surface) / scale;
+ h = cairo_image_surface_get_height (button_widget->priv->surface) / scale;
+ }
+ x = off + (width - w) / 2;
+ y = off + (height - h) / 2;
+
+ cairo_save (cr);
+
+ if (!button_widget->priv->activatable) {
+ cairo_set_source_surface (cr, button_widget->priv->surface, x, y);
+ cairo_mask_surface (cr, button_widget->priv->surface, x, y);
+ cairo_set_operator (cr, CAIRO_OPERATOR_HSL_SATURATION);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+ }
+ else if (panel_global_config_get_highlight_when_over () &&
+ (state_flags & GTK_STATE_FLAG_PRELIGHT || gtk_widget_has_focus (widget))) {
+ cairo_set_source_surface (cr, button_widget->priv->surface_hc, x, y);
+ }
+ else {
+ cairo_set_source_surface (cr, button_widget->priv->surface, x, y);
+ }
+
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ context = gtk_widget_get_style_context (widget);
+
+ if (button_widget->priv->arrow) {
+ gdouble angle, size;
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state_flags);
+
+ calc_arrow (button_widget->priv->orientation,
+ width, height,
+ &x, &y,
+ &angle, &size);
+
+ cairo_save (cr);
+ gtk_render_arrow (context, cr, angle, x, y, size);
+ cairo_restore (cr);
+
+ gtk_style_context_restore (context);
+ }
+
+ if (button_widget->priv->dnd_highlight) {
+ cairo_save (cr);
+ cairo_set_line_width (cr, 1);
+ cairo_set_source_rgb (cr, 0., 0., 0.);
+ cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+ cairo_stroke (cr);
+ cairo_restore (cr);
+ }
+
+ if (gtk_widget_has_focus (widget)) {
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state_flags);
+
+ cairo_save (cr);
+ gtk_render_focus (context, cr, 0, 0, width, height);
+ cairo_restore (cr);
+
+ gtk_style_context_restore (context);
+ }
+
+ return FALSE;
}
static void
button_widget_get_preferred_width (GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width)
+ gint *minimal_width,
+ gint *natural_width)
{
- ButtonWidget *button_widget = BUTTON_WIDGET (widget);
- GtkWidget *parent;
- int size;
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+ GtkWidget *parent;
+ int size;
- parent = gtk_widget_get_parent (widget);
+ parent = gtk_widget_get_parent (widget);
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK){
- size = gtk_widget_get_allocated_height (parent);
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
+ size = gtk_widget_get_allocated_height (parent);
- /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
- if ( size > 50 )
- size = 50;
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
+ if (size > 50)
+ size = 50;
- } else
- size = gtk_widget_get_allocated_width (parent);
+ } else
+ size = gtk_widget_get_allocated_width (parent);
- *minimal_width = *natural_width = size;
+ *minimal_width = *natural_width = size;
}
static void
button_widget_get_preferred_height (GtkWidget *widget,
- gint *minimal_height,
- gint *natural_height)
+ gint *minimal_height,
+ gint *natural_height)
{
- ButtonWidget *button_widget = BUTTON_WIDGET (widget);
- GtkWidget *parent;
- int size;
-
- parent = gtk_widget_get_parent (widget);
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+ GtkWidget *parent;
+ int size;
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
- size = gtk_widget_get_allocated_height (parent);
- else {
- size = gtk_widget_get_allocated_width (parent);
+ parent = gtk_widget_get_parent (widget);
- /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
- if ( size > 50 )
- size = 50;
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
+ size = gtk_widget_get_allocated_height (parent);
+ else {
+ size = gtk_widget_get_allocated_width (parent);
- }
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48*/
+ if (size > 50)
+ size = 50;
+ }
- *minimal_height = *natural_height = size;
+ *minimal_height = *natural_height = size;
}
static void
button_widget_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- ButtonWidget *button_widget = BUTTON_WIDGET (widget);
- int size;
-
- /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48?*/
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
- if ( allocation->height > 50 ) {
- allocation->width = 50;
- }
- } else {
- if ( allocation->width > 50 ) {
- allocation->height = 50;
- }
- }
-
- GTK_WIDGET_CLASS (button_widget_parent_class)->size_allocate (widget, allocation);
-
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
- size = allocation->height;
- else
- size = allocation->width;
-
- if (size < 22)
- size = 16;
- else if (size < 24)
- size = 22;
- else if (size < 32)
- size = 24;
- else if (size < 48)
- size = 32;
- else
- size = 48;
-
- if (button_widget->priv->size != size) {
- button_widget->priv->size = size;
-
- button_widget_reload_surface (button_widget);
- }
+ GtkAllocation *allocation)
+{
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+ int size;
+
+ /* should get this value (50) from gsettings, user defined value in properties of the panel (max_icon_size) OR use 48?*/
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
+ if (allocation->height > 50) {
+ allocation->width = 50;
+ }
+ }
+ else {
+ if (allocation->width > 50) {
+ allocation->height = 50;
+ }
+ }
+
+ GTK_WIDGET_CLASS (button_widget_parent_class)->size_allocate (widget, allocation);
+
+ if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
+ size = allocation->height;
+ else
+ size = allocation->width;
+
+ if (size < 22)
+ size = 16;
+ else if (size < 24)
+ size = 22;
+ else if (size < 32)
+ size = 24;
+ else if (size < 48)
+ size = 32;
+ else
+ size = 48;
+
+ if (button_widget->priv->size != size) {
+ button_widget->priv->size = size;
+
+ button_widget_reload_surface (button_widget);
+ }
}
static void
button_widget_activate (GtkButton *button)
{
- ButtonWidget *button_widget = BUTTON_WIDGET (button);
+ ButtonWidget *button_widget = BUTTON_WIDGET (button);
- if (!button_widget->priv->activatable)
- return;
+ if (!button_widget->priv->activatable)
+ return;
- if (GTK_BUTTON_CLASS (button_widget_parent_class)->activate)
- GTK_BUTTON_CLASS (button_widget_parent_class)->activate (button);
+ if (GTK_BUTTON_CLASS (button_widget_parent_class)->activate)
+ GTK_BUTTON_CLASS (button_widget_parent_class)->activate (button);
}
static gboolean
button_widget_button_press (GtkWidget *widget, GdkEventButton *event)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
- if (event->button == 1 && BUTTON_WIDGET (widget)->priv->activatable &&
- /* we don't want to have two/three "click" events for double/triple
- * clicks. FIXME: this is only a workaround, waiting for bug 159101 */
- event->type == GDK_BUTTON_PRESS)
- return GTK_WIDGET_CLASS (button_widget_parent_class)->button_press_event (widget, event);
+ if (event->button == 1 && BUTTON_WIDGET (widget)->priv->activatable &&
+ /* we don't want to have two/three "click" events for double/triple
+ * clicks. FIXME: this is only a workaround, waiting for bug 159101 */
+ event->type == GDK_BUTTON_PRESS)
+ return GTK_WIDGET_CLASS (button_widget_parent_class)->button_press_event (widget, event);
- return FALSE;
+ return FALSE;
}
static gboolean
-button_widget_enter_notify (GtkWidget *widget, GdkEventCrossing *event)
+button_widget_enter_notify (GtkWidget *widget,
+ GdkEventCrossing *event)
{
- gboolean in_button;
+ gboolean in_button;
- g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
- GtkStateFlags state_flags = gtk_widget_get_state_flags (widget);
- in_button = state_flags & GTK_STATE_FLAG_PRELIGHT;
+ GtkStateFlags state_flags = gtk_widget_get_state_flags (widget);
+ in_button = state_flags & GTK_STATE_FLAG_PRELIGHT;
- GTK_WIDGET_CLASS (button_widget_parent_class)->enter_notify_event (widget, event);
+ GTK_WIDGET_CLASS (button_widget_parent_class)->enter_notify_event (widget, event);
- state_flags = gtk_widget_get_state_flags (widget);
- if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
- panel_global_config_get_highlight_when_over ())
- gtk_widget_queue_draw (widget);
+ state_flags = gtk_widget_get_state_flags (widget);
+ if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
+ panel_global_config_get_highlight_when_over ())
+ gtk_widget_queue_draw (widget);
- return FALSE;
+ return FALSE;
}
static gboolean
-button_widget_leave_notify (GtkWidget *widget, GdkEventCrossing *event)
+button_widget_leave_notify (GtkWidget *widget,
+ GdkEventCrossing *event)
{
- gboolean in_button;
+ gboolean in_button;
- g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
- GtkStateFlags state_flags = gtk_widget_get_state_flags (widget);
- in_button = state_flags & GTK_STATE_FLAG_PRELIGHT;
+ GtkStateFlags state_flags = gtk_widget_get_state_flags (widget);
+ in_button = state_flags & GTK_STATE_FLAG_PRELIGHT;
- GTK_WIDGET_CLASS (button_widget_parent_class)->leave_notify_event (widget, event);
+ GTK_WIDGET_CLASS (button_widget_parent_class)->leave_notify_event (widget, event);
- state_flags = gtk_widget_get_state_flags (widget);
- if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
- panel_global_config_get_highlight_when_over ())
- gtk_widget_queue_draw (widget);
+ state_flags = gtk_widget_get_state_flags (widget);
+ if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
+ panel_global_config_get_highlight_when_over ())
+ gtk_widget_queue_draw (widget);
- return FALSE;
+ return FALSE;
}
static void
button_widget_init (ButtonWidget *button)
{
- button->priv = button_widget_get_instance_private (button);
+ button->priv = button_widget_get_instance_private (button);
- button->priv->icon_theme = NULL;
- button->priv->surface = NULL;
- button->priv->surface_hc = NULL;
+ button->priv->icon_theme = NULL;
+ button->priv->surface = NULL;
+ button->priv->surface_hc = NULL;
- button->priv->filename = NULL;
+ button->priv->filename = NULL;
- button->priv->orientation = PANEL_ORIENTATION_TOP;
+ button->priv->orientation = PANEL_ORIENTATION_TOP;
- button->priv->size = 0;
+ button->priv->size = 0;
- button->priv->activatable = FALSE;
- button->priv->ignore_leave = FALSE;
- button->priv->arrow = FALSE;
- button->priv->dnd_highlight = FALSE;
+ button->priv->activatable = FALSE;
+ button->priv->ignore_leave = FALSE;
+ button->priv->arrow = FALSE;
+ button->priv->dnd_highlight = FALSE;
}
static void
button_widget_class_init (ButtonWidgetClass *klass)
{
- GObjectClass *gobject_class = (GObjectClass *) klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
- GtkButtonClass *button_class = (GtkButtonClass *) klass;
-
- gobject_class->finalize = button_widget_finalize;
- gobject_class->get_property = button_widget_get_property;
- gobject_class->set_property = button_widget_set_property;
-
- widget_class->realize = button_widget_realize;
- widget_class->unrealize = button_widget_unrealize;
- widget_class->size_allocate = button_widget_size_allocate;
- widget_class->get_preferred_width = button_widget_get_preferred_width;
- widget_class->get_preferred_height = button_widget_get_preferred_height;
- widget_class->draw = button_widget_draw;
- widget_class->button_press_event = button_widget_button_press;
- widget_class->enter_notify_event = button_widget_enter_notify;
- widget_class->leave_notify_event = button_widget_leave_notify;
-
- button_class->activate = button_widget_activate;
-
- g_object_class_install_property (
- gobject_class,
- PROP_ACTIVATABLE,
- g_param_spec_boolean ("activatable",
- "Activatable",
- "Whether the button is activatable",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- gobject_class,
- PROP_IGNORE_LEAVE,
- g_param_spec_boolean ("ignore-leave",
- "Ignore leaving to not unhighlight the icon",
- "Whether or not to unhighlight the icon when the cursor leaves it",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_HAS_ARROW,
- g_param_spec_boolean ("has-arrow",
- "Has Arrow",
- "Whether or not to draw an arrow indicator",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_DND_HIGHLIGHT,
- g_param_spec_boolean ("dnd-highlight",
- "Drag and drop Highlight",
- "Whether or not to highlight the icon during drag and drop",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_ORIENTATION,
- g_param_spec_enum ("orientation",
- "Orientation",
- "The ButtonWidget orientation",
- PANEL_TYPE_ORIENTATION,
- PANEL_ORIENTATION_TOP,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- gobject_class,
- PROP_ICON_NAME,
- g_param_spec_string ("icon-name",
- "Icon Name",
- "The desired icon for the ButtonWidget",
- NULL,
- G_PARAM_READWRITE));
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ GtkButtonClass *button_class = (GtkButtonClass *) klass;
+
+ gobject_class->finalize = button_widget_finalize;
+ gobject_class->get_property = button_widget_get_property;
+ gobject_class->set_property = button_widget_set_property;
+
+ widget_class->realize = button_widget_realize;
+ widget_class->unrealize = button_widget_unrealize;
+ widget_class->size_allocate = button_widget_size_allocate;
+ widget_class->get_preferred_width = button_widget_get_preferred_width;
+ widget_class->get_preferred_height = button_widget_get_preferred_height;
+ widget_class->draw = button_widget_draw;
+ widget_class->button_press_event = button_widget_button_press;
+ widget_class->enter_notify_event = button_widget_enter_notify;
+ widget_class->leave_notify_event = button_widget_leave_notify;
+
+ button_class->activate = button_widget_activate;
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_ACTIVATABLE,
+ g_param_spec_boolean ("activatable",
+ "Activatable",
+ "Whether the button is activatable",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_IGNORE_LEAVE,
+ g_param_spec_boolean ("ignore-leave",
+ "Ignore leaving to not unhighlight the icon",
+ "Whether or not to unhighlight the icon when the cursor leaves it",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_HAS_ARROW,
+ g_param_spec_boolean ("has-arrow",
+ "Has Arrow",
+ "Whether or not to draw an arrow indicator",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_DND_HIGHLIGHT,
+ g_param_spec_boolean ("dnd-highlight",
+ "Drag and drop Highlight",
+ "Whether or not to highlight the icon during drag and drop",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_ORIENTATION,
+ g_param_spec_enum ("orientation",
+ "Orientation",
+ "The ButtonWidget orientation",
+ PANEL_TYPE_ORIENTATION,
+ PANEL_ORIENTATION_TOP,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
+ PROP_ICON_NAME,
+ g_param_spec_string ("icon-name",
+ "Icon Name",
+ "The desired icon for the ButtonWidget",
+ NULL,
+ G_PARAM_READWRITE));
}
GtkWidget *
button_widget_new (const char *filename,
- gboolean arrow,
- PanelOrientation orientation)
+ gboolean arrow,
+ PanelOrientation orientation)
{
- GtkWidget *retval;
+ GtkWidget *retval;
- retval = g_object_new (
- BUTTON_TYPE_WIDGET,
- "has-arrow", arrow,
- "orientation", orientation,
- "icon-name", filename,
- NULL);
+ retval = g_object_new (BUTTON_TYPE_WIDGET,
+ "has-arrow", arrow,
+ "orientation", orientation,
+ "icon-name", filename,
+ NULL);
- return retval;
+ return retval;
}
void
button_widget_set_activatable (ButtonWidget *button,
- gboolean activatable)
+ gboolean activatable)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
- activatable = activatable != FALSE;
+ activatable = activatable != FALSE;
- if (button->priv->activatable != activatable) {
- button->priv->activatable = activatable;
+ if (button->priv->activatable != activatable) {
+ button->priv->activatable = (activatable != FALSE);
- if (gtk_widget_is_drawable (GTK_WIDGET (button)))
- gtk_widget_queue_draw (GTK_WIDGET (button));
+ if (gtk_widget_is_drawable (GTK_WIDGET (button)))
+ gtk_widget_queue_draw (GTK_WIDGET (button));
- g_object_notify (G_OBJECT (button), "activatable");
- }
+ g_object_notify (G_OBJECT (button), "activatable");
+ }
}
gboolean
button_widget_get_activatable (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
- return button->priv->activatable;
+ return button->priv->activatable;
}
void
button_widget_set_icon_name (ButtonWidget *button,
- const char *icon_name)
+ const char *icon_name)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
+
+ if (button->priv->filename && icon_name &&
+ !strcmp (button->priv->filename, icon_name))
+ return;
- if (button->priv->filename && icon_name &&
- !strcmp (button->priv->filename, icon_name))
- return;
+ if (button->priv->filename)
+ g_free (button->priv->filename);
- if (button->priv->filename)
- g_free (button->priv->filename);
- button->priv->filename = g_strdup (icon_name);
+ button->priv->filename = g_strdup (icon_name);
- button_widget_reload_surface (button);
+ button_widget_reload_surface (button);
- g_object_notify (G_OBJECT (button), "icon-name");
+ g_object_notify (G_OBJECT (button), "icon-name");
}
const char *
button_widget_get_icon_name (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
- return button->priv->filename;
+ return button->priv->filename;
}
void
button_widget_set_orientation (ButtonWidget *button,
- PanelOrientation orientation)
+ PanelOrientation orientation)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
- if (button->priv->orientation == orientation)
- return;
+ if (button->priv->orientation == orientation)
+ return;
- button->priv->orientation = orientation;
+ button->priv->orientation = orientation;
- /* Force a re-scale */
- button->priv->size = -1;
+ /* Force a re-scale */
+ button->priv->size = -1;
- gtk_widget_queue_resize (GTK_WIDGET (button));
+ gtk_widget_queue_resize (GTK_WIDGET (button));
- g_object_notify (G_OBJECT (button), "orientation");
+ g_object_notify (G_OBJECT (button), "orientation");
}
PanelOrientation
button_widget_get_orientation (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), 0);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), 0);
- return button->priv->orientation;
+ return button->priv->orientation;
}
void
button_widget_set_has_arrow (ButtonWidget *button,
- gboolean has_arrow)
+ gboolean has_arrow)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
- has_arrow = has_arrow != FALSE;
+ has_arrow = has_arrow != FALSE;
- if (button->priv->arrow == has_arrow)
- return;
+ if (button->priv->arrow == has_arrow)
+ return;
- button->priv->arrow = has_arrow;
+ button->priv->arrow = (has_arrow != FALSE);
- gtk_widget_queue_draw (GTK_WIDGET (button));
+ gtk_widget_queue_draw (GTK_WIDGET (button));
- g_object_notify (G_OBJECT (button), "has-arrow");
+ g_object_notify (G_OBJECT (button), "has-arrow");
}
gboolean
button_widget_get_has_arrow (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
- return button->priv->arrow;
+ return button->priv->arrow;
}
void
button_widget_set_dnd_highlight (ButtonWidget *button,
- gboolean dnd_highlight)
+ gboolean dnd_highlight)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
- dnd_highlight = dnd_highlight != FALSE;
+ dnd_highlight = dnd_highlight != FALSE;
- if (button->priv->dnd_highlight == dnd_highlight)
- return;
+ if (button->priv->dnd_highlight == dnd_highlight)
+ return;
- button->priv->dnd_highlight = dnd_highlight;
+ button->priv->dnd_highlight = (dnd_highlight != FALSE);
- gtk_widget_queue_draw (GTK_WIDGET (button));
+ gtk_widget_queue_draw (GTK_WIDGET (button));
- g_object_notify (G_OBJECT (button), "dnd-highlight");
+ g_object_notify (G_OBJECT (button), "dnd-highlight");
}
gboolean
button_widget_get_dnd_highlight (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
- return button->priv->dnd_highlight;
+ return button->priv->dnd_highlight;
}
void
button_widget_set_ignore_leave (ButtonWidget *button,
- gboolean ignore_leave)
+ gboolean ignore_leave)
{
- g_return_if_fail (BUTTON_IS_WIDGET (button));
+ g_return_if_fail (BUTTON_IS_WIDGET (button));
- ignore_leave = ignore_leave != FALSE;
+ ignore_leave = ignore_leave != FALSE;
- if (button->priv->ignore_leave == ignore_leave)
- return;
+ if (button->priv->ignore_leave == ignore_leave)
+ return;
- button->priv->ignore_leave = ignore_leave;
+ button->priv->ignore_leave = (ignore_leave != FALSE);
- gtk_widget_queue_draw (GTK_WIDGET (button));
+ gtk_widget_queue_draw (GTK_WIDGET (button));
- g_object_notify (G_OBJECT (button), "ignore-leave");
+ g_object_notify (G_OBJECT (button), "ignore-leave");
}
gboolean
button_widget_get_ignore_leave (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), FALSE);
- return button->priv->ignore_leave;
+ return button->priv->ignore_leave;
}
GtkIconTheme *
button_widget_get_icon_theme (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
- return button->priv->icon_theme;
+ return button->priv->icon_theme;
}
cairo_surface_t *
button_widget_get_surface (ButtonWidget *button)
{
- g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
+ g_return_val_if_fail (BUTTON_IS_WIDGET (button), NULL);
- if (!button->priv->surface)
- return NULL;
+ if (!button->priv->surface)
+ return NULL;
- return cairo_surface_reference (button->priv->surface);
+ return cairo_surface_reference (button->priv->surface);
}
diff --git a/mate-panel/button-widget.h b/mate-panel/button-widget.h
index 372c33b9..7bde482b 100644
--- a/mate-panel/button-widget.h
+++ b/mate-panel/button-widget.h
@@ -8,47 +8,47 @@
extern "C" {
#endif
-#define BUTTON_TYPE_WIDGET (button_widget_get_type ())
-#define BUTTON_WIDGET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BUTTON_TYPE_WIDGET, ButtonWidget))
-#define BUTTON_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass, BUTTON_TYPE_WIDGET, ButtonWidgetClass))
-#define BUTTON_IS_WIDGET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BUTTON_TYPE_WIDGET))
-#define BUTTON_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUTTON_TYPE_WIDGET))
+#define BUTTON_TYPE_WIDGET (button_widget_get_type ())
+#define BUTTON_WIDGET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BUTTON_TYPE_WIDGET, ButtonWidget))
+#define BUTTON_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass, BUTTON_TYPE_WIDGET, ButtonWidgetClass))
+#define BUTTON_IS_WIDGET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BUTTON_TYPE_WIDGET))
+#define BUTTON_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUTTON_TYPE_WIDGET))
-typedef struct _ButtonWidget ButtonWidget;
-typedef struct _ButtonWidgetClass ButtonWidgetClass;
-typedef struct _ButtonWidgetPrivate ButtonWidgetPrivate;
+typedef struct _ButtonWidget ButtonWidget;
+typedef struct _ButtonWidgetClass ButtonWidgetClass;
+typedef struct _ButtonWidgetPrivate ButtonWidgetPrivate;
struct _ButtonWidget {
- GtkButton parent;
+ GtkButton parent;
- ButtonWidgetPrivate *priv;
+ ButtonWidgetPrivate *priv;
};
struct _ButtonWidgetClass {
- GtkButtonClass parent_class;
+ GtkButtonClass parent_class;
};
-GType button_widget_get_type (void) G_GNUC_CONST;
+GType button_widget_get_type (void) G_GNUC_CONST;
GtkWidget * button_widget_new (const char *pixmap,
- gboolean arrow,
- PanelOrientation orientation);
+ gboolean arrow,
+ PanelOrientation orientation);
void button_widget_set_activatable (ButtonWidget *button,
- gboolean activatable);
+ gboolean activatable);
gboolean button_widget_get_activatable (ButtonWidget *button);
void button_widget_set_icon_name (ButtonWidget *button,
- const char *icon_name);
+ const char *icon_name);
const char * button_widget_get_icon_name (ButtonWidget *button);
void button_widget_set_orientation (ButtonWidget *button,
- PanelOrientation orientation);
+ PanelOrientation orientation);
PanelOrientation button_widget_get_orientation (ButtonWidget *button);
void button_widget_set_has_arrow (ButtonWidget *button,
- gboolean has_arrow);
+ gboolean has_arrow);
gboolean button_widget_get_has_arrow (ButtonWidget *button);
void button_widget_set_dnd_highlight (ButtonWidget *button,
- gboolean dnd_highlight);
+ gboolean dnd_highlight);
gboolean button_widget_get_dnd_highlight (ButtonWidget *button);
void button_widget_set_ignore_leave (ButtonWidget *button,
- gboolean ignore_leave);
+ gboolean ignore_leave);
gboolean button_widget_get_ignore_leave (ButtonWidget *button);
GtkIconTheme *button_widget_get_icon_theme (ButtonWidget *button);
cairo_surface_t *button_widget_get_surface (ButtonWidget *button);
diff --git a/mate-panel/drawer-private.h b/mate-panel/drawer-private.h
index 67db7353..b8db81f8 100644
--- a/mate-panel/drawer-private.h
+++ b/mate-panel/drawer-private.h
@@ -1,5 +1,6 @@
/*
* MATE panel drawer module.
+ * Copyright (C) 2012-2021 MATE Developers
*
* List static function prototypes separate
* to prevent errors when compiling panel.c
@@ -7,7 +8,6 @@
* Authors: [email protected]
*/
-
#ifndef DRAWER_PRIVATE_H
#define DRAWER_PRIVATE_H
@@ -15,7 +15,6 @@
extern "C" {
#endif
-
/* Internal functions */
/* event handlers */
@@ -138,7 +137,6 @@ static void panel_drawer_prepare (const char *drawer_id,
const char *tooltip,
char **attached_toplevel_id);
-
#ifdef __cplusplus
}
#endif
diff --git a/mate-panel/drawer.c b/mate-panel/drawer.c
index a59cf6e8..03d6bd5f 100644
--- a/mate-panel/drawer.c
+++ b/mate-panel/drawer.c
@@ -1,13 +1,13 @@
/*
* MATE panel drawer module.
* (C) 1997 The Free Software Foundation
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Miguel de Icaza
* Federico Mena
* George Lebl
*/
-
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
@@ -34,11 +34,9 @@
#include "panel-icon-names.h"
#include "panel-schemas.h"
-
/* Internal functions */
/* event handlers */
-
static void
drawer_click (GtkWidget *widget,
Drawer *drawer)
@@ -445,18 +443,16 @@ create_drawer_applet (PanelToplevel *toplevel,
set_tooltip_and_name (drawer, tooltip);
g_signal_connect (drawer->button, "clicked", G_CALLBACK (drawer_click), drawer);
- g_signal_connect (drawer->button, "key_press_event", G_CALLBACK (key_press_drawer), drawer);
- g_signal_connect (drawer->toplevel, "key_press_event", G_CALLBACK (key_press_drawer_widget), drawer);
-
+ g_signal_connect (drawer->button, "key-press-event", G_CALLBACK (key_press_drawer), drawer);
+ g_signal_connect (drawer->toplevel, "key-press-event", G_CALLBACK (key_press_drawer_widget), drawer);
gtk_drag_dest_set (drawer->button, 0, NULL, 0, 0);
- g_signal_connect (drawer->button, "drag_data_get", G_CALLBACK (drag_data_get_cb), drawer);
- g_signal_connect (drawer->button, "drag_motion", G_CALLBACK (drag_motion_cb), drawer);
- g_signal_connect (drawer->button, "drag_drop", G_CALLBACK (drag_drop_cb), drawer);
- g_signal_connect (drawer->button, "drag_data_received", G_CALLBACK (drag_data_received_cb), drawer);
- g_signal_connect (drawer->button, "drag_leave", G_CALLBACK (drag_leave_cb), drawer);
-
+ g_signal_connect (drawer->button, "drag-data-get", G_CALLBACK (drag_data_get_cb), drawer);
+ g_signal_connect (drawer->button, "drag-motion", G_CALLBACK (drag_motion_cb), drawer);
+ g_signal_connect (drawer->button, "drag-drop", G_CALLBACK (drag_drop_cb), drawer);
+ g_signal_connect (drawer->button, "drag-data-received", G_CALLBACK (drag_data_received_cb), drawer);
+ g_signal_connect (drawer->button, "drag-leave", G_CALLBACK (drag_leave_cb), drawer);
g_signal_connect (drawer->button, "destroy", G_CALLBACK (destroy_drawer), drawer);
g_signal_connect (drawer->toplevel, "destroy", G_CALLBACK (toplevel_destroyed), drawer);
@@ -538,7 +534,7 @@ load_drawer_applet (char *toplevel_id,
return;
}
- g_signal_connect_after (drawer->button, "size_allocate", G_CALLBACK (drawer_button_size_allocated), drawer);
+ g_signal_connect_after (drawer->button, "size-allocate", G_CALLBACK (drawer_button_size_allocated), drawer);
panel_widget_add_forbidden (panel_toplevel_get_panel_widget (drawer->toplevel));
panel_widget_set_applet_expandable (panel_widget, GTK_WIDGET (drawer->button), FALSE, TRUE);
diff --git a/mate-panel/drawer.h b/mate-panel/drawer.h
index 891b8dd7..04fcd0a1 100644
--- a/mate-panel/drawer.h
+++ b/mate-panel/drawer.h
@@ -7,7 +7,6 @@
extern "C" {
#endif
-
typedef struct {
char *tooltip;
@@ -20,7 +19,6 @@ typedef struct {
AppletInfo *info;
} Drawer;
-
/* API */
void panel_drawer_create (PanelToplevel *toplevel,
@@ -45,7 +43,6 @@ void panel_drawer_set_dnd_enabled (Drawer *drawer,
void drawer_query_deletion (Drawer *drawer);
-
#ifdef __cplusplus
}
#endif
diff --git a/mate-panel/launcher.c b/mate-panel/launcher.c
index ad2c147b..0385ccea 100644
--- a/mate-panel/launcher.c
+++ b/mate-panel/launcher.c
@@ -2,6 +2,7 @@
* MATE panel launcher module.
* (C) 1997,1998,1999,2000 The Free Software Foundation
* (C) 2000 Eazel, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Miguel de Icaza
* Federico Mena
@@ -250,11 +251,11 @@ free_launcher (gpointer data)
if (launcher->key_file)
g_key_file_free (launcher->key_file);
- launcher->key_file = NULL;
- if (launcher->location != NULL)
- g_free (launcher->location);
- launcher->location = NULL;
+ g_free (launcher->location);
+
+ if (launcher->monitor != NULL)
+ g_object_unref (launcher->monitor);
g_free (launcher);
}
@@ -323,7 +324,6 @@ drag_leave_cb(GtkWidget *widget,
button_widget_set_dnd_highlight(BUTTON_WIDGET(widget), FALSE);
}
-
static gboolean
drag_motion_cb(GtkWidget *widget,
GdkDragContext *context,
@@ -368,7 +368,6 @@ enum {
TARGET_URI_LIST
};
-
static void
drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
@@ -442,6 +441,7 @@ static Launcher *
create_launcher (const char *location)
{
GKeyFile *key_file;
+ g_autoptr(GFile) file = NULL;
gboolean loaded = FALSE;
Launcher *launcher;
GError *error = NULL;
@@ -501,6 +501,7 @@ create_launcher (const char *location)
if (!new_location)
new_location = g_strdup (location);
+ file = g_file_new_for_path (new_location);
launcher = g_new0 (Launcher, 1);
@@ -516,6 +517,10 @@ create_launcher (const char *location)
FALSE,
PANEL_ORIENTATION_TOP);
+ launcher->monitor = g_file_monitor_file (file,
+ G_FILE_MONITOR_NONE,
+ NULL,
+ NULL);
gtk_widget_show (launcher->button);
/*gtk_drag_dest_set (GTK_WIDGET (launcher->button),
@@ -525,15 +530,15 @@ create_launcher (const char *location)
gtk_drag_dest_set (GTK_WIDGET (launcher->button),
0, NULL, 0, 0);
- g_signal_connect (launcher->button, "drag_data_get",
+ g_signal_connect (launcher->button, "drag-data-get",
G_CALLBACK (drag_data_get_cb), launcher);
- g_signal_connect (launcher->button, "drag_data_received",
+ g_signal_connect (launcher->button, "drag-data-received",
G_CALLBACK (drag_data_received_cb), launcher);
- g_signal_connect (launcher->button, "drag_motion",
+ g_signal_connect (launcher->button, "drag-motion",
G_CALLBACK (drag_motion_cb), launcher);
- g_signal_connect (launcher->button, "drag_drop",
+ g_signal_connect (launcher->button, "drag-drop",
G_CALLBACK (drag_drop_cb), launcher);
- g_signal_connect (launcher->button, "drag_leave",
+ g_signal_connect (launcher->button, "drag-leave",
G_CALLBACK (drag_leave_cb), launcher);
g_signal_connect_swapped (launcher->button, "clicked",
G_CALLBACK (clicked_cb), launcher);
@@ -614,7 +619,6 @@ setup_button (Launcher *launcher)
else
str = g_strdup (comment);
-
/* If we can unescape the string, then we probably have an escaped
* string (a location e.g.). If we can't, then it most probably means
* we have a % that is not here to encode a character, and we don't
@@ -634,10 +638,8 @@ setup_button (Launcher *launcher)
/* Setup icon */
icon = panel_key_file_get_locale_string (launcher->key_file, "Icon");
- if (icon && icon[0] == '\0') {
- g_free (icon);
- icon = NULL;
- }
+ if (icon && icon[0] == '\0')
+ g_clear_pointer (&icon, g_free);
if (!icon) {
gchar *exec;
@@ -819,13 +821,13 @@ launcher_properties (Launcher *launcher)
g_signal_connect (launcher->prop_dialog, "changed",
G_CALLBACK (launcher_changed), launcher);
- g_signal_connect (launcher->prop_dialog, "command_changed",
+ g_signal_connect (launcher->prop_dialog, "command-changed",
G_CALLBACK (launcher_command_changed), launcher);
g_signal_connect (launcher->prop_dialog, "saved",
G_CALLBACK (launcher_saved), launcher);
- g_signal_connect (launcher->prop_dialog, "error_reported",
+ g_signal_connect (launcher->prop_dialog, "error-reported",
G_CALLBACK (launcher_error_reported), NULL);
g_signal_connect (launcher->prop_dialog, "destroy",
@@ -845,6 +847,34 @@ launcher_properties_enabled (void)
return TRUE;
}
+static void
+app_desktop_file_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ Launcher *launcher)
+{
+ if (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
+ event_type != G_FILE_MONITOR_EVENT_CREATED)
+ {
+ return;
+ }
+
+ if (!strchr (launcher->location, G_DIR_SEPARATOR))
+ {
+ g_key_file_load_from_file (launcher->key_file, launcher->location,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ NULL);
+ }
+ else
+ {
+ panel_key_file_load_from_uri (launcher->key_file, launcher->location,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ NULL);
+ }
+ setup_button (launcher);
+}
+
static Launcher *
load_launcher_applet (const char *location,
PanelWidget *panel,
@@ -872,6 +902,11 @@ load_launcher_applet (const char *location,
panel_widget_set_applet_expandable (panel, GTK_WIDGET (launcher->button), FALSE, TRUE);
panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (launcher->button), TRUE);
+ g_signal_connect (launcher->monitor,
+ "changed",
+ G_CALLBACK (app_desktop_file_changed),
+ launcher);
+
/* setup button according to ditem */
setup_button (launcher);
@@ -976,11 +1011,13 @@ ask_about_launcher (const char *file,
launcher_save_uri,
NULL);
- g_signal_connect (G_OBJECT (dialog), "saved",
- G_CALLBACK (launcher_new_saved), NULL);
+ g_signal_connect (dialog, "saved",
+ G_CALLBACK (launcher_new_saved),
+ NULL);
- g_signal_connect (G_OBJECT (dialog), "error_reported",
- G_CALLBACK (launcher_error_reported), NULL);
+ g_signal_connect (dialog, "error-reported",
+ G_CALLBACK (launcher_error_reported),
+ NULL);
gtk_window_set_screen (GTK_WINDOW (dialog),
gtk_widget_get_screen (GTK_WIDGET (panel)));
diff --git a/mate-panel/launcher.h b/mate-panel/launcher.h
index 2d3594bb..8cfd50b9 100644
--- a/mate-panel/launcher.h
+++ b/mate-panel/launcher.h
@@ -1,6 +1,7 @@
/*
* MATE panel launcher module.
* (C) 1997 The Free Software Foundation
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Miguel de Icaza
* Federico Mena
@@ -25,6 +26,7 @@ typedef struct {
char *location;
GKeyFile *key_file;
+ GFileMonitor *monitor;
GtkWidget *prop_dialog;
GSList *error_dialogs;
@@ -72,7 +74,6 @@ void launcher_properties_destroy (Launcher *launcher);
void panel_launcher_set_dnd_enabled (Launcher *launcher,
gboolean dnd_enabled);
-
#ifdef __cplusplus
}
#endif
diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-container.c b/mate-panel/libmate-panel-applet-private/panel-applet-container.c
index 9354b999..bd2269e9 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applet-container.c
+++ b/mate-panel/libmate-panel-applet-private/panel-applet-container.c
@@ -2,6 +2,7 @@
* panel-applet-container.c: a container for applets.
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -160,25 +161,15 @@ mate_panel_applet_container_dispose (GObject *object)
container->priv->pending_ops = NULL;
}
- if (container->priv->bus_name) {
- g_free (container->priv->bus_name);
- container->priv->bus_name = NULL;
- }
-
- if (container->priv->iid) {
- g_free (container->priv->iid);
- container->priv->iid = NULL;
- }
+ g_clear_pointer (&container->priv->bus_name, g_free);
+ g_clear_pointer (&container->priv->iid, g_free);
if (container->priv->name_watcher_id > 0) {
g_bus_unwatch_name (container->priv->name_watcher_id);
container->priv->name_watcher_id = 0;
}
- if (container->priv->applet_proxy) {
- g_object_unref (container->priv->applet_proxy);
- container->priv->applet_proxy = NULL;
- }
+ g_clear_object (&container->priv->applet_proxy);
G_OBJECT_CLASS (mate_panel_applet_container_parent_class)->dispose (object);
}
@@ -247,7 +238,7 @@ mate_panel_applet_container_class_init (MatePanelAppletContainerClass *klass)
static const AppletPropertyInfo *
mate_panel_applet_container_child_property_get_info (const gchar *property_name)
{
- gint i;
+ gsize i;
g_assert (property_name != NULL);
@@ -352,23 +343,20 @@ on_proxy_appeared (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GTask *task = G_TASK (user_data);
MatePanelAppletContainer *container;
GDBusProxy *proxy;
GError *error = NULL;
proxy = g_dbus_proxy_new_finish (res, &error);
if (!proxy) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ g_task_return_error (task, error);
+ g_object_unref (task);
return;
}
- container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
-
+ container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
container->priv->applet_proxy = proxy;
g_signal_connect (container->priv->applet_proxy, "g-signal",
G_CALLBACK (mate_panel_applet_container_child_signal),
@@ -383,8 +371,8 @@ on_proxy_appeared (GObject *source_object,
(GDBusSignalCallback) on_property_changed,
container, NULL);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ g_task_return_boolean (task,TRUE);
+ g_object_unref (task);
panel_applet_container_setup (container);
@@ -406,7 +394,7 @@ get_applet_cb (GObject *source_object,
gpointer user_data)
{
GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GTask *task = G_TASK (user_data);
MatePanelAppletContainer *container;
GVariant *retvals;
const gchar *applet_path;
@@ -414,15 +402,13 @@ get_applet_cb (GObject *source_object,
retvals = g_dbus_connection_call_finish (connection, res, &error);
if (!retvals) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ g_task_return_error (task, error);
+ g_object_unref (task);
return;
}
- container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
g_variant_get (retvals,
"(&obuu)",
&applet_path,
@@ -438,7 +424,7 @@ get_applet_cb (GObject *source_object,
MATE_PANEL_APPLET_INTERFACE,
NULL,
(GAsyncReadyCallback) on_proxy_appeared,
- result);
+ task);
g_variant_unref (retvals);
@@ -447,7 +433,6 @@ get_applet_cb (GObject *source_object,
}
typedef struct {
- GSimpleAsyncResult *result;
gchar *factory_id;
GVariant *parameters;
GCancellable *cancellable;
@@ -467,12 +452,14 @@ static void
on_factory_appeared (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
- AppletFactoryData *data)
+ GTask *task)
{
MatePanelAppletContainer *container;
gchar *object_path;
+ AppletFactoryData *data;
- container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (data->result)));
+ data = g_task_get_task_data (task);
+ container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
container->priv->bus_name = g_strdup (name_owner);
object_path = g_strdup_printf (MATE_PANEL_APPLET_FACTORY_OBJECT_PATH, data->factory_id);
g_dbus_connection_call (connection,
@@ -486,7 +473,7 @@ on_factory_appeared (GDBusConnection *connection,
-1,
data->cancellable,
get_applet_cb,
- data->result);
+ task);
g_free (object_path);
}
@@ -499,27 +486,25 @@ mate_panel_applet_container_get_applet (MatePanelAppletContainer *container,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *result;
+ GTask *task;
AppletFactoryData *data;
gint screen_number;
gchar *bus_name;
gchar *factory_id;
gchar *applet_id;
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- mate_panel_applet_container_get_applet);
-
+ task = g_task_new (G_OBJECT (container),
+ cancellable,
+ callback,
+ user_data);
+ g_task_set_source_tag (task,mate_panel_applet_container_get_applet);
applet_id = g_strrstr (iid, "::");
- if (!applet_id) {
- g_simple_async_result_set_error (result,
- MATE_PANEL_APPLET_CONTAINER_ERROR,
- MATE_PANEL_APPLET_CONTAINER_INVALID_APPLET,
- "Invalid applet iid: %s", iid);
- g_simple_async_result_complete (result);
- g_object_unref (result);
-
+ if (!applet_id) {
+ g_task_return_new_error (task,
+ MATE_PANEL_APPLET_CONTAINER_ERROR,
+ MATE_PANEL_APPLET_CONTAINER_INVALID_APPLET,
+ "Invalid applet iid: %s", iid);
+ g_object_unref (task);
return;
}
@@ -538,11 +523,10 @@ mate_panel_applet_container_get_applet (MatePanelAppletContainer *container,
}
data = g_new (AppletFactoryData, 1);
- data->result = result;
data->factory_id = factory_id;
data->parameters = g_variant_new ("(si*)", applet_id, screen_number, props);
data->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
-
+ g_task_set_task_data (task,data,(GDestroyNotify) applet_factory_data_free);
bus_name = g_strdup_printf (MATE_PANEL_APPLET_BUS_NAME, factory_id);
container->priv->iid = g_strdup (iid);
@@ -552,8 +536,8 @@ mate_panel_applet_container_get_applet (MatePanelAppletContainer *container,
G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
(GBusNameAppearedCallback) on_factory_appeared,
NULL,
- data,
- (GDestroyNotify) applet_factory_data_free);
+ task,
+ NULL);
g_free (bus_name);
}
@@ -581,11 +565,9 @@ mate_panel_applet_container_add_finish (MatePanelAppletContainer *container,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_get_applet);
-
- return !g_simple_async_result_propagate_error (simple, error);
+ g_return_val_if_fail (g_task_is_valid (result, container), FALSE);
+ g_warn_if_fail (g_task_get_source_tag (G_TASK (result)) == mate_panel_applet_container_get_applet);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
/* Child Properties */
@@ -595,7 +577,7 @@ set_applet_property_cb (GObject *source_object,
gpointer user_data)
{
GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GTask *task = G_TASK (user_data);
MatePanelAppletContainer *container;
GVariant *retvals;
GError *error = NULL;
@@ -604,16 +586,16 @@ set_applet_property_cb (GObject *source_object,
if (!retvals) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Error setting property: %s\n", error->message);
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
+ g_task_return_error (task, error);
+ return;
} else {
g_variant_unref (retvals);
}
- container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
- g_hash_table_remove (container->priv->pending_ops, result);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
+ g_hash_table_remove (container->priv->pending_ops, task);
+ g_task_return_boolean (task,TRUE);
+ g_object_unref (task);
/* g_async_result_get_source_object returns new ref */
g_object_unref (container);
@@ -629,32 +611,33 @@ mate_panel_applet_container_child_set (MatePanelAppletContainer *container,
{
GDBusProxy *proxy = container->priv->applet_proxy;
const AppletPropertyInfo *info;
- GSimpleAsyncResult *result;
-
+ GTask *task;
if (!proxy)
return NULL;
info = mate_panel_applet_container_child_property_get_info (property_name);
if (!info) {
- g_simple_async_report_error_in_idle (G_OBJECT (container),
- callback, user_data,
- MATE_PANEL_APPLET_CONTAINER_ERROR,
- MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
- "%s: Applet has no child property named `%s'",
- G_STRLOC, property_name);
+ g_task_report_new_error (G_OBJECT (container),
+ callback, user_data,
+ NULL,
+ MATE_PANEL_APPLET_CONTAINER_ERROR,
+ MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
return NULL;
}
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- mate_panel_applet_container_child_set);
+ task = g_task_new (G_OBJECT (container),
+ cancellable,
+ callback,
+ user_data);
+ g_task_set_source_tag (task,mate_panel_applet_container_child_set);
if (cancellable)
g_object_ref (cancellable);
else
cancellable = g_cancellable_new ();
- g_hash_table_insert (container->priv->pending_ops, result, cancellable);
+ g_hash_table_insert (container->priv->pending_ops, task, cancellable);
g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
g_dbus_proxy_get_name (proxy),
@@ -669,9 +652,9 @@ mate_panel_applet_container_child_set (MatePanelAppletContainer *container,
G_DBUS_CALL_FLAGS_NO_AUTO_START,
-1, cancellable,
set_applet_property_cb,
- result);
+ task);
- return result;
+ return task;
}
gboolean
@@ -679,11 +662,9 @@ mate_panel_applet_container_child_set_finish (MatePanelAppletContainer *containe
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_set);
-
- return !g_simple_async_result_propagate_error (simple, error);
+ g_return_val_if_fail (g_task_is_valid (result, container), FALSE);
+ g_warn_if_fail (g_task_get_source_tag (G_TASK (result)) == mate_panel_applet_container_child_set);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static void
@@ -692,34 +673,30 @@ get_applet_property_cb (GObject *source_object,
gpointer user_data)
{
GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GTask *task = G_TASK (user_data);
MatePanelAppletContainer *container;
GVariant *retvals;
+ GVariant *value, *item;
GError *error = NULL;
retvals = g_dbus_connection_call_finish (connection, res, &error);
if (!retvals) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Error getting property: %s\n", error->message);
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- } else {
- GVariant *value, *item;
-
- item = g_variant_get_child_value (retvals, 0);
- value = g_variant_get_variant (item);
- g_variant_unref (item);
- g_simple_async_result_set_op_res_gpointer (result, value,
- (GDestroyNotify) g_variant_unref);
- g_variant_unref (retvals);
+ g_task_return_error (task, error);
+ return;
}
- container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
- g_hash_table_remove (container->priv->pending_ops, result);
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ item = g_variant_get_child_value (retvals, 0);
+ value = g_variant_get_variant (item);
+ g_variant_unref (item);
+ g_variant_unref (retvals);
+
+ container = MATE_PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (task)));
+ g_hash_table_remove (container->priv->pending_ops, task);
+ g_task_return_pointer (task,value,(GDestroyNotify) g_variant_unref);
+ g_object_unref (task);
- /* g_async_result_get_source_object returns new ref */
g_object_unref (container);
}
@@ -732,31 +709,27 @@ mate_panel_applet_container_child_get (MatePanelAppletContainer *container,
{
GDBusProxy *proxy = container->priv->applet_proxy;
const AppletPropertyInfo *info;
- GSimpleAsyncResult *result;
+ GTask *task;
if (!proxy)
return NULL;
info = mate_panel_applet_container_child_property_get_info (property_name);
if (!info) {
- g_simple_async_report_error_in_idle (G_OBJECT (container),
- callback, user_data,
- MATE_PANEL_APPLET_CONTAINER_ERROR,
- MATE_PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
- "%s: Applet has no child property named `%s'",
- G_STRLOC, property_name);
+ g_warning ("mate_panel_applet_container_child_get error");
return NULL;
}
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- mate_panel_applet_container_child_get);
+ task = g_task_new (G_OBJECT (container),
+ cancellable,
+ callback,
+ user_data);
+ g_task_set_source_tag (task,mate_panel_applet_container_child_get);
if (cancellable)
g_object_ref (cancellable);
else
cancellable = g_cancellable_new ();
- g_hash_table_insert (container->priv->pending_ops, result, cancellable);
+ g_hash_table_insert (container->priv->pending_ops, task, cancellable);
g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
g_dbus_proxy_get_name (proxy),
@@ -770,9 +743,9 @@ mate_panel_applet_container_child_get (MatePanelAppletContainer *container,
G_DBUS_CALL_FLAGS_NO_AUTO_START,
-1, cancellable,
get_applet_property_cb,
- result);
+ task);
- return result;
+ return task;
}
GVariant *
@@ -780,14 +753,10 @@ mate_panel_applet_container_child_get_finish (MatePanelAppletContainer *containe
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ g_return_val_if_fail (g_task_is_valid (result, container), NULL);
+ g_warn_if_fail (g_task_get_source_tag (G_TASK (result)) == mate_panel_applet_container_child_get);
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_get);
-
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
-
- return g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple));
+ return g_variant_ref (g_task_propagate_pointer (G_TASK (result), error));
}
static void
@@ -796,20 +765,20 @@ child_popup_menu_cb (GObject *source_object,
gpointer user_data)
{
GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
- GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ GTask *task = G_TASK (user_data);
GVariant *retvals;
GError *error = NULL;
retvals = g_dbus_connection_call_finish (connection, res, &error);
if (!retvals) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
+ g_task_return_error (task, error);
+ return;
} else {
g_variant_unref (retvals);
+ g_task_return_boolean (task,TRUE);
}
- g_simple_async_result_complete (result);
- g_object_unref (result);
+ g_object_unref (task);
}
void
@@ -820,16 +789,16 @@ mate_panel_applet_container_child_popup_menu (MatePanelAppletContainer *containe
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSimpleAsyncResult *result;
+ GTask *task;
GDBusProxy *proxy = container->priv->applet_proxy;
if (!proxy)
return;
-
- result = g_simple_async_result_new (G_OBJECT (container),
- callback,
- user_data,
- mate_panel_applet_container_child_popup_menu);
+ task = g_task_new (G_OBJECT (container),
+ cancellable,
+ callback,
+ user_data);
+ g_task_set_source_tag (task,mate_panel_applet_container_child_popup_menu);
g_dbus_connection_call (g_dbus_proxy_get_connection (proxy),
g_dbus_proxy_get_name (proxy),
@@ -841,7 +810,7 @@ mate_panel_applet_container_child_popup_menu (MatePanelAppletContainer *containe
G_DBUS_CALL_FLAGS_NO_AUTO_START,
-1, cancellable,
child_popup_menu_cb,
- result);
+ task);
}
gboolean
@@ -849,11 +818,9 @@ mate_panel_applet_container_child_popup_menu_finish (MatePanelAppletContainer *c
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == mate_panel_applet_container_child_popup_menu);
-
- return !g_simple_async_result_propagate_error (simple, error);
+ g_return_val_if_fail (g_task_is_valid (result, container), FALSE);
+ g_warn_if_fail (g_task_get_source_tag (G_TASK (result)) == mate_panel_applet_container_child_popup_menu);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
void
diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-container.h b/mate-panel/libmate-panel-applet-private/panel-applet-container.h
index 63f5f078..7bd967b7 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applet-container.h
+++ b/mate-panel/libmate-panel-applet-private/panel-applet-container.h
@@ -2,6 +2,7 @@
* panel-applet-container.h: a container for applets.
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -73,7 +74,6 @@ GType mate_panel_applet_container_get_type (void) G_GNUC_CON
GQuark mate_panel_applet_container_error_quark (void) G_GNUC_CONST;
GtkWidget *mate_panel_applet_container_new (void);
-
void mate_panel_applet_container_add (MatePanelAppletContainer *container,
GdkScreen *screen,
const gchar *iid,
diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c
index c20e5cb2..99346221 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c
+++ b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.c
@@ -5,6 +5,7 @@
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -69,7 +70,7 @@ get_mate_panel_applet_orient (PanelOrientation orientation)
return 2;
default:
g_assert_not_reached ();
- break;
+ return 0;
}
}
@@ -91,7 +92,6 @@ mate_panel_applet_frame_dbus_update_flags (MatePanelAppletFrame *frame,
_mate_panel_applet_frame_update_flags (frame, major, minor, has_handle);
}
-
static void
mate_panel_applet_frame_dbus_get_flags_cb (MatePanelAppletContainer *container,
GAsyncResult *res,
diff --git a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.h b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.h
index 73da38f2..65dd4a21 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.h
+++ b/mate-panel/libmate-panel-applet-private/panel-applet-frame-dbus.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c
index 5873a4e9..b65fe4a7 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c
+++ b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -158,10 +159,9 @@ mate_panel_applets_manager_get_applet_factory_info_from_file (const gchar *filen
{
MatePanelAppletFactoryInfo *info;
GKeyFile *applet_file;
- const char *lib_prefix;
gchar **groups;
gsize n_groups;
- gint i;
+ gsize i;
GError *error = NULL;
applet_file = g_key_file_new ();
@@ -188,6 +188,8 @@ mate_panel_applets_manager_get_applet_factory_info_from_file (const gchar *filen
info->in_process = g_key_file_get_boolean (applet_file, MATE_PANEL_APPLET_FACTORY_GROUP,
"InProcess", NULL);
if (info->in_process) {
+ const char *lib_prefix;
+
info->location = g_key_file_get_string (applet_file, MATE_PANEL_APPLET_FACTORY_GROUP,
"Location", NULL);
if (!info->location) {
@@ -334,15 +336,15 @@ applets_directory_changed (GFileMonitor *monitor,
static void
mate_panel_applets_manager_dbus_load_applet_infos (MatePanelAppletsManagerDBus *manager)
{
- GSList *dirs, *d;
- GDir *dir;
- const gchar *dirent;
- GError *error = NULL;
+ GSList *dirs;
dirs = mate_panel_applets_manager_get_applets_dirs ();
- for (d = dirs; d; d = g_slist_next (d)) {
+ for (GSList *d = dirs; d; d = g_slist_next (d)) {
+ GDir *dir;
+ const gchar *dirent;
GFileMonitor *monitor;
GFile *dir_file;
+ GError *error = NULL;
gchar *path = (gchar *) d->data;
dir = g_dir_open (path, 0, &error);
diff --git a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.h b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.h
index 85ab5c53..9fb63d52 100644
--- a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.h
+++ b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-cleanup.c b/mate-panel/libpanel-util/panel-cleanup.c
index 199a7036..d615b83c 100644
--- a/mate-panel/libpanel-util/panel-cleanup.c
+++ b/mate-panel/libpanel-util/panel-cleanup.c
@@ -2,6 +2,7 @@
* panel-cleanup.c: utility to clean up things on exit
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-cleanup.h b/mate-panel/libpanel-util/panel-cleanup.h
index 9da5b828..7683c2a9 100644
--- a/mate-panel/libpanel-util/panel-cleanup.h
+++ b/mate-panel/libpanel-util/panel-cleanup.h
@@ -2,6 +2,7 @@
* panel-cleanup.h: utility to clean up things on exit
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-color.c b/mate-panel/libpanel-util/panel-color.c
index f6148aaa..15ebf686 100644
--- a/mate-panel/libpanel-util/panel-color.c
+++ b/mate-panel/libpanel-util/panel-color.c
@@ -17,7 +17,6 @@ rgb_to_hls (gdouble *r, gdouble *g, gdouble *b)
gdouble green;
gdouble blue;
gdouble h, l, s;
- gdouble delta;
red = *r;
green = *g;
@@ -50,6 +49,8 @@ rgb_to_hls (gdouble *r, gdouble *g, gdouble *b)
h = 0;
if (max != min) {
+ gdouble delta;
+
if (l <= 0.5)
s = (max - min) / (max + min);
else
@@ -84,26 +85,27 @@ rgb_to_hls (gdouble *r, gdouble *g, gdouble *b)
static void
hls_to_rgb (gdouble *h, gdouble *l, gdouble *s)
{
- gdouble hue;
gdouble lightness;
gdouble saturation;
- gdouble m1, m2;
- gdouble r, g, b;
lightness = *l;
saturation = *s;
- if (lightness <= 0.5)
- m2 = lightness * (1 + saturation);
- else
- m2 = lightness + saturation - lightness * saturation;
- m1 = 2 * lightness - m2;
-
if (saturation == 0) {
*h = lightness;
*l = lightness;
*s = lightness;
} else {
+ gdouble hue;
+ gdouble m1, m2;
+ gdouble r, g, b;
+
+ if (lightness <= 0.5)
+ m2 = lightness * (1 + saturation);
+ else
+ m2 = lightness + saturation - lightness * saturation;
+ m1 = 2 * lightness - m2;
+
hue = *h + 120;
while (hue > 360)
hue -= 360;
diff --git a/mate-panel/libpanel-util/panel-error.c b/mate-panel/libpanel-util/panel-error.c
index b14d225f..81867a4a 100644
--- a/mate-panel/libpanel-util/panel-error.c
+++ b/mate-panel/libpanel-util/panel-error.c
@@ -2,6 +2,7 @@
* panel-error.c: an easy-to-use error dialog
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Originally based on code from panel-util.c (there was no relevant copyright
* header at the time).
@@ -79,9 +80,9 @@ panel_error_dialog (GtkWindow *parent,
gtk_widget_show_all (dialog);
if (auto_destroy)
- g_signal_connect_swapped (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_destroy),
- G_OBJECT (dialog));
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
if (freeme)
g_free (freeme);
diff --git a/mate-panel/libpanel-util/panel-error.h b/mate-panel/libpanel-util/panel-error.h
index c888731a..5b1c9b69 100644
--- a/mate-panel/libpanel-util/panel-error.h
+++ b/mate-panel/libpanel-util/panel-error.h
@@ -2,6 +2,7 @@
* panel-error.h: an easy-to-use error dialog
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Originally based on code from panel-util.h (there was no relevant copyright
* header at the time).
diff --git a/mate-panel/libpanel-util/panel-glib.c b/mate-panel/libpanel-util/panel-glib.c
index 70fc7610..e7cc531c 100644
--- a/mate-panel/libpanel-util/panel-glib.c
+++ b/mate-panel/libpanel-util/panel-glib.c
@@ -2,6 +2,7 @@
* panel-glib.c: various small extensions to glib
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Originally based on code from panel-util.c (there was no relevant copyright
* header at the time), but the code was:
diff --git a/mate-panel/libpanel-util/panel-glib.h b/mate-panel/libpanel-util/panel-glib.h
index 0cab22e9..aa21b347 100644
--- a/mate-panel/libpanel-util/panel-glib.h
+++ b/mate-panel/libpanel-util/panel-glib.h
@@ -2,6 +2,7 @@
* panel-glib.h: various small extensions to glib
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-gtk.c b/mate-panel/libpanel-util/panel-gtk.c
index a1db40fc..3672fca8 100644
--- a/mate-panel/libpanel-util/panel-gtk.c
+++ b/mate-panel/libpanel-util/panel-gtk.c
@@ -2,6 +2,7 @@
* panel-gtk.c: various small extensions to gtk+
*
* Copyright (C) 2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -118,7 +119,6 @@ panel_file_chooser_dialog_new_valist (const gchar *title,
{
GtkWidget *result;
const char *button_text = first_button_text;
- gint response_id;
result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
"title", title,
@@ -130,7 +130,7 @@ panel_file_chooser_dialog_new_valist (const gchar *title,
while (button_text)
{
- response_id = va_arg (varargs, gint);
+ gint response_id = va_arg (varargs, gint);
if (g_strcmp0 (button_text, "process-stop") == 0)
panel_dialog_add_button (GTK_DIALOG (result), _("_Cancel"), button_text, response_id);
@@ -166,7 +166,6 @@ panel_file_chooser_dialog_new (const gchar *title,
return result;
}
-
static void
ensure_icon_settings (void)
{
diff --git a/mate-panel/libpanel-util/panel-gtk.h b/mate-panel/libpanel-util/panel-gtk.h
index 3703e5a4..25ab2644 100644
--- a/mate-panel/libpanel-util/panel-gtk.h
+++ b/mate-panel/libpanel-util/panel-gtk.h
@@ -2,6 +2,7 @@
* panel-gtk.h: various small extensions to gtk+
*
* Copyright (C) 2009-2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-icon-chooser.c b/mate-panel/libpanel-util/panel-icon-chooser.c
index 44d64908..26fee9af 100644
--- a/mate-panel/libpanel-util/panel-icon-chooser.c
+++ b/mate-panel/libpanel-util/panel-icon-chooser.c
@@ -2,6 +2,7 @@
* panel-icon-chooser.c: An icon chooser widget
*
* Copyright (C) 2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -152,17 +153,9 @@ panel_icon_chooser_dispose (GObject *object)
/* remember, destroy can be run multiple times! */
- if (chooser->priv->fallback_icon_name != NULL)
- g_free (chooser->priv->fallback_icon_name);
- chooser->priv->fallback_icon_name = NULL;
-
- if (chooser->priv->icon != NULL)
- g_free (chooser->priv->icon);
- chooser->priv->icon = NULL;
-
- if (chooser->priv->icon_theme_dir != NULL)
- g_free (chooser->priv->icon_theme_dir);
- chooser->priv->icon_theme_dir = NULL;
+ g_clear_pointer (&chooser->priv->fallback_icon_name, g_free);
+ g_clear_pointer (&chooser->priv->icon, g_free);
+ g_clear_pointer (&chooser->priv->icon_theme_dir, g_free);
G_OBJECT_CLASS (panel_icon_chooser_parent_class)->dispose (object);
}
@@ -357,7 +350,6 @@ _panel_icon_chooser_clicked (GtkButton *button)
GtkWidget *filechooser;
GtkWidget *toplevel;
GtkWindow *parent;
- char *path;
gboolean filechooser_path_set;
if (chooser->priv->filechooser) {
@@ -382,15 +374,11 @@ _panel_icon_chooser_clicked (GtkButton *button)
panel_gtk_file_chooser_add_image_preview (GTK_FILE_CHOOSER (filechooser));
- path = g_build_filename (DATADIR, "icons", NULL);
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (filechooser),
- path, NULL);
- g_free (path);
+ DATADIR "/icons", NULL);
- path = g_build_filename (DATADIR, "pixmaps", NULL);
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (filechooser),
- path, NULL);
- g_free (path);
+ DATADIR "/pixmaps", NULL);
filechooser_path_set = FALSE;
@@ -428,14 +416,11 @@ _panel_icon_chooser_clicked (GtkButton *button)
}
if (!filechooser_path_set) {
- char *path;
/* FIXME? Use current icon theme? But there might not be a lot
* of icons there...
*/
- path = g_build_filename (DATADIR, "icons", NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser),
- path);
- g_free (path);
+ DATADIR "/icons");
}
gtk_window_set_destroy_with_parent (GTK_WINDOW (filechooser), TRUE);
@@ -446,9 +431,9 @@ _panel_icon_chooser_clicked (GtkButton *button)
chooser->priv->filechooser = filechooser;
- g_signal_connect (G_OBJECT (filechooser), "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &chooser->priv->filechooser);
+ g_signal_connect (filechooser, "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &chooser->priv->filechooser);
gtk_widget_show (filechooser);
}
@@ -511,8 +496,7 @@ panel_icon_chooser_set_fallback_icon_name (PanelIconChooser *chooser,
if (g_strcmp0 (chooser->priv->fallback_icon_name, fallback_icon_name) == 0)
return;
- if (chooser->priv->fallback_icon_name)
- g_free (chooser->priv->fallback_icon_name);
+ g_free (chooser->priv->fallback_icon_name);
chooser->priv->fallback_icon_name = g_strdup (fallback_icon_name);
_panel_icon_chooser_update (chooser);
@@ -537,8 +521,7 @@ panel_icon_chooser_set_icon (PanelIconChooser *chooser,
if (g_strcmp0 (chooser->priv->icon, icon) == 0)
return;
- if (chooser->priv->icon)
- g_free (chooser->priv->icon);
+ g_free (chooser->priv->icon);
chooser->priv->icon = g_strdup (icon);
_panel_icon_chooser_update (chooser);
diff --git a/mate-panel/libpanel-util/panel-icon-chooser.h b/mate-panel/libpanel-util/panel-icon-chooser.h
index a815749a..97cb0fe6 100644
--- a/mate-panel/libpanel-util/panel-icon-chooser.h
+++ b/mate-panel/libpanel-util/panel-icon-chooser.h
@@ -2,6 +2,7 @@
* panel-icon-chooser.h: An icon chooser widget
*
* Copyright (C) 2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-keyfile.c b/mate-panel/libpanel-util/panel-keyfile.c
index 09d387e3..b98058c3 100644
--- a/mate-panel/libpanel-util/panel-keyfile.c
+++ b/mate-panel/libpanel-util/panel-keyfile.c
@@ -2,6 +2,7 @@
* panel-keyfile.c: GKeyFile extensions
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Based on code from panel-util.c (there was no copyright header at the time)
*
@@ -52,8 +53,6 @@ _panel_key_file_make_executable (const gchar *path)
{
GFile *file;
GFileInfo *info;
- guint32 current_perms;
- guint32 new_perms;
file = g_file_new_for_path (path);
@@ -71,6 +70,9 @@ _panel_key_file_make_executable (const gchar *path)
}
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE)) {
+ guint32 current_perms;
+ guint32 new_perms;
+
current_perms = g_file_info_get_attribute_uint32 (info,
G_FILE_ATTRIBUTE_UNIX_MODE);
new_perms = current_perms | S_IXGRP | S_IXUSR | S_IXOTH;
@@ -292,8 +294,7 @@ panel_key_file_remove_locale_key (GKeyFile *keyfile,
locale_key, NULL))
break;
- g_free (locale_key);
- locale_key = NULL;
+ g_clear_pointer (&locale_key, g_free);
}
}
diff --git a/mate-panel/libpanel-util/panel-keyfile.h b/mate-panel/libpanel-util/panel-keyfile.h
index 8f90939d..413ae7ec 100644
--- a/mate-panel/libpanel-util/panel-keyfile.h
+++ b/mate-panel/libpanel-util/panel-keyfile.h
@@ -2,6 +2,7 @@
* panel-keyfile.h: GKeyFile extensions
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Based on code from panel-util.h (there was no copyright header at the time)
*
@@ -33,7 +34,6 @@
extern "C" {
#endif
-
GKeyFile *panel_key_file_new_desktop (void);
gboolean panel_key_file_to_file (GKeyFile *keyfile,
const gchar *file,
diff --git a/mate-panel/libpanel-util/panel-launch.c b/mate-panel/libpanel-util/panel-launch.c
index 7de0a02c..fb72c221 100644
--- a/mate-panel/libpanel-util/panel-launch.c
+++ b/mate-panel/libpanel-util/panel-launch.c
@@ -2,6 +2,7 @@
* panel-launch.c: some helpers to launch desktop files
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-launch.h b/mate-panel/libpanel-util/panel-launch.h
index 653167c1..372be078 100644
--- a/mate-panel/libpanel-util/panel-launch.h
+++ b/mate-panel/libpanel-util/panel-launch.h
@@ -2,6 +2,7 @@
* panel-launch.h: some helpers to launch desktop files
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-list.c b/mate-panel/libpanel-util/panel-list.c
index 9b1ad3f9..636161cf 100644
--- a/mate-panel/libpanel-util/panel-list.c
+++ b/mate-panel/libpanel-util/panel-list.c
@@ -2,6 +2,7 @@
* panel-list.c: GList & GSList extensions
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Originally based on code from panel-util.c (there was no relevant copyright
* header at the time), but the code was:
diff --git a/mate-panel/libpanel-util/panel-list.h b/mate-panel/libpanel-util/panel-list.h
index ec12a40d..7e09e368 100644
--- a/mate-panel/libpanel-util/panel-list.h
+++ b/mate-panel/libpanel-util/panel-list.h
@@ -2,6 +2,7 @@
* panel-list.h: GList & GSList extensions
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-session-manager.c b/mate-panel/libpanel-util/panel-session-manager.c
index ef99cad2..a4a17862 100644
--- a/mate-panel/libpanel-util/panel-session-manager.c
+++ b/mate-panel/libpanel-util/panel-session-manager.c
@@ -2,6 +2,7 @@
* panel-session.c:
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -38,8 +39,7 @@ panel_session_manager_finalize (GObject *object)
{
PanelSessionManager *manager = PANEL_SESSION_MANAGER (object);
- if (manager->proxy != NULL)
- g_object_unref (manager->proxy);
+ g_clear_object (&manager->proxy);
G_OBJECT_CLASS (panel_session_manager_parent_class)->finalize (object);
}
diff --git a/mate-panel/libpanel-util/panel-session-manager.h b/mate-panel/libpanel-util/panel-session-manager.h
index 98d09c94..fe148e9d 100644
--- a/mate-panel/libpanel-util/panel-session-manager.h
+++ b/mate-panel/libpanel-util/panel-session-manager.h
@@ -2,6 +2,7 @@
* panel-session.h:
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-show.c b/mate-panel/libpanel-util/panel-show.c
index 19feac90..1bc84ee7 100644
--- a/mate-panel/libpanel-util/panel-show.c
+++ b/mate-panel/libpanel-util/panel-show.c
@@ -2,6 +2,7 @@
* panel-show.c: a helper around gtk_show_uri
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-show.h b/mate-panel/libpanel-util/panel-show.h
index 9964319a..56a761c0 100644
--- a/mate-panel/libpanel-util/panel-show.h
+++ b/mate-panel/libpanel-util/panel-show.h
@@ -3,6 +3,7 @@
* or gtk_show_uri for gtk 3.20 and earlier
*
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/libpanel-util/panel-xdg.c b/mate-panel/libpanel-util/panel-xdg.c
index bcdbb5fa..361f413c 100644
--- a/mate-panel/libpanel-util/panel-xdg.c
+++ b/mate-panel/libpanel-util/panel-xdg.c
@@ -2,6 +2,7 @@
* panel-xdg.c: miscellaneous XDG-related functions.
*
* Copyright (C) 2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -117,18 +118,12 @@ panel_xdg_icon_name_from_icon_path (const char *path,
gboolean current;
theme_dir = g_file_get_child (parent, theme_name);
-
- current = FALSE;
- if (g_file_has_prefix (file, theme_dir)) {
- /* it's the current one */
- current = TRUE;
- } else {
- /* it's the default one */
+ if ((current = g_file_has_prefix (file, theme_dir)) == FALSE) {
+ /* fallback icon theme? */
g_object_unref (theme_dir);
theme_dir = g_file_get_child (parent, DEFAULT_THEME_NAME);
current = g_file_has_prefix (file, theme_dir);
}
-
g_object_unref (theme_dir);
if (current) {
diff --git a/mate-panel/libpanel-util/panel-xdg.h b/mate-panel/libpanel-util/panel-xdg.h
index 359c91b2..1553c8f5 100644
--- a/mate-panel/libpanel-util/panel-xdg.h
+++ b/mate-panel/libpanel-util/panel-xdg.h
@@ -2,6 +2,7 @@
* panel-xdg.h: miscellaneous XDG-related functions.
*
* Copyright (C) 2010 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/main.c b/mate-panel/main.c
index 15b7303d..f8c35f09 100644
--- a/mate-panel/main.c
+++ b/mate-panel/main.c
@@ -1,6 +1,7 @@
/* Mate panel: Initialization routines
* (C) 1997,1998,1999,2000 the Free Software Foundation
* (C) 2000 Eazel, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Federico Mena
* Miguel de Icaza
@@ -58,7 +59,7 @@ static const GOptionEntry options[] = {
{ "run-dialog", 0, 0, G_OPTION_ARG_NONE, &run_dialog, N_("Execute the run dialog"), NULL },
/* default panels layout */
{ "layout", 0, 0, G_OPTION_ARG_STRING, &layout, N_("Set the default panel layout"), NULL },
- { NULL }
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
static void
diff --git a/mate-panel/mate-desktop-item-edit.c b/mate-panel/mate-desktop-item-edit.c
index 72853939..b37f43ed 100644
--- a/mate-panel/mate-desktop-item-edit.c
+++ b/mate-panel/mate-desktop-item-edit.c
@@ -26,7 +26,7 @@ static char **desktops = NULL;
static GOptionEntry options[] = {
{ "create-new", 0, 0, G_OPTION_ARG_NONE, &create_new, N_("Create new file in the given directory"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &desktops, NULL, N_("[FILE...]") },
- { NULL }
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
static void
@@ -123,7 +123,6 @@ main (int argc, char * argv[])
for (i = 0; desktops[i] != NULL; i++) {
GFile *file;
GFileInfo *info;
- GFileType type;
char *uri;
char *path;
GtkWidget *dlg = NULL;
@@ -136,7 +135,7 @@ main (int argc, char * argv[])
g_object_unref (file);
if (info) {
- type = g_file_info_get_file_type (info);
+ GFileType type = g_file_info_get_file_type (info);
if (type == G_FILE_TYPE_DIRECTORY && create_new) {
@@ -205,10 +204,12 @@ main (int argc, char * argv[])
if (dlg != NULL) {
dialogs ++;
- g_signal_connect (G_OBJECT (dlg), "destroy",
- G_CALLBACK (dialog_destroyed), NULL);
- g_signal_connect (G_OBJECT (dlg), "error_reported",
- G_CALLBACK (error_reported), NULL);
+ g_signal_connect (dlg, "destroy",
+ G_CALLBACK (dialog_destroyed),
+ NULL);
+ g_signal_connect (dlg, "error-reported",
+ G_CALLBACK (error_reported),
+ NULL);
gtk_widget_show (dlg);
}
diff --git a/mate-panel/menu.c b/mate-panel/menu.c
index e1f4ba08..b72127ff 100644
--- a/mate-panel/menu.c
+++ b/mate-panel/menu.c
@@ -3,6 +3,7 @@
* Copyright (C) 2000 Helix Code, Inc.
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2004 Red Hat Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -31,6 +32,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <libmate-desktop/mate-gsettings.h>
+#include <libmate-desktop/mate-image-menu-item.h>
#include <matemenu-tree.h>
#include <libpanel-util/panel-keyfile.h>
@@ -167,7 +169,7 @@ panel_create_menu (void)
gtk_widget_set_name (retval, "mate-panel-main-menu");
- g_signal_connect (retval, "key_press_event",
+ g_signal_connect (retval, "key-press-event",
G_CALLBACK (panel_menu_key_press_handler),
NULL);
@@ -185,7 +187,7 @@ create_empty_menu (void)
/* intercept all right button clicks makes sure they don't
go to the object itself */
- g_signal_connect (retval, "button_press_event",
+ g_signal_connect (retval, "button-press-event",
G_CALLBACK (menu_dummy_button_press_event), NULL);
return retval;
@@ -211,7 +213,6 @@ add_app_to_panel (GtkWidget *item,
matemenu_tree_entry_get_desktop_file_path (entry));
}
-
static void
add_app_to_desktop (GtkWidget *item,
MateMenuTreeEntry *entry)
@@ -255,7 +256,6 @@ add_app_to_desktop (GtkWidget *item,
}
}
-
static void add_drawers_from_dir (MateMenuTreeDirectory *directory,
int pos,
const char *toplevel_id);
@@ -512,7 +512,6 @@ create_item_context_menu (GtkWidget *item,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
-
submenu = create_empty_menu ();
g_object_set_data (G_OBJECT (submenu), "menu_panel", panel_widget);
@@ -770,7 +769,7 @@ setup_menuitem (GtkWidget *menuitem,
gtk_icon_size_lookup (icon_size, NULL, &icon_height);
gtk_widget_show (image);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
+ mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (menuitem),
image);
gtk_image_set_pixel_size (GTK_IMAGE(image), icon_height);
}
@@ -809,15 +808,17 @@ setup_uri_drag (GtkWidget *menuitem,
if (icon != NULL)
gtk_drag_source_set_icon_name (menuitem, icon);
- g_signal_connect (G_OBJECT (menuitem), "drag_begin",
- G_CALLBACK (drag_begin_menu_cb), NULL);
- g_signal_connect_data (G_OBJECT (menuitem), "drag_data_get",
- G_CALLBACK (drag_data_get_string_cb),
- g_strdup (uri),
- (GClosureNotify) G_CALLBACK (g_free),
- 0 /* connect_flags */);
- g_signal_connect (G_OBJECT (menuitem), "drag_end",
- G_CALLBACK (drag_end_menu_cb), NULL);
+ g_signal_connect (menuitem, "drag-begin",
+ G_CALLBACK (drag_begin_menu_cb),
+ NULL);
+ g_signal_connect_data (menuitem, "drag-data-get",
+ G_CALLBACK (drag_data_get_string_cb),
+ g_strdup (uri),
+ (GClosureNotify) G_CALLBACK (g_free),
+ 0 /* connect_flags */);
+ g_signal_connect (menuitem, "drag-end",
+ G_CALLBACK (drag_end_menu_cb),
+ NULL);
}
void
@@ -840,15 +841,17 @@ setup_internal_applet_drag (GtkWidget *menuitem,
gtk_drag_source_set_icon_name (menuitem,
panel_action_get_icon_name (type));
- g_signal_connect (G_OBJECT (menuitem), "drag_begin",
- G_CALLBACK (drag_begin_menu_cb), NULL);
- g_signal_connect_data (G_OBJECT (menuitem), "drag_data_get",
- G_CALLBACK (drag_data_get_string_cb),
- g_strdup (panel_action_get_drag_id (type)),
- (GClosureNotify) G_CALLBACK (g_free),
- 0 /* connect_flags */);
- g_signal_connect (G_OBJECT (menuitem), "drag_end",
- G_CALLBACK (drag_end_menu_cb), NULL);
+ g_signal_connect (menuitem, "drag-begin",
+ G_CALLBACK (drag_begin_menu_cb),
+ NULL);
+ g_signal_connect_data (menuitem, "drag-data-get",
+ G_CALLBACK (drag_data_get_string_cb),
+ g_strdup (panel_action_get_drag_id (type)),
+ (GClosureNotify) G_CALLBACK (g_free),
+ 0 /* connect_flags */);
+ g_signal_connect (menuitem, "drag-end",
+ G_CALLBACK (drag_end_menu_cb),
+ NULL);
}
static void
@@ -946,10 +949,9 @@ create_fake_menu (MateMenuTreeDirectory *directory)
GUINT_TO_POINTER (idle_id),
remove_submenu_to_display_idle);
- g_signal_connect (menu, "button_press_event",
+ g_signal_connect (menu, "button-press-event",
G_CALLBACK (menu_dummy_button_press_event), NULL);
-
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
@@ -963,9 +965,7 @@ panel_image_menu_item_new (void)
{
GtkWidget *menuitem;
- menuitem = gtk_image_menu_item_new ();
- gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem),
- TRUE);
+ menuitem = mate_image_menu_item_new ();
return menuitem;
}
@@ -982,7 +982,7 @@ create_submenu_entry (GtkWidget *menu,
if (force_categories_icon)
menuitem = panel_image_menu_item_new ();
else
- menuitem = gtk_image_menu_item_new ();
+ menuitem = mate_image_menu_item_new ();
setup_menuitem_with_icon (menuitem,
panel_menu_icon_get_size (),
@@ -1096,7 +1096,7 @@ create_menuitem (GtkWidget *menu,
}
}
- g_signal_connect_after (menuitem, "button_press_event",
+ g_signal_connect_after (menuitem, "button-press-event",
G_CALLBACK (menuitem_button_press_event), NULL);
if (!panel_lockdown_get_locked_down ()) {
@@ -1120,12 +1120,15 @@ create_menuitem (GtkWidget *menu,
}
}
- g_signal_connect (G_OBJECT (menuitem), "drag_begin",
- G_CALLBACK (drag_begin_menu_cb), NULL);
- g_signal_connect (menuitem, "drag_data_get",
- G_CALLBACK (drag_data_get_menu_cb), entry);
- g_signal_connect (menuitem, "drag_end",
- G_CALLBACK (drag_end_menu_cb), NULL);
+ g_signal_connect (menuitem, "drag-begin",
+ G_CALLBACK (drag_begin_menu_cb),
+ NULL);
+ g_signal_connect (menuitem, "drag-data-get",
+ G_CALLBACK (drag_data_get_menu_cb),
+ entry);
+ g_signal_connect (menuitem, "drag-end",
+ G_CALLBACK (drag_end_menu_cb),
+ NULL);
}
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
@@ -1258,7 +1261,7 @@ create_applications_menu (const char *menu_file,
GUINT_TO_POINTER (idle_id),
remove_submenu_to_display_idle);
- g_signal_connect (menu, "button_press_event",
+ g_signal_connect (menu, "button-press-event",
G_CALLBACK (menu_dummy_button_press_event), NULL);
g_signal_connect (tree, "changed", G_CALLBACK (handle_matemenu_tree_changed), menu);
diff --git a/mate-panel/menu.h b/mate-panel/menu.h
index bd2398de..dd99e793 100644
--- a/mate-panel/menu.h
+++ b/mate-panel/menu.h
@@ -3,6 +3,7 @@
* Copyright (C) 2000 Helix Code, Inc.
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2004 Red Hat Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -71,7 +72,6 @@ GtkWidget *add_menu_separator (GtkWidget *menu);
gboolean menu_dummy_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
-
#ifdef __cplusplus
}
#endif
diff --git a/mate-panel/panel-a11y.c b/mate-panel/panel-a11y.c
index 531f4b8b..d3d0411c 100644
--- a/mate-panel/panel-a11y.c
+++ b/mate-panel/panel-a11y.c
@@ -2,6 +2,7 @@
* panel-a11y.c: panel accessibility support module
*
* Copyright (C) 2002, 2003 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/mate-panel/panel-a11y.h b/mate-panel/panel-a11y.h
index f12e9aa4..9fe75d3b 100644
--- a/mate-panel/panel-a11y.h
+++ b/mate-panel/panel-a11y.h
@@ -2,6 +2,7 @@
* panel-a11y.h: panel accessibility support module
*
* Copyright (C) 2002, 2003 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/mate-panel/panel-action-button.c b/mate-panel/panel-action-button.c
index 2c4569c1..6fad288f 100644
--- a/mate-panel/panel-action-button.c
+++ b/mate-panel/panel-action-button.c
@@ -4,6 +4,7 @@
*
* Copyright (C) 2002 Sun Microsystems, Inc.
* Copyright (C) 2004 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -60,6 +61,11 @@
#include "panel-force-quit.h"
#endif
+#ifdef HAVE_WAYLAND
+#include <gdk/gdkwayland.h>
+
+#endif
+
enum {
PROP_0,
PROP_ACTION_TYPE,
@@ -212,13 +218,202 @@ panel_action_logout (GtkWidget *widget)
PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL);
}
+/* Shutdown
+ */
+#ifdef HAVE_WAYLAND
static void
-panel_action_shutdown (GtkWidget *widget)
+show_error_dialog (GtkWidget *label)
{
- PanelSessionManager *manager;
+ GtkWidget *dialog, *box, *content_area, *button, *image;
+ dialog = gtk_dialog_new ();
+ button = gtk_dialog_add_button (GTK_DIALOG(dialog),
+ "Cancel",
+ GTK_RESPONSE_CANCEL);
+
+ image = gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_MENU);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 16);
+ gtk_container_add (GTK_CONTAINER (content_area), box);
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ gtk_widget_show_all (dialog);
+}
+static void wayland_shutdown_response_cb (GtkWidget *dialog, gint response_id)
+ {
+ int ret;
- manager = panel_session_manager_get ();
- panel_session_manager_request_shutdown (manager);
+ if (response_id == GTK_RESPONSE_CANCEL)
+ {
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ gtk_widget_destroy (dialog);
+ system ("shutdown now");
+ /*Try the system shutdown command first.
+ *This will fail if root is logged in
+ *Note that if -f --force was used this would block proper unmounting
+ *if this fails try systemd in case it's installed as it commonly is
+ *FIXME: we also need a logind equivalent for non-systemd users
+ *with session managers running as root
+ */
+ system ("systemctl poweroff -i");
+ return;
+ }
+
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ {
+ gtk_widget_destroy (dialog);
+ system ("reboot now");
+ /*Same approach as shutdown command
+ *FIXME: we also need a logind equivalent for non-systemd users
+ *with session managers running as root
+ */
+ system ("systemctl reboot -i");
+ return;
+ }
+
+ if (response_id == GTK_RESPONSE_REJECT)
+ {
+ gtk_widget_destroy (dialog);
+ /*FIXME: we also need a logind equivalent for non-systemd users
+ *with session managers running as root
+ */
+ ret = system ("systemctl hibernate -i");
+ if (ret != 0)
+ {
+ GtkWidget *label;
+ label = gtk_label_new ("Hibernation not supported on this system" "\n" "\n"
+ "The \"resume = \" boot command line option must be set to a swap partition or file" "\n"
+ "Swapfile or partition must be large enough to support hibernation" "\n"
+ "System and hardware must support hibernation");
+ show_error_dialog (label);
+ }
+ return;
+ }
+
+ if (response_id == GTK_RESPONSE_APPLY)
+ {
+ gtk_widget_destroy (dialog);
+ /*FIXME: we also need a logind equivalent for non-systemd users
+ *with session managers running as root
+ */
+ ret = system ("systemctl suspend -i");
+ if (ret != 0)
+ {
+ GtkWidget *label;
+ label = gtk_label_new ("Suspend not supported on this system" "\n" "\n"
+ "Hardware and Firmware must support sleep / suspend");
+ show_error_dialog (label);
+ }
+
+ return;
+ }
+ }
+
+static GtkWidget*
+wayland_shutdown_dialog_add_button (GtkDialog *dialog,
+ const gchar *button_text,
+ const gchar *icon_name,
+ gint response_id)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_with_mnemonic (button_text);
+ gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+ gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+ gtk_widget_set_can_default (button, TRUE);
+ gtk_widget_show (button);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+ return button;
+}
+#endif
+static void
+panel_action_shutdown (GtkWidget *widget)
+{
+#ifdef HAVE_WAYLAND
+ GdkDisplay *display = gdk_screen_get_display (gdk_screen_get_default ());
+ if (GDK_IS_WAYLAND_DISPLAY (display))
+ {
+ GtkWidget *dialog, *hbox, *buttonbox, *shutdown_btn, *label;
+ GtkStyleContext *context;
+
+ dialog = gtk_dialog_new_with_buttons ("System Shutdown",
+ NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ NULL,
+ NULL,
+ NULL);
+
+ /*Window icons in dialogs are currently broken or unsupported
+ *in many wayland compositors but this may not always be so
+ */
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-shutdown");
+ context = gtk_widget_get_style_context (GTK_WIDGET (dialog));
+ gtk_style_context_add_class (context, "logout-dialog");
+ context = NULL;
+
+ /*We use the inbuilt gtk response types for simplicity*/
+ wayland_shutdown_dialog_add_button (GTK_DIALOG (dialog),
+ _("S_uspend"), "battery",
+ GTK_RESPONSE_APPLY);
+
+ wayland_shutdown_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Hibernate"), "drive-harddisk",
+ GTK_RESPONSE_REJECT);
+
+ wayland_shutdown_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Restart"), "view-refresh",
+ GTK_RESPONSE_ACCEPT);
+
+ wayland_shutdown_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Cancel"), "process-stop",
+ GTK_RESPONSE_CANCEL);
+
+ shutdown_btn = wayland_shutdown_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Shut Down"), "system-shutdown",
+ GTK_RESPONSE_OK);
+
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (wayland_shutdown_response_cb),
+ dialog);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+ label = gtk_label_new ("Shut this system down now?");
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 16);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ hbox);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ buttonbox = gtk_widget_get_parent (shutdown_btn);
+ gtk_widget_set_halign (buttonbox,GTK_ALIGN_CENTER);
+ context = gtk_widget_get_style_context (buttonbox);
+ gtk_style_context_add_class (context, "linked");
+ context = NULL;
+ gtk_widget_show_all (dialog);
+ }
+ else
+#endif
+ {
+ PanelSessionManager *manager;
+ manager = panel_session_manager_get ();
+ panel_session_manager_request_shutdown (manager);
+ }
}
static gboolean
@@ -228,7 +423,11 @@ panel_action_shutdown_reboot_is_disabled (void)
if (panel_lockdown_get_disable_log_out())
return TRUE;
-
+#ifdef HAVE_WAYLAND
+ GdkDisplay *display = gdk_screen_get_display (gdk_screen_get_default());
+ if (!(panel_lockdown_get_disable_log_out()) && (GDK_IS_WAYLAND_DISPLAY (display)))
+ return FALSE;
+#endif
manager = panel_session_manager_get ();
return (!panel_session_manager_is_shutdown_available (manager));
@@ -272,7 +471,7 @@ panel_action_force_quit (GtkWidget *widget)
}
#endif
flags = GTK_DIALOG_DESTROY_WITH_PARENT;
- dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
+ dialog = gtk_message_dialog_new (NULL,
flags,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
@@ -314,7 +513,6 @@ panel_action_connect_server (GtkWidget *widget)
}
typedef struct {
- PanelActionButtonType type;
char *icon_name;
char *text;
char *tooltip;
@@ -331,12 +529,10 @@ typedef struct {
*/
static PanelAction actions [PANEL_ACTION_LAST] = {
[PANEL_ACTION_NONE] = {
- PANEL_ACTION_NONE,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL
},
[PANEL_ACTION_LOCK] = {
- PANEL_ACTION_LOCK,
PANEL_ICON_LOCKSCREEN,
N_("Lock Screen"),
N_("Protect your computer from unauthorized use"),
@@ -348,7 +544,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_action_lock_is_disabled
},
[PANEL_ACTION_LOGOUT] = {
- PANEL_ACTION_LOGOUT,
PANEL_ICON_LOGOUT,
/* when changing one of those two strings, don't forget to
* update the ones in panel-menu-items.c (look for
@@ -361,7 +556,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_lockdown_get_disable_log_out
},
[PANEL_ACTION_RUN] = {
- PANEL_ACTION_RUN,
PANEL_ICON_RUN,
N_("Run Application..."),
N_("Run an application by typing a command or choosing from a list"),
@@ -371,7 +565,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_lockdown_get_disable_command_line
},
[PANEL_ACTION_SEARCH] = {
- PANEL_ACTION_SEARCH,
PANEL_ICON_SEARCHTOOL,
N_("Search for Files..."),
N_("Locate documents and folders on this computer by name or content"),
@@ -380,7 +573,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_action_search, NULL, NULL, NULL
},
[PANEL_ACTION_FORCE_QUIT] = {
- PANEL_ACTION_FORCE_QUIT,
PANEL_ICON_FORCE_QUIT,
N_("Force Quit"),
N_("Force a misbehaving application to quit"),
@@ -390,7 +582,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_lockdown_get_disable_force_quit
},
[PANEL_ACTION_CONNECT_SERVER] = {
- PANEL_ACTION_CONNECT_SERVER,
PANEL_ICON_REMOTE, /* FIXME icon */
N_("Connect to Server..."),
N_("Connect to a remote computer or shared disk"),
@@ -399,7 +590,6 @@ static PanelAction actions [PANEL_ACTION_LAST] = {
panel_action_connect_server, NULL, NULL, NULL
},
[PANEL_ACTION_SHUTDOWN] = {
- PANEL_ACTION_SHUTDOWN,
PANEL_ICON_SHUTDOWN,
N_("Shut Down..."),
N_("Shut down the computer"),
@@ -476,8 +666,7 @@ panel_action_button_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (button->priv->settings,
G_CALLBACK (panel_action_button_type_changed),
button);
- g_object_unref (button->priv->settings);
- button->priv->settings = NULL;
+ g_clear_object (&button->priv->settings);
}
button->priv->info = NULL;
@@ -715,7 +904,6 @@ panel_action_button_load (PanelActionButtonType type,
button = g_object_new (PANEL_TYPE_ACTION_BUTTON, "action-type", type, NULL);
-
button->priv->info = mate_panel_applet_register (GTK_WIDGET (button),
NULL, NULL,
panel, locked, position,
@@ -889,7 +1077,7 @@ panel_action_button_set_dnd_enabled (PanelActionButton *button,
} else
gtk_drag_source_unset (GTK_WIDGET (button));
- button->priv->dnd_enabled = enabled;
+ button->priv->dnd_enabled = (enabled != FALSE);
g_object_notify (G_OBJECT (button), "dnd-enabled");
}
diff --git a/mate-panel/panel-action-button.h b/mate-panel/panel-action-button.h
index 6bddff6d..0df9d1ab 100644
--- a/mate-panel/panel-action-button.h
+++ b/mate-panel/panel-action-button.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2002 Sun Microsystems, Inc.
* Copyright (C) 2004 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-action-protocol.c b/mate-panel/panel-action-protocol.c
index 4661971d..f261d860 100644
--- a/mate-panel/panel-action-protocol.c
+++ b/mate-panel/panel-action-protocol.c
@@ -2,6 +2,7 @@
* panel-action-protocol.h: _MATE_PANEL_ACTION protocol impl.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -144,15 +145,18 @@ panel_action_protocol_filter (GdkXEvent *gdk_xevent,
if (window != gdk_screen_get_root_window (screen))
return GDK_FILTER_CONTINUE;
- if (xevent->xclient.data.l [0] == atom_mate_panel_action_main_menu)
+ if (xevent->xclient.data.l [0] < 0)
+ return GDK_FILTER_CONTINUE;
+
+ if (xevent->xclient.data.l [0] == (long) atom_mate_panel_action_main_menu)
panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1], event);
- else if (xevent->xclient.data.l [0] == atom_mate_panel_action_run_dialog)
+ else if (xevent->xclient.data.l [0] == (long) atom_mate_panel_action_run_dialog)
panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]);
- else if (xevent->xclient.data.l [0] == atom_gnome_panel_action_main_menu)
+ else if (xevent->xclient.data.l [0] == (long) atom_gnome_panel_action_main_menu)
panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1], event);
- else if (xevent->xclient.data.l [0] == atom_gnome_panel_action_run_dialog)
+ else if (xevent->xclient.data.l [0] == (long) atom_gnome_panel_action_run_dialog)
panel_action_protocol_run_dialog (screen, xevent->xclient.data.l [1]);
- else if (xevent->xclient.data.l [0] == atom_mate_panel_action_kill_dialog)
+ else if (xevent->xclient.data.l [0] == (long) atom_mate_panel_action_kill_dialog)
panel_action_protocol_kill_dialog (screen, xevent->xclient.data.l [1]);
else
return GDK_FILTER_CONTINUE;
diff --git a/mate-panel/panel-action-protocol.h b/mate-panel/panel-action-protocol.h
index 4774826b..28d1bc03 100644
--- a/mate-panel/panel-action-protocol.h
+++ b/mate-panel/panel-action-protocol.h
@@ -2,6 +2,7 @@
* panel-action-protocol.h: _MATE_PANEL_ACTION protocol impl.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-addto.c b/mate-panel/panel-addto.c
index 9f76b717..bcd676ee 100644
--- a/mate-panel/panel-addto.c
+++ b/mate-panel/panel-addto.c
@@ -2,6 +2,7 @@
* panel-addto.c:
*
* Copyright (C) 2004 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -228,8 +229,9 @@ panel_addto_applet_info_sort_func (PanelAddtoItemInfo *a,
static GSList *
panel_addto_prepend_internal_applets (GSList *list)
{
- static gboolean translated = FALSE;
- int i;
+ static gboolean translated = FALSE;
+ gsize i;
+ PanelActionButtonType p;
for (i = 0; i < G_N_ELEMENTS (internal_addto_items); i++) {
if (!translated) {
@@ -242,19 +244,19 @@ panel_addto_prepend_internal_applets (GSList *list)
translated = TRUE;
- for (i = PANEL_ACTION_LOCK; i < PANEL_ACTION_LAST; i++) {
+ for (p = PANEL_ACTION_LOCK; p < PANEL_ACTION_LAST; p++) {
PanelAddtoItemInfo *info;
- if (panel_action_get_is_disabled (i))
+ if (panel_action_get_is_disabled (p))
continue;
info = g_new0 (PanelAddtoItemInfo, 1);
info->type = PANEL_ADDTO_ACTION;
- info->action_type = i;
- info->name = g_strdup (panel_action_get_text (i));
- info->description = g_strdup (panel_action_get_tooltip (i));
- info->icon = g_strdup (panel_action_get_icon_name (i));
- info->iid = g_strdup (panel_action_get_drag_id (i));
+ info->action_type = p;
+ info->name = g_strdup (panel_action_get_text (p));
+ info->description = g_strdup (panel_action_get_tooltip (p));
+ info->icon = g_strdup (panel_action_get_icon_name (p));
+ info->iid = g_strdup (panel_action_get_drag_id (p));
info->enabled = TRUE;
info->static_data = FALSE;
@@ -338,12 +340,12 @@ panel_addto_setup_drag (GtkTreeView *tree_view,
GDK_BUTTON1_MASK|GDK_BUTTON2_MASK,
target, 1, GDK_ACTION_COPY);
- g_signal_connect_data (G_OBJECT (tree_view), "drag_data_get",
+ g_signal_connect_data (tree_view, "drag-data-get",
G_CALLBACK (panel_addto_drag_data_get_cb),
g_strdup (text),
(GClosureNotify) G_CALLBACK (g_free),
0 /* connect_flags */);
- g_signal_connect_after (G_OBJECT (tree_view), "drag-begin",
+ g_signal_connect_after (tree_view, "drag-begin",
G_CALLBACK (panel_addto_drag_begin_cb),
NULL);
}
@@ -483,7 +485,7 @@ panel_addto_append_special_applets (PanelAddtoDialog *dialog,
GtkListStore *model)
{
static gboolean translated = FALSE;
- int i;
+ gsize i;
for (i = 0; i < G_N_ELEMENTS (special_addto_items); i++) {
if (!translated) {
@@ -892,9 +894,7 @@ panel_addto_present_applications (PanelAddtoDialog *dialog)
dialog->search_entry);
gtk_widget_set_sensitive (dialog->back_button, TRUE);
- if (dialog->applet_search_text)
- g_free (dialog->applet_search_text);
-
+ g_free (dialog->applet_search_text);
dialog->applet_search_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)));
/* show everything */
gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), "");
@@ -914,11 +914,8 @@ panel_addto_present_applets (PanelAddtoDialog *dialog)
if (dialog->applet_search_text) {
gtk_entry_set_text (GTK_ENTRY (dialog->search_entry),
dialog->applet_search_text);
- gtk_editable_set_position (GTK_EDITABLE (dialog->search_entry),
- -1);
-
- g_free (dialog->applet_search_text);
- dialog->applet_search_text = NULL;
+ gtk_editable_set_position (GTK_EDITABLE (dialog->search_entry), -1);
+ g_clear_pointer (&dialog->applet_search_text, g_free);
}
}
@@ -928,33 +925,13 @@ panel_addto_dialog_free_item_info (PanelAddtoItemInfo *item_info)
if (item_info == NULL || item_info->static_data)
return;
- if (item_info->name != NULL)
- g_free (item_info->name);
- item_info->name = NULL;
-
- if (item_info->description != NULL)
- g_free (item_info->description);
- item_info->description = NULL;
-
- if (item_info->icon != NULL)
- g_free (item_info->icon);
- item_info->icon = NULL;
-
- if (item_info->iid != NULL)
- g_free (item_info->iid);
- item_info->iid = NULL;
-
- if (item_info->launcher_path != NULL)
- g_free (item_info->launcher_path);
- item_info->launcher_path = NULL;
-
- if (item_info->menu_filename != NULL)
- g_free (item_info->menu_filename);
- item_info->menu_filename = NULL;
-
- if (item_info->menu_path != NULL)
- g_free (item_info->menu_path);
- item_info->menu_path = NULL;
+ g_clear_pointer (&item_info->name, g_free);
+ g_clear_pointer (&item_info->description, g_free);
+ g_clear_pointer (&item_info->icon, g_free);
+ g_clear_pointer (&item_info->iid, g_free);
+ g_clear_pointer (&item_info->launcher_path, g_free);
+ g_clear_pointer (&item_info->menu_filename, g_free);
+ g_clear_pointer (&item_info->menu_path, g_free);
}
static void
@@ -991,13 +968,8 @@ panel_addto_dialog_free (PanelAddtoDialog *dialog)
G_CALLBACK (panel_addto_name_notify),
dialog);
- if (dialog->search_text)
- g_free (dialog->search_text);
- dialog->search_text = NULL;
-
- if (dialog->applet_search_text)
- g_free (dialog->applet_search_text);
- dialog->applet_search_text = NULL;
+ g_free (dialog->search_text);
+ g_free (dialog->applet_search_text);
if (dialog->addto_dialog)
gtk_widget_destroy (dialog->addto_dialog);
@@ -1017,22 +989,10 @@ panel_addto_dialog_free (PanelAddtoDialog *dialog)
panel_addto_dialog_free_application_list (dialog->application_list);
panel_addto_dialog_free_application_list (dialog->settings_list);
- if (dialog->filter_applet_model)
- g_object_unref (dialog->filter_applet_model);
- dialog->filter_applet_model = NULL;
-
- if (dialog->applet_model)
- g_object_unref (dialog->applet_model);
- dialog->applet_model = NULL;
-
- if (dialog->filter_application_model)
- g_object_unref (dialog->filter_application_model);
- dialog->filter_application_model = NULL;
-
- if (dialog->application_model)
- g_object_unref (dialog->application_model);
- dialog->application_model = NULL;
-
+ g_clear_object (&dialog->filter_applet_model);
+ g_clear_object (&dialog->applet_model);
+ g_clear_object (&dialog->filter_application_model);
+ g_clear_object (&dialog->application_model);
g_clear_object (&dialog->menu_tree);
g_free (dialog);
@@ -1126,8 +1086,7 @@ panel_addto_search_entry_changed (GtkWidget *entry,
return;
}
- if (dialog->search_text)
- g_free (dialog->search_text);
+ g_free (dialog->search_text);
dialog->search_text = new_text;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree_view));
@@ -1330,10 +1289,12 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
gtk_box_set_spacing (GTK_BOX (dialog_vbox), 12);
gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
- g_signal_connect (G_OBJECT (dialog->addto_dialog), "response",
- G_CALLBACK (panel_addto_dialog_response), dialog);
+ g_signal_connect (dialog->addto_dialog, "response",
+ G_CALLBACK (panel_addto_dialog_response),
+ dialog);
g_signal_connect (dialog->addto_dialog, "destroy",
- G_CALLBACK (panel_addto_dialog_destroy), dialog);
+ G_CALLBACK (panel_addto_dialog_destroy),
+ dialog);
inner_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (dialog_vbox), inner_vbox, TRUE, TRUE, 0);
@@ -1350,10 +1311,12 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
FALSE, FALSE, 0);
dialog->search_entry = gtk_entry_new ();
- g_signal_connect (G_OBJECT (dialog->search_entry), "changed",
- G_CALLBACK (panel_addto_search_entry_changed), dialog);
- g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
- G_CALLBACK (panel_addto_search_entry_activated), dialog);
+ g_signal_connect (dialog->search_entry, "changed",
+ G_CALLBACK (panel_addto_search_entry_changed),
+ dialog);
+ g_signal_connect (dialog->search_entry, "activate",
+ G_CALLBACK (panel_addto_search_entry_activated),
+ dialog);
gtk_box_pack_end (GTK_BOX (find_hbox), dialog->search_entry,
TRUE, TRUE, 0);
@@ -1404,7 +1367,6 @@ panel_addto_dialog_new (PanelWidget *panel_widget)
GINT_TO_POINTER (COLUMN_TEXT),
NULL);
-
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
diff --git a/mate-panel/panel-addto.h b/mate-panel/panel-addto.h
index f1defdc5..92a37af2 100644
--- a/mate-panel/panel-addto.h
+++ b/mate-panel/panel-addto.h
@@ -2,6 +2,7 @@
* panel-addto.h:
*
* Copyright (C) 2004 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-applet-frame.c b/mate-panel/panel-applet-frame.c
index ebb8cb14..2b0e4b7f 100644
--- a/mate-panel/panel-applet-frame.c
+++ b/mate-panel/panel-applet-frame.c
@@ -4,6 +4,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -437,8 +438,7 @@ mate_panel_applet_frame_finalize (GObject *object)
panel_lockdown_notify_remove (G_CALLBACK (mate_panel_applet_frame_sync_menu_state),
frame);
- g_free (frame->priv->iid);
- frame->priv->iid = NULL;
+ g_clear_pointer (&frame->priv->iid, g_free);
G_OBJECT_CLASS (mate_panel_applet_frame_parent_class)->finalize (object);
}
@@ -551,8 +551,7 @@ void
_mate_panel_applet_frame_set_iid (MatePanelAppletFrame *frame,
const gchar *iid)
{
- if (frame->priv->iid)
- g_free (frame->priv->iid);
+ g_free (frame->priv->iid);
frame->priv->iid = g_strdup (iid);
}
@@ -614,7 +613,7 @@ _mate_panel_applet_frame_update_flags (MatePanelAppletFrame *frame,
frame->priv->panel, GTK_WIDGET (frame), major, minor);
old_has_handle = frame->priv->has_handle;
- frame->priv->has_handle = has_handle;
+ frame->priv->has_handle = (has_handle != FALSE);
if (!old_has_handle && frame->priv->has_handle) {
/* we've added an handle, so we need to get the background for
@@ -628,12 +627,12 @@ _mate_panel_applet_frame_update_flags (MatePanelAppletFrame *frame,
void
_mate_panel_applet_frame_update_size_hints (MatePanelAppletFrame *frame,
- gint *size_hints,
- guint n_elements)
+ gint *size_hints,
+ gsize n_elements)
{
if (frame->priv->has_handle) {
gint extra_size = HANDLE_SIZE + 1;
- gint i;
+ gsize i;
for (i = 0; i < n_elements; i++)
size_hints[i] += extra_size;
diff --git a/mate-panel/panel-applet-frame.h b/mate-panel/panel-applet-frame.h
index 50b700b4..0c0fbd09 100644
--- a/mate-panel/panel-applet-frame.h
+++ b/mate-panel/panel-applet-frame.h
@@ -2,6 +2,7 @@
* panel-applet-frame.h: panel side container for applets
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -101,7 +102,6 @@ void mate_panel_applet_frame_change_background (MatePanelAppletFrame *frame
void mate_panel_applet_frame_set_panel (MatePanelAppletFrame *frame,
PanelWidget *panel);
-
/* For module implementations only */
typedef struct _MatePanelAppletFrameActivating MatePanelAppletFrameActivating;
@@ -126,8 +126,8 @@ void _mate_panel_applet_frame_update_flags (MatePanelAppletFrame *fram
gboolean has_handle);
void _mate_panel_applet_frame_update_size_hints (MatePanelAppletFrame *frame,
- gint *size_hints,
- guint n_elements);
+ gint *size_hints,
+ gsize n_elements);
char *_mate_panel_applet_frame_get_background_string (MatePanelAppletFrame *frame,
PanelWidget *panel,
diff --git a/mate-panel/panel-applet-info.c b/mate-panel/panel-applet-info.c
index c3862358..9081156f 100644
--- a/mate-panel/panel-applet-info.c
+++ b/mate-panel/panel-applet-info.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-applet-info.h b/mate-panel/panel-applet-info.h
index fc999ffc..708ae043 100644
--- a/mate-panel/panel-applet-info.h
+++ b/mate-panel/panel-applet-info.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-applets-manager.c b/mate-panel/panel-applets-manager.c
index 6d93d04b..05ca399a 100644
--- a/mate-panel/panel-applets-manager.c
+++ b/mate-panel/panel-applets-manager.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-applets-manager.h b/mate-panel/panel-applets-manager.h
index d2c5e2e8..3f0ac69f 100644
--- a/mate-panel/panel-applets-manager.h
+++ b/mate-panel/panel-applets-manager.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,16 +29,10 @@
#include "panel-applet-frame.h"
#include "panel-applet-info.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
-#define PANEL_TYPE_APPLETS_MANAGER (mate_panel_applets_manager_get_type ())
-#define MATE_PANEL_APPLETS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLETS_MANAGER, MatePanelAppletsManager))
-#define MATE_PANEL_APPLETS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_APPLETS_MANAGER, MatePanelAppletsManagerClass))
-#define PANEL_IS_APPLETS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLETS_MANAGER))
-#define PANEL_IS_APPLETS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLETS_MANAGER))
-#define MATE_PANEL_APPLETS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_APPLETS_MANAGER, MatePanelAppletsManagerClass))
+#define PANEL_TYPE_APPLETS_MANAGER mate_panel_applets_manager_get_type ()
+G_DECLARE_DERIVABLE_TYPE (MatePanelAppletsManager, mate_panel_applets_manager, MATE_PANEL, APPLETS_MANAGER, GObject)
/**
* MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME:
@@ -46,56 +41,36 @@ extern "C" {
**/
#define MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME "mate-panel-applets-manager"
-typedef struct _MatePanelAppletsManager MatePanelAppletsManager;
-typedef struct _MatePanelAppletsManagerClass MatePanelAppletsManagerClass;
-
struct _MatePanelAppletsManagerClass {
- GObjectClass parent_class;
-
- GList * (*get_applets) (MatePanelAppletsManager *manager);
-
- gboolean (*factory_activate) (MatePanelAppletsManager *manager,
- const gchar *iid);
- gboolean (*factory_deactivate) (MatePanelAppletsManager *manager,
- const gchar *iid);
-
- MatePanelAppletInfo * (*get_applet_info) (MatePanelAppletsManager *manager,
- const gchar *iid);
-
- MatePanelAppletInfo * (*get_applet_info_from_old_id) (MatePanelAppletsManager *manager,
- const gchar *iid);
-
- gboolean (*load_applet) (MatePanelAppletsManager *manager,
- const gchar *iid,
- MatePanelAppletFrameActivating *frame_act);
-
- GtkWidget * (*get_applet_widget) (MatePanelAppletsManager *manager,
- const gchar *iid,
- guint uid);
+ GObjectClass parent_class;
+
+ GList * (*get_applets) (MatePanelAppletsManager *manager);
+ gboolean (*factory_activate) (MatePanelAppletsManager *manager,
+ const gchar *iid);
+ gboolean (*factory_deactivate) (MatePanelAppletsManager *manager,
+ const gchar *iid);
+ MatePanelAppletInfo * (*get_applet_info) (MatePanelAppletsManager *manager,
+ const gchar *iid);
+ MatePanelAppletInfo * (*get_applet_info_from_old_id) (MatePanelAppletsManager *manager,
+ const gchar *iid);
+ gboolean (*load_applet) (MatePanelAppletsManager *manager,
+ const gchar *iid,
+ MatePanelAppletFrameActivating *frame_act);
+ GtkWidget * (*get_applet_widget) (MatePanelAppletsManager *manager,
+ const gchar *iid,
+ guint uid);
};
-struct _MatePanelAppletsManager {
- GObject parent;
-};
-
-GType mate_panel_applets_manager_get_type (void);
-
-GList *mate_panel_applets_manager_get_applets (void);
-
-gboolean mate_panel_applets_manager_factory_activate (const gchar *iid);
-void mate_panel_applets_manager_factory_deactivate (const gchar *iid);
-
-MatePanelAppletInfo *mate_panel_applets_manager_get_applet_info (const gchar *iid);
-MatePanelAppletInfo *mate_panel_applets_manager_get_applet_info_from_old_id (const gchar *iid);
-
-gboolean mate_panel_applets_manager_load_applet (const gchar *iid,
- MatePanelAppletFrameActivating *frame_act);
-
-GtkWidget *mate_panel_applets_manager_get_applet_widget (const gchar *iid,
- guint uid);
-
-#ifdef __cplusplus
-}
-#endif
+GList *mate_panel_applets_manager_get_applets (void);
+gboolean mate_panel_applets_manager_factory_activate (const gchar *iid);
+void mate_panel_applets_manager_factory_deactivate (const gchar *iid);
+MatePanelAppletInfo *mate_panel_applets_manager_get_applet_info (const gchar *iid);
+MatePanelAppletInfo *mate_panel_applets_manager_get_applet_info_from_old_id (const gchar *iid);
+gboolean mate_panel_applets_manager_load_applet (const gchar *iid,
+ MatePanelAppletFrameActivating *frame_act);
+GtkWidget *mate_panel_applets_manager_get_applet_widget (const gchar *iid,
+ guint uid);
+
+G_END_DECLS
#endif /* __PANEL_APPLETS_MANAGER_H__ */
diff --git a/mate-panel/panel-background-monitor.c b/mate-panel/panel-background-monitor.c
deleted file mode 100644
index 4c33aedf..00000000
--- a/mate-panel/panel-background-monitor.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * panel-background-monitor.c:
- *
- * Copyright (C) 2001, 2002 Ian McKellar <[email protected]>
- * 2002 Sun Microsystems, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Ian McKellar <[email protected]>
- * Mark McLoughlin <[email protected]>
- */
-
-#include <config.h>
-
-#ifndef HAVE_X11
-#error file should only be compiled when HAVE_X11 is enabled
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <cairo-xlib.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
-#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate-desktop/mate-bg.h>
-
-#include "panel-background-monitor.h"
-#include "panel-util.h"
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-static void panel_background_monitor_changed (PanelBackgroundMonitor *monitor);
-
-static GdkFilterReturn panel_background_monitor_xevent_filter (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data);
-
-struct _PanelBackgroundMonitorClass {
- GObjectClass parent_class;
- void (*changed) (PanelBackgroundMonitor *monitor);
-};
-
-struct _PanelBackgroundMonitor {
- GObject parent_instance;
-
- GdkScreen *screen;
-
- Window xwindow;
- GdkWindow *gdkwindow;
-
- Atom xatom;
- GdkAtom gdkatom;
-
- cairo_surface_t *surface;
- GdkPixbuf *gdkpixbuf;
-
- int width;
- int height;
-
- gboolean display_grabbed;
-};
-
-G_DEFINE_TYPE (PanelBackgroundMonitor, panel_background_monitor, G_TYPE_OBJECT)
-
-static PanelBackgroundMonitor *global_background_monitor = NULL;
-
-static guint signals [LAST_SIGNAL] = { 0 };
-
-gboolean gdk_window_check_composited_wm(GdkWindow* window)
-{
- g_return_val_if_fail (GDK_IS_X11_WINDOW (window), TRUE);
- return gdk_screen_is_composited(gdk_window_get_screen(window));
-}
-
-static void
-panel_background_monitor_finalize (GObject *object)
-{
- PanelBackgroundMonitor *monitor;
-
- monitor = PANEL_BACKGROUND_MONITOR (object);
-
- gdk_window_remove_filter (
- monitor->gdkwindow, panel_background_monitor_xevent_filter, monitor);
- g_signal_handlers_disconnect_by_func (monitor->screen,
- panel_background_monitor_changed, monitor);
-
- if (monitor->surface)
- cairo_surface_destroy (monitor->surface);
- monitor->surface= NULL;
-
- if (monitor->gdkpixbuf)
- g_object_unref (monitor->gdkpixbuf);
- monitor->gdkpixbuf = NULL;
-
- G_OBJECT_CLASS (panel_background_monitor_parent_class)->finalize (object);
-}
-
-static void
-panel_background_monitor_class_init (PanelBackgroundMonitorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- signals [CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PanelBackgroundMonitorClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- object_class->finalize = panel_background_monitor_finalize;
-}
-
-static void
-panel_background_monitor_init (PanelBackgroundMonitor *monitor)
-{
- monitor->screen = NULL;
-
- monitor->gdkwindow = NULL;
- monitor->xwindow = None;
-
- monitor->gdkatom = gdk_atom_intern_static_string ("_XROOTPMAP_ID");
- monitor->xatom = gdk_x11_atom_to_xatom (monitor->gdkatom);
-
- monitor->surface = NULL;
- monitor->gdkpixbuf = NULL;
-
- monitor->display_grabbed = FALSE;
-}
-
-static void
-panel_background_monitor_connect_to_screen (PanelBackgroundMonitor *monitor,
- GdkScreen *screen)
-{
- if (monitor->screen != NULL && monitor->gdkwindow != NULL) {
- gdk_window_remove_filter (monitor->gdkwindow,
- panel_background_monitor_xevent_filter,
- monitor);
- }
-
- monitor->screen = screen;
- g_signal_connect_swapped (screen, "size-changed",
- G_CALLBACK (panel_background_monitor_changed), monitor);
-
- monitor->gdkwindow = gdk_screen_get_root_window (screen);
- monitor->xwindow = GDK_WINDOW_XID (monitor->gdkwindow);
-
- gdk_window_add_filter (
- monitor->gdkwindow, panel_background_monitor_xevent_filter, monitor);
-
- gdk_window_set_events (
- monitor->gdkwindow,
- gdk_window_get_events (monitor->gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
-}
-
-static PanelBackgroundMonitor *
-panel_background_monitor_new (GdkScreen *screen)
-{
- PanelBackgroundMonitor *monitor;
-
- monitor = g_object_new (PANEL_TYPE_BACKGROUND_MONITOR, NULL);
-
- panel_background_monitor_connect_to_screen (monitor, screen);
-
- return monitor;
-}
-
-PanelBackgroundMonitor *
-panel_background_monitor_get_for_screen (GdkScreen *screen)
-{
- g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), NULL);
-
- if (!global_background_monitor) {
- global_background_monitor = panel_background_monitor_new (screen);
-
- g_object_add_weak_pointer (G_OBJECT (global_background_monitor),
- (void **) &global_background_monitor);
-
- return global_background_monitor;
- }
-
- return g_object_ref (global_background_monitor);
-}
-
-static void
-panel_background_monitor_changed (PanelBackgroundMonitor *monitor)
-{
- if (monitor->surface)
- cairo_surface_destroy (monitor->surface);
- monitor->surface = NULL;
-
- if (monitor->gdkpixbuf)
- g_object_unref (monitor->gdkpixbuf);
- monitor->gdkpixbuf = NULL;
-
- g_signal_emit (monitor, signals [CHANGED], 0);
-}
-
-static GdkFilterReturn
-panel_background_monitor_xevent_filter (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data)
-{
- PanelBackgroundMonitor *monitor;
- XEvent *xev;
-
- g_return_val_if_fail (PANEL_IS_BACKGROUND_MONITOR (data), GDK_FILTER_CONTINUE);
-
- monitor = PANEL_BACKGROUND_MONITOR (data);
- xev = (XEvent *) xevent;
-
- if (xev->type == PropertyNotify &&
- xev->xproperty.atom == monitor->xatom &&
- xev->xproperty.window == monitor->xwindow)
- panel_background_monitor_changed (monitor);
-
- return GDK_FILTER_CONTINUE;
-}
-
-static GdkPixbuf *
-panel_background_monitor_tile_background (PanelBackgroundMonitor *monitor,
- int width,
- int height)
-{
- GdkPixbuf *retval;
- int tilewidth, tileheight;
-
- retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
-
- tilewidth = gdk_pixbuf_get_width (monitor->gdkpixbuf);
- tileheight = gdk_pixbuf_get_height (monitor->gdkpixbuf);
-
- if (tilewidth == 1 && tileheight == 1) {
- guchar *pixels;
- int n_channels;
- guint32 pixel = 0;
-
- n_channels = gdk_pixbuf_get_n_channels (monitor->gdkpixbuf);
- pixels = gdk_pixbuf_get_pixels (monitor->gdkpixbuf);
-
- if (pixels) {
- if (n_channels == 4)
- pixel = ((guint32 *) pixels) [0];
- else if (n_channels == 3)
- pixel = pixels [0] << 24 | pixels [1] << 16 | pixels [2] << 8;
- }
-
- gdk_pixbuf_fill (retval, pixel);
- } else {
- unsigned char *data;
- cairo_t *cr;
- cairo_surface_t *surface;
- cairo_pattern_t *pattern;
-
- data = g_malloc (width * height * 4);
- if (!data)
- return NULL;
-
- surface = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_RGB24,
- width, height,
- width * 4);
- cr = cairo_create (surface);
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_paint (cr);
-
- gdk_cairo_set_source_pixbuf (cr, monitor->gdkpixbuf, 0, 0);
- pattern = cairo_get_source (cr);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
-
- cairo_destroy (cr);
- cairo_surface_destroy (surface);
-
- retval = panel_util_cairo_rgbdata_to_pixbuf (data,
- width, height);
-
- g_free (data);
- }
-
- return retval;
-}
-
-static void
-panel_background_monitor_setup_pixbuf (PanelBackgroundMonitor *monitor)
-{
- GdkDisplay *display;
- int rwidth, rheight;
- int pwidth, pheight;
-
- display = gdk_screen_get_display (monitor->screen);
-
- gdk_x11_display_grab (display);
- monitor->display_grabbed = TRUE;
-
- if (!monitor->surface)
- monitor->surface = mate_bg_get_surface_from_root (monitor->screen);
-
- if (!monitor->surface)
- {
- g_warning ("couldn't get background pixmap\n");
- gdk_x11_display_ungrab (display);
- monitor->display_grabbed = FALSE;
- return;
- }
-
- pwidth = cairo_xlib_surface_get_width (monitor->surface);
- pheight = cairo_xlib_surface_get_height (monitor->surface);
-
- gdk_window_get_geometry (monitor->gdkwindow,
- NULL, NULL, &rwidth, &rheight);
-
- monitor->width = MIN (pwidth, rwidth);
- monitor->height = MIN (pheight, rheight);
-
- g_assert (monitor->gdkpixbuf == NULL);
- monitor->gdkpixbuf = gdk_pixbuf_get_from_surface (monitor->surface,
- 0, 0,
- monitor->width, monitor->height);
-
- gdk_x11_display_ungrab (display);
- monitor->display_grabbed = FALSE;
-
- if (monitor->gdkpixbuf == NULL)
- return;
-
- if ((monitor->width < rwidth || monitor->height < rheight)) {
- GdkPixbuf *tiled;
-
- tiled = panel_background_monitor_tile_background (
- monitor, rwidth, rheight);
- g_object_unref (monitor->gdkpixbuf);
- monitor->gdkpixbuf = tiled;
-
- monitor->width = rwidth;
- monitor->height = rheight;
- }
-}
-
-GdkPixbuf *
-panel_background_monitor_get_region (PanelBackgroundMonitor *monitor,
- int x,
- int y,
- int width,
- int height)
-{
- GdkPixbuf *pixbuf, *tmpbuf;
- int subwidth, subheight;
- int subx, suby;
-
- g_return_val_if_fail (monitor, NULL);
- g_return_val_if_fail (GDK_IS_X11_WINDOW (monitor->gdkwindow), NULL);
-
- if (!monitor->gdkpixbuf)
- panel_background_monitor_setup_pixbuf (monitor);
-
- if (!monitor->gdkpixbuf)
- return NULL;
-
- subwidth = MIN (width, monitor->width - x);
- subheight = MIN (height, monitor->height - y);
- /* if x or y are negative numbers */
- subwidth = MIN (subwidth, width + x);
- subheight = MIN (subheight, height + y);
-
- subx = MAX (x, 0);
- suby = MAX (y, 0);
-
- if ((subwidth <= 0) || (subheight <= 0) ||
- (monitor->width-x < 0) || (monitor->height-y < 0) )
- /* region is completely offscreen */
- return gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
- width, height);
-
- pixbuf = gdk_pixbuf_new_subpixbuf (
- monitor->gdkpixbuf, subx, suby, subwidth, subheight);
-
- if ((subwidth < width) || (subheight < height)) {
- tmpbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
- width, height);
- gdk_pixbuf_copy_area (pixbuf, 0, 0, subwidth, subheight,
- tmpbuf, (x < 0) ? -x : 0, (y < 0) ? -y : 0);
- g_object_unref (pixbuf);
- pixbuf = tmpbuf;
- }
-
- return pixbuf;
-}
diff --git a/mate-panel/panel-background-monitor.h b/mate-panel/panel-background-monitor.h
deleted file mode 100644
index 09b7b91e..00000000
--- a/mate-panel/panel-background-monitor.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * panel-background-monitor.h:
- *
- * Copyright (C) 2001, 2002 Ian McKellar <[email protected]>
- * 2002 Sun Microsystems, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Ian McKellar <[email protected]>
- * Mark McLoughlin <[email protected]>
- */
-
-#ifndef __PANEL_BACKGROUND_MONITOR_H__
-#define __PANEL_BACKGROUND_MONITOR_H__
-
-#ifdef PACKAGE_NAME /* only check HAVE_X11 if config.h has been included */
-#ifndef HAVE_X11
-#error file should only be included when HAVE_X11 is enabled
-#endif
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gdk/gdk.h>
-
-#define PANEL_TYPE_BACKGROUND_MONITOR (panel_background_monitor_get_type ())
-#define PANEL_BACKGROUND_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- PANEL_TYPE_BACKGROUND_MONITOR, \
- PanelBackgroundMonitor))
-#define PANEL_BACKGROUND_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
- PANEL_TYPE_BACKGROUND_MONITOR, \
- PanelBackgroundMonitorClass))
-#define PANEL_IS_BACKGROUND_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- PANEL_TYPE_BACKGROUND_MONITOR))
-#define PANEL_IS_BACKGROUND_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- PANEL_TYPE_BACKGROUND_MONITOR))
-#define PANEL_BACKGROUND_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- PANEL_TYPE_BACKGROUND_MONITOR, \
- PanelBackgroundMonitorClass))
-
-typedef struct _PanelBackgroundMonitorClass PanelBackgroundMonitorClass;
-typedef struct _PanelBackgroundMonitor PanelBackgroundMonitor;
-
-gboolean gdk_window_check_composited_wm (GdkWindow* window);
-
-GType panel_background_monitor_get_type (void);
-PanelBackgroundMonitor *panel_background_monitor_get_for_screen (GdkScreen *screen);
-GdkPixbuf *panel_background_monitor_get_region (PanelBackgroundMonitor *monitor,
- int x,
- int y,
- int width,
- int height);
-
-#endif /* __PANEL_BACKGROUND_MONITOR_H__ */
diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c
index 3ce08a5b..b5c475d7 100644
--- a/mate-panel/panel-background.c
+++ b/mate-panel/panel-background.c
@@ -2,6 +2,7 @@
* panel-background.c: panel background rendering
*
* Copyright (C) 2002, 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -38,19 +39,9 @@
#include "panel-util.h"
-
static gboolean panel_background_composite (PanelBackground *background);
static void load_background_file (PanelBackground *background);
-
-static void
-set_pixbuf_background (PanelBackground *background)
-{
- g_assert (background->composited_pattern != NULL);
-
- gdk_window_set_background_pattern (background->window, background->composited_pattern);
-}
-
void panel_background_apply_css (PanelBackground *background, GtkWidget *widget)
{
GtkStyleContext *context;
@@ -143,21 +134,18 @@ panel_background_prepare (PanelBackground *background)
break;
case PANEL_BACK_COLOR:
-#ifdef HAVE_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()) &&
- background->has_alpha &&
- !gdk_window_check_composited_wm(background->window))
- set_pixbuf_background (background);
- else
-#endif /* HAVE_X11 */
- { /* Not using X11, or pixbuf background not needed */
- gdk_window_set_background_rgba (background->window,
- &background->color);
+ {
+ GdkRGBA color = background->color;
+ if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
+ color.alpha = 1.;
}
+ gdk_window_set_background_rgba (background->window, &color);
break;
+ }
case PANEL_BACK_IMAGE:
- set_pixbuf_background (background);
+ g_assert (background->composited_pattern);
+ gdk_window_set_background_pattern (background->window, background->composited_pattern);
break;
default:
@@ -195,69 +183,6 @@ free_composited_resources (PanelBackground *background)
background->composited_pattern = NULL;
}
-#ifdef HAVE_X11
-
-static void _panel_background_transparency(GdkScreen* screen,PanelBackground* background)
-{
- panel_background_composite(background);
-}
-
-static void
-background_changed (PanelBackgroundMonitor *monitor,
- PanelBackground *background)
-{
- GdkPixbuf *tmp;
-
- g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()));
-
- tmp = background->desktop;
-
- background->desktop = panel_background_monitor_get_region (
- background->monitor,
- background->region.x,
- background->region.y,
- background->region.width,
- background->region.height);
-
- if (tmp)
- g_object_unref (tmp);
-
- panel_background_composite (background);
-}
-
-static GdkPixbuf *
-get_desktop_pixbuf (PanelBackground *background)
-{
- GdkPixbuf *desktop;
-
- g_return_val_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()), NULL);
-
- if (!background->monitor) {
- background->monitor =
- panel_background_monitor_get_for_screen (
- gdk_window_get_screen (background->window));
-
- background->monitor_signal =
- g_signal_connect (
- background->monitor, "changed",
- G_CALLBACK (background_changed), background);
- }
- g_signal_connect(gdk_window_get_screen(background->window), "composited-changed",
- G_CALLBACK(_panel_background_transparency),
- background);
-
- desktop = panel_background_monitor_get_region (
- background->monitor,
- background->region.x,
- background->region.y,
- background->region.width,
- background->region.height);
-
- return desktop;
-}
-
-#endif /* HAVE_X11 */
-
static cairo_pattern_t *
composite_image_onto_desktop (PanelBackground *background)
{
@@ -279,24 +204,6 @@ composite_image_onto_desktop (PanelBackground *background)
cr = cairo_create (surface);
-#ifdef HAVE_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
- if (!background->desktop)
- background->desktop = get_desktop_pixbuf (background);
-
- if(!gdk_window_check_composited_wm (background->window)){
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_paint (cr);
-
- if (background->desktop) {
- gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
- }
- }
- }
-#endif /* HAVE_X11 */
-
gdk_cairo_set_source_pixbuf (cr, background->transformed_image, 0, 0);
pattern = cairo_get_source (cr);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
@@ -311,71 +218,6 @@ composite_image_onto_desktop (PanelBackground *background)
return pattern;
}
-static cairo_pattern_t *
-composite_color_onto_desktop (PanelBackground *background)
-{
- cairo_surface_t *surface;
- cairo_pattern_t *pattern;
- cairo_t *cr;
-
- surface = gdk_window_create_similar_surface (background->window,
- CAIRO_CONTENT_COLOR_ALPHA,
- background->region.width,
- background->region.height);
- if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
- cairo_surface_destroy (surface);
- return NULL;
- }
-
- cr = cairo_create (surface);
-
-#ifdef HAVE_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
- if (!background->desktop)
- background->desktop = get_desktop_pixbuf (background);
-
- if(!gdk_window_check_composited_wm (background->window)){
- if (background->desktop) {
- gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
- cairo_paint (cr);
- }
- }
- }
-#endif /* HAVE_X11 */
-
- gdk_cairo_set_source_rgba (cr, &background->color);
- cairo_paint (cr);
-
- cairo_destroy (cr);
-
- pattern = cairo_pattern_create_for_surface (surface);
- cairo_surface_destroy (surface);
-
- return pattern;
-}
-
-static cairo_pattern_t *
-get_composited_pattern (PanelBackground *background)
-{
- cairo_pattern_t *retval = NULL;
-
- switch (background->type) {
- case PANEL_BACK_NONE:
- break;
- case PANEL_BACK_COLOR:
- retval = composite_color_onto_desktop (background);
- break;
- case PANEL_BACK_IMAGE:
- retval = composite_image_onto_desktop (background);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- return retval;
-}
-
static gboolean
panel_background_composite (PanelBackground *background)
{
@@ -386,16 +228,12 @@ panel_background_composite (PanelBackground *background)
switch (background->type) {
case PANEL_BACK_NONE:
- break;
case PANEL_BACK_COLOR:
- if (background->has_alpha)
- background->composited_pattern =
- get_composited_pattern (background);
break;
case PANEL_BACK_IMAGE:
if (background->transformed_image) {
background->composited_pattern =
- get_composited_pattern (background);
+ composite_image_onto_desktop (background);
}
break;
default:
@@ -405,7 +243,6 @@ panel_background_composite (PanelBackground *background)
background->composited = TRUE;
-
panel_background_prepare (background);
return TRUE;
@@ -568,25 +405,6 @@ panel_background_transform (PanelBackground *background)
return TRUE;
}
-#ifdef HAVE_X11
-static void
-disconnect_background_monitor (PanelBackground *background)
-{
- g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()));
- if (background->monitor) {
- g_signal_handler_disconnect (
- background->monitor, background->monitor_signal);
- background->monitor_signal = -1;
- g_object_unref (background->monitor);
- }
- background->monitor = NULL;
-
- if (background->desktop)
- g_object_unref (background->desktop);
- background->desktop = NULL;
-}
-#endif /* HAVE_X11 */
-
static void
panel_background_update_has_alpha (PanelBackground *background)
{
@@ -599,14 +417,7 @@ panel_background_update_has_alpha (PanelBackground *background)
background->loaded_image)
has_alpha = gdk_pixbuf_get_has_alpha (background->loaded_image);
- background->has_alpha = has_alpha;
-
-#ifdef HAVE_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
- if (!has_alpha)
- disconnect_background_monitor (background);
- }
-#endif /* HAVE_X11 */
+ background->has_alpha = (has_alpha != FALSE);
}
static void
@@ -649,26 +460,6 @@ panel_background_set_type (PanelBackground *background,
}
static void
-panel_background_set_opacity_no_update (PanelBackground *background,
- guint16 opacity)
-{
- background->color.alpha = opacity / 65535.0;
- panel_background_update_has_alpha (background);
-}
-
-void
-panel_background_set_opacity (PanelBackground *background,
- guint16 opacity)
-{
- if (background->color.alpha == (opacity / 65535.0))
- return;
-
- free_transformed_resources (background);
- panel_background_set_opacity_no_update (background, opacity);
- panel_background_transform (background);
-}
-
-static void
panel_background_set_color_no_update (PanelBackground *background,
const GdkRGBA *color)
{
@@ -699,16 +490,13 @@ static void
panel_background_set_image_no_update (PanelBackground *background,
const char *image)
{
- if (background->loaded_image)
- g_object_unref (background->loaded_image);
- background->loaded_image = NULL;
-
- if (background->image)
- g_free (background->image);
- background->image = NULL;
+ g_clear_object (&background->loaded_image);
+ g_free (background->image);
if (image && image [0])
background->image = g_strdup (image);
+ else
+ background->image = NULL;
panel_background_update_has_alpha (background);
}
@@ -810,7 +598,7 @@ panel_background_set (PanelBackground *background,
void
panel_background_set_default_style (PanelBackground *background,
- GdkRGBA *color,
+ const GdkRGBA *color,
cairo_pattern_t *pattern)
{
g_return_if_fail (color != NULL);
@@ -828,7 +616,6 @@ panel_background_set_default_style (PanelBackground *background,
panel_background_prepare (background);
}
-
void
panel_background_realized (PanelBackground *background,
GdkWindow *window)
@@ -903,12 +690,6 @@ panel_background_change_region (PanelBackground *background,
background->orientation = orientation;
-#ifdef HAVE_X11
- if (background->desktop)
- g_object_unref (background->desktop);
- background->desktop = NULL;
-#endif /* HAVE_X11 */
-
if (need_to_retransform || ! background->transformed)
/* only retransform the background if we have in
fact changed size/orientation */
@@ -948,12 +729,6 @@ panel_background_init (PanelBackground *background,
background->transformed_image = NULL;
background->composited_pattern = NULL;
-#ifdef HAVE_X11
- background->monitor = NULL;
- background->desktop = NULL;
- background->monitor_signal = -1;
-#endif /* HAVE_X11 */
-
background->window = NULL;
background->default_pattern = NULL;
@@ -976,31 +751,12 @@ panel_background_init (PanelBackground *background,
void
panel_background_free (PanelBackground *background)
{
-#ifdef HAVE_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
- disconnect_background_monitor (background);
- }
-#endif /* HAVE_X11 */
-
free_transformed_resources (background);
- if (background->image)
- g_free (background->image);
- background->image = NULL;
-
- if (background->loaded_image)
- g_object_unref (background->loaded_image);
- background->loaded_image = NULL;
-
-#ifdef HAVE_X11
- if (background->monitor)
- g_object_unref (background->monitor);
- background->monitor = NULL;
-#endif /* HAVE_X11 */
+ g_clear_pointer (&background->image, g_free);
- if (background->window)
- g_object_unref (background->window);
- background->window = NULL;
+ g_clear_object (&background->loaded_image);
+ g_clear_object (&background->window);
if (background->default_pattern)
cairo_pattern_destroy (background->default_pattern);
@@ -1019,13 +775,7 @@ panel_background_make_string (PanelBackground *background,
effective_type = panel_background_effective_type (background);
-#ifdef HAVE_X11
- if (is_using_x11 () &&
- (effective_type == PANEL_BACK_IMAGE ||
- (effective_type == PANEL_BACK_COLOR &&
- background->has_alpha &&
- !gdk_window_check_composited_wm(background->window)))) {
-
+ if (effective_type == PANEL_BACK_IMAGE) {
cairo_surface_t *surface;
if (!background->composited_pattern)
@@ -1038,9 +788,7 @@ panel_background_make_string (PanelBackground *background,
return NULL;
retval = g_strdup_printf ("pixmap:%d,%d,%d", (guint32)cairo_xlib_surface_get_drawable (surface), x, y);
- } else
-#endif
- if (effective_type == PANEL_BACK_COLOR) {
+ } else if (effective_type == PANEL_BACK_COLOR) {
gchar *rgba = gdk_rgba_to_string (&background->color);
retval = g_strdup_printf (
"color:%s",
diff --git a/mate-panel/panel-background.h b/mate-panel/panel-background.h
index fbfbd5d9..8d360776 100644
--- a/mate-panel/panel-background.h
+++ b/mate-panel/panel-background.h
@@ -2,6 +2,7 @@
* panel-background.h: panel background rendering
*
* Copyright (C) 2002, 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -33,10 +34,6 @@
#include "panel-enums.h"
#include "panel-types.h"
-#ifdef HAVE_X11
-#include "panel-background-monitor.h"
-#endif
-
typedef struct _PanelBackground PanelBackground;
typedef void (*PanelBackgroundChangedNotify)
@@ -59,12 +56,6 @@ struct _PanelBackground {
GdkPixbuf *transformed_image;
cairo_pattern_t *composited_pattern;
-#ifdef HAVE_X11
- PanelBackgroundMonitor *monitor;
- GdkPixbuf *desktop;
- gulong monitor_signal;
-#endif /* HAVE_X11 */
-
GdkWindow *window;
cairo_pattern_t *default_pattern;
GdkRGBA default_color;
@@ -93,8 +84,6 @@ void panel_background_set (PanelBackground *background,
gboolean rotate_image);
void panel_background_set_type (PanelBackground *background,
PanelBackgroundType type);
-void panel_background_set_opacity (PanelBackground *background,
- guint16 opacity);
void panel_background_set_color (PanelBackground *background,
const GdkRGBA *color);
void panel_background_set_image (PanelBackground *background,
@@ -106,7 +95,7 @@ void panel_background_set_stretch (PanelBackground *background,
void panel_background_set_rotate (PanelBackground *background,
gboolean rotate_image);
void panel_background_set_default_style (PanelBackground *background,
- GdkRGBA *color,
+ const GdkRGBA *color,
cairo_pattern_t *pattern);
void panel_background_realized (PanelBackground *background,
GdkWindow *window);
diff --git a/mate-panel/panel-bindings.c b/mate-panel/panel-bindings.c
index 493de6ab..4680cb3d 100644
--- a/mate-panel/panel-bindings.c
+++ b/mate-panel/panel-bindings.c
@@ -2,6 +2,7 @@
* panel-bindings.c: panel keybindings support module
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -190,7 +191,7 @@ panel_bindings_mouse_modifier_changed (GSettings *settings,
static void
panel_bindings_initialise (void)
{
- int i;
+ gsize i;
char *str;
if (initialised)
@@ -228,7 +229,7 @@ panel_bindings_initialise (void)
void
panel_bindings_set_entries (GtkBindingSet *binding_set)
{
- int i;
+ gsize i;
if (!initialised)
panel_bindings_initialise ();
diff --git a/mate-panel/panel-bindings.h b/mate-panel/panel-bindings.h
index 0f8cf29d..1abd803f 100644
--- a/mate-panel/panel-bindings.h
+++ b/mate-panel/panel-bindings.h
@@ -2,6 +2,7 @@
* panel-bindings.h: panel keybindings support module
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-config-global.c b/mate-panel/panel-config-global.c
index 1e1f34de..9fb3e618 100644
--- a/mate-panel/panel-config-global.c
+++ b/mate-panel/panel-config-global.c
@@ -2,6 +2,7 @@
* panel-config-global.c: panel global configuration module
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -93,23 +94,23 @@ panel_global_config_set_entry (GSettings *settings, gchar *key)
if (strcmp (key, "tooltips-enabled") == 0)
global_config.tooltips_enabled =
- g_settings_get_boolean (settings, key);
+ (g_settings_get_boolean (settings, key) != FALSE);
else if (strcmp (key, "enable-animations") == 0)
global_config.enable_animations =
- g_settings_get_boolean (settings, key);
+ (g_settings_get_boolean (settings, key) != FALSE);
else if (strcmp (key, "drawer-autoclose") == 0)
global_config.drawer_auto_close =
- g_settings_get_boolean (settings, key);
+ (g_settings_get_boolean (settings, key) != FALSE);
else if (strcmp (key, "confirm-panel-remove") == 0)
global_config.confirm_panel_remove =
- g_settings_get_boolean (settings, key);
+ (g_settings_get_boolean (settings, key) != FALSE);
else if (strcmp (key, "highlight-launchers-on-mouseover") == 0)
global_config.highlight_when_over =
- g_settings_get_boolean (settings, key);
+ (g_settings_get_boolean (settings, key) != FALSE);
}
static void
diff --git a/mate-panel/panel-config-global.h b/mate-panel/panel-config-global.h
index 44bf043f..d889016b 100644
--- a/mate-panel/panel-config-global.h
+++ b/mate-panel/panel-config-global.h
@@ -2,6 +2,7 @@
* panel-config-global.h: panel global configuration module
*
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-context-menu.c b/mate-panel/panel-context-menu.c
index e8cea5e3..5126f7bf 100644
--- a/mate-panel/panel-context-menu.c
+++ b/mate-panel/panel-context-menu.c
@@ -2,6 +2,7 @@
* panel-context-menu.c: context menu for the panels
*
* Copyright (C) 2004 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -115,7 +116,7 @@ panel_context_menu_show_about_dialog (GtkWidget *menuitem)
"version", VERSION,
"copyright", _("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n"
- "Copyright \xc2\xa9 2011-2020 MATE developers"),
+ "Copyright \xc2\xa9 2011-2021 MATE developers"),
"comments", _("This program is responsible for launching other "
"applications and provides useful utilities."),
"authors", authors,
@@ -237,8 +238,9 @@ panel_context_menu_build_edition (PanelWidget *panel_widget,
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- g_signal_connect (G_OBJECT (menuitem), "activate",
- G_CALLBACK (panel_addto_present), panel_widget);
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (panel_addto_present),
+ panel_widget);
if (!panel_profile_id_lists_are_writable ())
gtk_widget_set_sensitive (menuitem, FALSE);
@@ -264,12 +266,12 @@ panel_context_menu_build_edition (PanelWidget *panel_widget,
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
- G_CALLBACK (panel_context_menu_delete_panel),
- panel_widget->toplevel);
- g_signal_connect (G_OBJECT (menu), "show",
- G_CALLBACK (panel_context_menu_setup_delete_panel_item),
- menuitem);
+ g_signal_connect_swapped (menuitem, "activate",
+ G_CALLBACK (panel_context_menu_delete_panel),
+ panel_widget->toplevel);
+ g_signal_connect (menu, "show",
+ G_CALLBACK (panel_context_menu_setup_delete_panel_item),
+ menuitem);
add_menu_separator (menu);
@@ -278,8 +280,8 @@ panel_context_menu_build_edition (PanelWidget *panel_widget,
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (menuitem, "activate",
- G_CALLBACK (panel_context_menu_create_new_panel),
- NULL);
+ G_CALLBACK (panel_context_menu_create_new_panel),
+ NULL);
gtk_widget_set_sensitive (menuitem,
panel_profile_id_lists_are_writable ());
diff --git a/mate-panel/panel-context-menu.h b/mate-panel/panel-context-menu.h
index 4b412fbf..f10bb1b5 100644
--- a/mate-panel/panel-context-menu.h
+++ b/mate-panel/panel-context-menu.h
@@ -2,6 +2,7 @@
* panel-context-menu.h: context menu for the panels
*
* Copyright (C) 2004 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-ditem-editor-dialog.ui b/mate-panel/panel-ditem-editor-dialog.ui
new file mode 100644
index 00000000..0bf7cdb5
--- /dev/null
+++ b/mate-panel/panel-ditem-editor-dialog.ui
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <object class="GtkImage" id="cancel_button_image">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">process-stop</property>
+ </object>
+ <object class="GtkImage" id="close_button_image">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">window-close</property>
+ </object>
+ <object class="GtkImage" id="help_button_image">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">help-browser</property>
+ </object>
+ <object class="GtkImage" id="ok_button_image">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">gtk-apply</property>
+ </object>
+ <object class="GtkImage" id="revert_button_image">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">document-revert</property>
+ </object>
+ <template class="PanelDItemEditor" parent="GtkDialog">
+ <property name="can-focus">False</property>
+ <property name="border-width">5</property>
+ <property name="type-hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="help_button">
+ <property name="label" translatable="yes">_Help</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">help_button_image</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="revert_button">
+ <property name="label" translatable="yes">_Revert</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">revert_button_image</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">close_button_image</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">cancel_button_image</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok_button">
+ <property name="label" translatable="yes">_Ok</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="image">ok_button_image</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox" id="icon_chooser_box">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <!-- n-columns=2 n-rows=4 -->
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="row-spacing">6</property>
+ <property name="column-spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="type_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Type:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">type_combo</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="name_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">name_entry</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="command_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Comm_and:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">command_entry</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="comment_label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Co_mment:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">comment_entry</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="type_combo">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="has-focus">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkEntry" id="command_entry">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="command_browse_button">
+ <property name="label" translatable="yes">_Browse...</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="comment_entry">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-11">help_button</action-widget>
+ <action-widget response="1">revert_button</action-widget>
+ <action-widget response="-7">close_button</action-widget>
+ <action-widget response="-6">cancel_button</action-widget>
+ <action-widget response="-5">ok_button</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/mate-panel/panel-ditem-editor.c b/mate-panel/panel-ditem-editor.c
index 3d9f58a1..f6f0c53a 100644
--- a/mate-panel/panel-ditem-editor.c
+++ b/mate-panel/panel-ditem-editor.c
@@ -2,6 +2,7 @@
* panel-ditem-editor.c:
*
* Copyright (C) 2004, 2006 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* The Mate Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
@@ -39,6 +40,7 @@
#include "panel-ditem-editor.h"
#include "panel-icon-names.h"
#include "panel-util.h"
+#include "panel-schemas.h"
#include "panel-marshal.h"
struct _PanelDItemEditorPrivate
@@ -63,7 +65,7 @@ struct _PanelDItemEditorPrivate
PanelDitemSaveUri save_uri;
gpointer save_uri_data;
- GtkWidget *grid;
+ GtkWidget *icon_chooser_box;
GtkWidget *type_label;
GtkWidget *type_combo;
GtkWidget *name_label;
@@ -88,7 +90,7 @@ struct _PanelDItemEditorPrivate
#define SAVE_FREQUENCY 2
enum {
- REVERT_BUTTON
+ REVERT_BUTTON = 1
};
typedef enum {
@@ -170,7 +172,8 @@ static guint ditem_edit_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (PanelDItemEditor, panel_ditem_editor, GTK_TYPE_DIALOG)
-static void panel_ditem_editor_setup_ui (PanelDItemEditor *dialog);
+static void panel_ditem_editor_setup_ui (PanelDItemEditor *dialog);
+static void panel_ditem_editor_connect_signals (PanelDItemEditor *dialog);
static void type_combo_changed (PanelDItemEditor *dialog);
@@ -196,7 +199,6 @@ static gboolean panel_ditem_editor_get_type_directory (PanelDItemEditor *dialog)
static void panel_ditem_editor_set_type_directory (PanelDItemEditor *dialog,
gboolean type_directory);
-
static PanelDItemEditorType
map_type_from_desktop_item (const char *type,
gboolean terminal)
@@ -232,6 +234,14 @@ panel_ditem_editor_constructor (GType type,
dialog = PANEL_DITEM_EDITOR (obj);
+ /* Icon */
+ dialog->priv->icon_chooser = panel_icon_chooser_new (NULL);
+ panel_icon_chooser_set_fallback_icon_name (PANEL_ICON_CHOOSER (dialog->priv->icon_chooser),
+ PANEL_ICON_LAUNCHER);
+ gtk_box_pack_start (GTK_BOX (dialog->priv->icon_chooser_box), dialog->priv->icon_chooser, FALSE, FALSE, 0);
+ gtk_widget_set_valign (dialog->priv->icon_chooser, GTK_ALIGN_START);
+ gtk_widget_show (dialog->priv->icon_chooser);
+
if (dialog->priv->key_file) {
panel_ditem_editor_key_file_loaded (dialog);
dialog->priv->new_file = FALSE;
@@ -273,6 +283,8 @@ panel_ditem_editor_constructor (GType type,
if (dialog->priv->new_file)
setup_icon_chooser (dialog, NULL);
+ panel_ditem_editor_connect_signals (dialog);
+
return obj;
}
@@ -360,24 +372,26 @@ panel_ditem_editor_dispose (GObject *object)
g_key_file_free (dialog->priv->revert_key_file);
dialog->priv->revert_key_file = NULL;
- if (dialog->priv->uri != NULL)
- g_free (dialog->priv->uri);
- dialog->priv->uri = NULL;
+ g_clear_pointer (&dialog->priv->uri, g_free);
G_OBJECT_CLASS (panel_ditem_editor_parent_class)->dispose (object);
}
static void
-panel_ditem_editor_class_init (PanelDItemEditorClass *class)
+panel_ditem_editor_class_init (PanelDItemEditorClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ const gchar *resource = PANEL_RESOURCE_PATH "panel-ditem-editor-dialog.ui";
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
gobject_class->constructor = panel_ditem_editor_constructor;
gobject_class->get_property = panel_ditem_editor_get_property;
- gobject_class->set_property = panel_ditem_editor_set_property;
-
+ gobject_class->set_property = panel_ditem_editor_set_property;
gobject_class->dispose = panel_ditem_editor_dispose;
+ dialog_class->response = response_cb;
+
ditem_edit_signals[SAVED] =
g_signal_new ("saved",
G_TYPE_FROM_CLASS (gobject_class),
@@ -413,7 +427,7 @@ panel_ditem_editor_class_init (PanelDItemEditorClass *class)
G_TYPE_STRING);
ditem_edit_signals[COMMAND_CHANGED] =
- g_signal_new ("command_changed",
+ g_signal_new ("command-changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelDItemEditorClass,
@@ -449,7 +463,7 @@ panel_ditem_editor_class_init (PanelDItemEditorClass *class)
G_TYPE_STRING);
ditem_edit_signals[ERROR_REPORTED] =
- g_signal_new ("error_reported",
+ g_signal_new ("error-reported",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelDItemEditorClass,
@@ -485,38 +499,23 @@ panel_ditem_editor_class_init (PanelDItemEditorClass *class)
"Whether the edited file is a .directory file or not",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
-static GtkWidget *
-label_new_with_mnemonic (const char *text)
-{
- GtkWidget *label;
- char *bold;
-
- bold = g_strdup_printf ("<b>%s</b>", text);
- label = gtk_label_new_with_mnemonic (bold);
- g_free (bold);
-
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_xalign (GTK_LABEL (label), 1.0);
- gtk_label_set_yalign (GTK_LABEL (label), 0.5);
-
- gtk_widget_show (label);
-
- return label;
-}
-
-static inline void
-grid_attach_label (GtkGrid *grid, GtkWidget *label, int left, int top, int width, int height)
-{
- gtk_grid_attach (grid, label, left, top, width, height);
-}
-
-static inline void
-grid_attach_entry (GtkGrid *grid, GtkWidget *entry, int left, int top, int width, int height)
-{
- gtk_widget_set_hexpand (entry, TRUE);
- gtk_grid_attach (grid, entry, left, top, width, height);
+ gtk_widget_class_set_template_from_resource (widget_class, resource);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, icon_chooser_box);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, type_label);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, type_combo);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, name_label);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, name_entry);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, comment_label);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, comment_entry);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, command_label);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, command_entry);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, command_browse_button);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, help_button);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, revert_button);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, close_button);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, cancel_button);
+ gtk_widget_class_bind_template_child_private (widget_class, PanelDItemEditor, ok_button);
}
static void
@@ -567,8 +566,7 @@ panel_ditem_editor_get_item_type (PanelDItemEditor *dialog)
if (dialog->priv->type_directory)
return PANEL_DITEM_EDITOR_TYPE_DIRECTORY;
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->priv->type_combo),
- &iter))
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->priv->type_combo), &iter))
return PANEL_DITEM_EDITOR_TYPE_NULL;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->priv->type_combo));
@@ -578,105 +576,11 @@ panel_ditem_editor_get_item_type (PanelDItemEditor *dialog)
}
static void
-panel_ditem_editor_make_ui (PanelDItemEditor *dialog)
-{
- PanelDItemEditorPrivate *priv;
- GtkWidget *dialog_vbox;
-
- priv = dialog->priv;
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-
- dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
-
- priv->grid = gtk_grid_new ();
- gtk_container_set_border_width (GTK_CONTAINER (priv->grid), 5);
- gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6);
- gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 12);
- gtk_box_pack_start (GTK_BOX (dialog_vbox), priv->grid, TRUE, TRUE, 0);
- gtk_widget_show (priv->grid);
-
- /* Type */
- priv->type_label = label_new_with_mnemonic (_("_Type:"));
- priv->type_combo = gtk_combo_box_new ();
- gtk_widget_show (priv->type_combo);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->type_label),
- priv->type_combo);
-
- /* Name */
- priv->name_label = label_new_with_mnemonic (_("_Name:"));
- priv->name_entry = gtk_entry_new ();
- gtk_widget_show (priv->name_entry);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->name_label),
- priv->name_entry);
-
- /* Icon */
- priv->icon_chooser = panel_icon_chooser_new (NULL);
- panel_icon_chooser_set_fallback_icon_name (PANEL_ICON_CHOOSER (priv->icon_chooser),
- PANEL_ICON_LAUNCHER);
- gtk_grid_attach (GTK_GRID (priv->grid), priv->icon_chooser, 0, 0, 1, 2);
- gtk_widget_show (priv->icon_chooser);
-
- /* Command */
- priv->command_label = label_new_with_mnemonic ("");
-
- priv->command_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_widget_show (priv->command_hbox);
-
- priv->command_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (priv->command_hbox),
- priv->command_entry,
- TRUE, TRUE, 0);
- gtk_widget_show (priv->command_entry);
-
- priv->command_browse_button = gtk_button_new_with_mnemonic (_("_Browse..."));
- gtk_box_pack_start (GTK_BOX (priv->command_hbox),
- priv->command_browse_button,
- FALSE, FALSE, 0);
- gtk_widget_show (priv->command_browse_button);
-
- /* Comment */
- priv->comment_label = label_new_with_mnemonic (_("Co_mment:"));
- priv->comment_entry = gtk_entry_new ();
- gtk_widget_show (priv->comment_entry);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->comment_label),
- priv->comment_entry);
-
- priv->help_button = panel_dialog_add_button (GTK_DIALOG (dialog),
- _("_Help"), "help-browser",
- GTK_RESPONSE_HELP);
-
- priv->revert_button = panel_dialog_add_button (GTK_DIALOG (dialog),
- _("_Revert"), "document-revert",
- REVERT_BUTTON);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- REVERT_BUTTON,
- FALSE);
-
- priv->close_button = panel_dialog_add_button (GTK_DIALOG (dialog),
- _("_Close"), "window-close",
- GTK_RESPONSE_CLOSE);
-
- priv->cancel_button = panel_dialog_add_button (GTK_DIALOG (dialog),
- _("_Cancel"), "process-stop",
- GTK_RESPONSE_CANCEL);
-
- priv->ok_button = panel_dialog_add_button (GTK_DIALOG (dialog),
- _("_OK"), "gtk-ok",
- GTK_RESPONSE_OK);
-
- /* FIXME: There needs to be a way to edit ALL keys/sections */
-}
-
-static void
panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
{
PanelDItemEditorPrivate *priv;
PanelDItemEditorType type;
gboolean show_combo;
- GList *focus_chain;
priv = dialog->priv;
type = panel_ditem_editor_get_item_type (dialog);
@@ -691,8 +595,8 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
if (!priv->combo_setuped) {
setup_combo (priv->type_combo,
- type_items, G_N_ELEMENTS (type_items),
- NULL);
+ type_items, G_N_ELEMENTS (type_items),
+ NULL);
priv->combo_setuped = TRUE;
}
@@ -717,18 +621,6 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
GtkTreeModel *model;
PanelDItemEditorType buf_type;
- grid_attach_label (GTK_GRID (priv->grid), priv->type_label, 1, 0, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->type_combo, 2, 0, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 1, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 1, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 2, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 2, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 3, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 3, 1, 1);
-
/* FIXME: hack hack hack */
model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->type_combo));
if (!gtk_tree_model_get_iter_first (model, &iter))
@@ -742,37 +634,17 @@ panel_ditem_editor_setup_ui (PanelDItemEditor *dialog)
break;
}
} while (gtk_tree_model_iter_next (model, &iter));
- } else if (type == PANEL_DITEM_EDITOR_TYPE_DIRECTORY) {
- grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 0, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 0, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 1, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 1, 1, 1);
} else {
- grid_attach_label (GTK_GRID (priv->grid), priv->name_label, 1, 0, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->name_entry, 2, 0, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->command_label, 1, 1, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->command_hbox, 2, 1, 1, 1);
-
- grid_attach_label (GTK_GRID (priv->grid), priv->comment_label, 1, 2, 1, 1);
- grid_attach_entry (GTK_GRID (priv->grid), priv->comment_entry, 2, 2, 1, 1);
+ gtk_widget_hide (priv->type_combo);
+ gtk_widget_hide (priv->type_label);
+ if (type == PANEL_DITEM_EDITOR_TYPE_DIRECTORY) {
+ gtk_widget_hide (priv->command_label);
+ gtk_widget_hide (priv->command_entry);
+ gtk_widget_hide (priv->command_browse_button);
+ }
}
type_combo_changed (dialog);
-
- /* set a focus chain since GTK+ doesn't want to put the icon entry
- * as the first widget in the chain */
- focus_chain = NULL;
- focus_chain = g_list_prepend (focus_chain, priv->icon_chooser);
- focus_chain = g_list_prepend (focus_chain, priv->type_combo);
- focus_chain = g_list_prepend (focus_chain, priv->name_entry);
- focus_chain = g_list_prepend (focus_chain, priv->command_hbox);
- focus_chain = g_list_prepend (focus_chain, priv->comment_entry);
- focus_chain = g_list_reverse (focus_chain);
- gtk_container_set_focus_chain (GTK_CONTAINER (priv->grid), focus_chain);
- g_list_free (focus_chain);
-
gtk_widget_grab_focus (priv->name_entry);
}
@@ -788,10 +660,10 @@ panel_ditem_editor_changed (PanelDItemEditor *dialog)
if (dialog->priv->save_timeout != 0)
g_source_remove (dialog->priv->save_timeout);
- dialog->priv->save_timeout = g_timeout_add_seconds (
- SAVE_FREQUENCY,
- panel_ditem_editor_save_timeout,
- dialog);
+ dialog->priv->save_timeout
+ = g_timeout_add_seconds (SAVE_FREQUENCY,
+ panel_ditem_editor_save_timeout,
+ dialog);
/* We can revert to the original state */
if (dialog->priv->revert_key_file != NULL)
@@ -917,13 +789,13 @@ panel_ditem_editor_icon_changed (PanelDItemEditor *dialog,
{
if (icon) {
panel_key_file_set_string (dialog->priv->key_file,
- "Icon", icon);
+ "Icon", icon);
panel_key_file_set_locale_string (dialog->priv->key_file,
- "Icon", icon);
+ "Icon", icon);
}
else
panel_key_file_remove_all_locale_key (dialog->priv->key_file,
- "Icon");
+ "Icon");
g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[ICON_CHANGED], 0,
icon);
@@ -951,8 +823,7 @@ command_browse_chooser_response (GtkFileChooser *chooser,
g_assert_not_reached ();
}
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry),
- uri);
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry), uri);
g_free (uri);
}
@@ -1029,10 +900,10 @@ panel_ditem_editor_connect_signals (PanelDItemEditor *dialog)
priv = dialog->priv;
#define CONNECT_CHANGED(widget, callback) \
- g_signal_connect_swapped (G_OBJECT (widget), "changed", \
+ g_signal_connect_swapped (widget, "changed", \
G_CALLBACK (callback), \
dialog); \
- g_signal_connect_swapped (G_OBJECT (widget), "changed", \
+ g_signal_connect_swapped (widget, "changed", \
G_CALLBACK (panel_ditem_editor_changed), \
dialog);
@@ -1041,6 +912,7 @@ panel_ditem_editor_connect_signals (PanelDItemEditor *dialog)
CONNECT_CHANGED (priv->command_entry, panel_ditem_editor_command_changed);
CONNECT_CHANGED (priv->comment_entry, panel_ditem_editor_comment_changed);
CONNECT_CHANGED (priv->icon_chooser, panel_ditem_editor_icon_changed);
+#undef CONNECT_CHANGED
g_signal_connect_swapped (priv->name_entry, "activate",
G_CALLBACK (panel_ditem_editor_activated),
@@ -1055,13 +927,6 @@ panel_ditem_editor_connect_signals (PanelDItemEditor *dialog)
g_signal_connect_swapped (priv->command_browse_button, "clicked",
G_CALLBACK (command_browse_button_clicked),
dialog);
-
- /* We do a signal connection here rather than overriding the method in
- * class_init because GtkDialog::response is a RUN_LAST signal. We
- * want *our* handler to be run *first*, regardless of whether the user
- * installs response handlers of his own.
- */
- g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
}
static void
@@ -1083,6 +948,7 @@ panel_ditem_editor_block_signals (PanelDItemEditor *dialog)
BLOCK_CHANGED (priv->command_entry, panel_ditem_editor_command_changed);
BLOCK_CHANGED (priv->comment_entry, panel_ditem_editor_comment_changed);
BLOCK_CHANGED (priv->icon_chooser, panel_ditem_editor_icon_changed);
+#undef BLOCK_CHANGED
}
static void
@@ -1104,86 +970,76 @@ panel_ditem_editor_unblock_signals (PanelDItemEditor *dialog)
UNBLOCK_CHANGED (priv->command_entry, panel_ditem_editor_command_changed);
UNBLOCK_CHANGED (priv->comment_entry, panel_ditem_editor_comment_changed);
UNBLOCK_CHANGED (priv->icon_chooser, panel_ditem_editor_icon_changed);
+#undef UNBLOCK_CHANGED
}
static void
panel_ditem_editor_init (PanelDItemEditor *dialog)
{
- PanelDItemEditorPrivate *priv;
-
- priv = panel_ditem_editor_get_instance_private (dialog);
-
- dialog->priv = priv;
-
- priv->key_file = NULL;
- priv->free_key_file = FALSE;
- priv->revert_key_file = NULL;
- priv->reverting = FALSE;
- priv->dirty = FALSE;
- priv->save_timeout = 0;
- priv->uri = NULL;
- priv->type_directory = FALSE;
- priv->new_file = TRUE;
- priv->save_uri = NULL;
- priv->save_uri_data = NULL;
- priv->combo_setuped = FALSE;
- priv->command_browse_filechooser = NULL;
-
- panel_ditem_editor_make_ui (dialog);
- panel_ditem_editor_connect_signals (dialog);
+ dialog->priv = panel_ditem_editor_get_instance_private (dialog);
+ dialog->priv->key_file = NULL;
+ dialog->priv->free_key_file = FALSE;
+ dialog->priv->revert_key_file = NULL;
+ dialog->priv->reverting = FALSE;
+ dialog->priv->dirty = FALSE;
+ dialog->priv->save_timeout = 0;
+ dialog->priv->uri = NULL;
+ dialog->priv->type_directory = FALSE;
+ dialog->priv->new_file = TRUE;
+ dialog->priv->save_uri = NULL;
+ dialog->priv->save_uri_data = NULL;
+ dialog->priv->combo_setuped = FALSE;
+ dialog->priv->command_browse_filechooser = NULL;
+ gtk_widget_init_template (GTK_WIDGET (dialog));
}
static void
type_combo_changed (PanelDItemEditor *dialog)
{
const char *text;
- char *bold;
switch (panel_ditem_editor_get_item_type (dialog)) {
case PANEL_DITEM_EDITOR_TYPE_APPLICATION:
text = _("Comm_and:");
if (dialog->priv->combo_setuped) {
panel_key_file_set_string (dialog->priv->key_file,
- "Type", "Application");
+ "Type", "Application");
panel_key_file_set_boolean (dialog->priv->key_file,
- "Terminal", FALSE);
+ "Terminal", FALSE);
}
break;
case PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION:
text = _("Comm_and:");
if (dialog->priv->combo_setuped) {
panel_key_file_set_string (dialog->priv->key_file,
- "Type", "Application");
+ "Type", "Application");
panel_key_file_set_boolean (dialog->priv->key_file,
- "Terminal", TRUE);
+ "Terminal", TRUE);
}
break;
case PANEL_DITEM_EDITOR_TYPE_LINK:
text = _("_Location:");
if (dialog->priv->combo_setuped) {
panel_key_file_set_string (dialog->priv->key_file,
- "Type", "Link");
+ "Type", "Link");
panel_key_file_remove_key (dialog->priv->key_file,
- "Terminal");
+ "Terminal");
}
break;
case PANEL_DITEM_EDITOR_TYPE_DIRECTORY:
if (dialog->priv->combo_setuped) {
panel_key_file_set_string (dialog->priv->key_file,
- "Type", "Directory");
+ "Type", "Directory");
}
return;
default:
g_assert_not_reached ();
}
- bold = g_strdup_printf ("<b>%s</b>", text);
- gtk_label_set_markup_with_mnemonic (GTK_LABEL (dialog->priv->command_label),
- bold);
- g_free (bold);
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->command_label), text);
gtk_label_set_mnemonic_widget (GTK_LABEL (dialog->priv->command_label),
- dialog->priv->command_entry);
+ dialog->priv->command_entry);
update_chooser_for_type (dialog);
}
@@ -1192,22 +1048,20 @@ static void
setup_icon_chooser (PanelDItemEditor *dialog,
const char *icon_name)
{
- char *buffer;
+ const char *buffer;
if (!icon_name || icon_name[0] == '\0') {
if (dialog->priv->type_directory) {
- buffer = g_strdup (PANEL_ICON_FOLDER);
+ buffer = PANEL_ICON_FOLDER;
} else {
- buffer = g_strdup (PANEL_ICON_LAUNCHER);
+ buffer = PANEL_ICON_LAUNCHER;
}
} else {
- buffer = g_strdup (icon_name);
+ buffer = icon_name;
}
panel_icon_chooser_set_icon (PANEL_ICON_CHOOSER (dialog->priv->icon_chooser),
buffer);
-
- g_free (buffer);
}
/* Conform display to ditem */
@@ -1239,8 +1093,8 @@ panel_ditem_editor_sync_display (PanelDItemEditor *dialog)
type = panel_key_file_get_string (key_file, "Type");
if (!dialog->priv->combo_setuped) {
setup_combo (dialog->priv->type_combo,
- type_items, G_N_ELEMENTS (type_items),
- type);
+ type_items, G_N_ELEMENTS (type_items),
+ type);
dialog->priv->combo_setuped = TRUE;
}
@@ -1256,7 +1110,7 @@ panel_ditem_editor_sync_display (PanelDItemEditor *dialog)
gtk_tree_model_get (model, &iter, COLUMN_TYPE, &buf_type, -1);
if (editor_type == buf_type) {
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->priv->type_combo),
- &iter);
+ &iter);
break;
}
} while (gtk_tree_model_iter_next (model, &iter));
@@ -1274,16 +1128,15 @@ panel_ditem_editor_sync_display (PanelDItemEditor *dialog)
buffer = NULL;
gtk_entry_set_text (GTK_ENTRY (dialog->priv->command_entry),
- buffer ? buffer : "");
+ buffer ? buffer : "");
g_free (buffer);
/* Comment */
buffer = panel_key_file_get_locale_string (key_file, "Comment");
gtk_entry_set_text (GTK_ENTRY (dialog->priv->comment_entry),
- buffer ? buffer : "");
+ buffer ? buffer : "");
g_free (buffer);
-
/* Icon */
buffer = panel_key_file_get_locale_string (key_file, "Icon");
setup_icon_chooser (dialog, buffer);
@@ -1305,7 +1158,7 @@ panel_ditem_editor_save (PanelDItemEditor *dialog,
g_return_val_if_fail (dialog != NULL, FALSE);
g_return_val_if_fail (dialog->priv->save_uri != NULL ||
- dialog->priv->uri != NULL, FALSE);
+ dialog->priv->uri != NULL, FALSE);
if (dialog->priv->save_timeout != 0)
g_source_remove (dialog->priv->save_timeout);
@@ -1368,8 +1221,7 @@ panel_ditem_editor_save (PanelDItemEditor *dialog,
if (dialog->priv->save_uri) {
char *uri;
- uri = dialog->priv->save_uri (dialog,
- dialog->priv->save_uri_data);
+ uri = dialog->priv->save_uri (dialog, dialog->priv->save_uri_data);
if (uri) {
panel_ditem_editor_set_uri (dialog, uri);
@@ -1456,7 +1308,7 @@ response_cb (GtkDialog *dialog,
static void
panel_ditem_editor_revert (PanelDItemEditor *dialog)
{
- int i;
+ gsize i;
char *string;
gboolean boolean;
GKeyFile *key_file;
@@ -1520,10 +1372,10 @@ panel_ditem_editor_revert (PanelDItemEditor *dialog)
if (dialog->priv->save_timeout != 0)
g_source_remove (dialog->priv->save_timeout);
- dialog->priv->save_timeout = g_timeout_add_seconds (
- SAVE_FREQUENCY,
- panel_ditem_editor_save_timeout,
- dialog);
+ dialog->priv->save_timeout =
+ g_timeout_add_seconds (SAVE_FREQUENCY,
+ panel_ditem_editor_save_timeout,
+ dialog);
}
dialog->priv->reverting = FALSE;
@@ -1532,7 +1384,7 @@ panel_ditem_editor_revert (PanelDItemEditor *dialog)
static void
panel_ditem_editor_set_revert (PanelDItemEditor *dialog)
{
- int i;
+ gsize i;
char *string;
gboolean boolean;
GKeyFile *key_file;
@@ -1608,7 +1460,7 @@ panel_ditem_editor_load_uri (PanelDItemEditor *dialog,
GKeyFile *key_file;
g_return_val_if_fail (PANEL_IS_DITEM_EDITOR (dialog), FALSE);
- g_return_val_if_fail (dialog->priv->uri != NULL, FALSE);
+ g_return_val_if_fail (dialog->priv->uri != NULL, FALSE);
key_file = g_key_file_new ();
@@ -1636,7 +1488,7 @@ panel_ditem_editor_new_full (GtkWindow *parent,
const char *title,
gboolean type_directory)
{
- GtkWidget *dialog;
+ PanelDItemEditor *dialog;
dialog = g_object_new (PANEL_TYPE_DITEM_EDITOR,
"title", title,
@@ -1648,7 +1500,7 @@ panel_ditem_editor_new_full (GtkWindow *parent,
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
- return dialog;
+ return GTK_WIDGET (dialog);
}
GtkWidget *
@@ -1700,12 +1552,11 @@ panel_ditem_editor_set_uri (PanelDItemEditor *dialog,
!strcmp (dialog->priv->uri, uri))
return;
- if (dialog->priv->uri)
- g_free (dialog->priv->uri);
- dialog->priv->uri = NULL;
-
+ g_free (dialog->priv->uri);
if (uri && uri [0])
dialog->priv->uri = g_strdup (uri);
+ else
+ dialog->priv->uri = NULL;
g_object_notify (G_OBJECT (dialog), "uri");
}
diff --git a/mate-panel/panel-ditem-editor.h b/mate-panel/panel-ditem-editor.h
index 4b0a13c1..6c5fd57b 100644
--- a/mate-panel/panel-ditem-editor.h
+++ b/mate-panel/panel-ditem-editor.h
@@ -2,6 +2,7 @@
* panel-ditem-editor.h:
*
* Copyright (C) 2004, 2006 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* The Mate Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
diff --git a/mate-panel/panel-enums-gsettings.h b/mate-panel/panel-enums-gsettings.h
index 3f9a7562..bc8a9c42 100644
--- a/mate-panel/panel-enums-gsettings.h
+++ b/mate-panel/panel-enums-gsettings.h
@@ -2,6 +2,7 @@
* panel-enums-gsettings.h:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-enums.h b/mate-panel/panel-enums.h
index 3ba34320..9a5a4532 100644
--- a/mate-panel/panel-enums.h
+++ b/mate-panel/panel-enums.h
@@ -2,6 +2,7 @@
* panel-enums.h:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-force-quit.c b/mate-panel/panel-force-quit.c
index 4ed60fb8..13b0139f 100644
--- a/mate-panel/panel-force-quit.c
+++ b/mate-panel/panel-force-quit.c
@@ -2,6 +2,7 @@
* panel-force-quit.c:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -57,8 +58,12 @@ display_popup_window (GdkScreen *screen)
GtkWidget *image;
GtkWidget *frame;
GtkWidget *label;
- int screen_width, screen_height;
+ int monitor_width, monitor_height;
GtkAllocation allocation;
+ GdkWindow *window;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
retval = gtk_window_new (GTK_WINDOW_POPUP);
atk_object_set_role (gtk_widget_get_accessible (retval), ATK_ROLE_ALERT);
@@ -92,14 +97,18 @@ display_popup_window (GdkScreen *screen)
gtk_widget_realize (retval);
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ display = gdk_display_get_default();
+ window = gtk_widget_get_window (retval);
+ monitor = gdk_display_get_monitor_at_window (display, window);
+ gdk_monitor_get_geometry (monitor, &geometry);
+ monitor_width = geometry.width;
+ monitor_height = geometry.height;
gtk_widget_get_allocation (retval, &allocation);
gtk_window_move (GTK_WINDOW (retval),
- (screen_width - allocation.width) / 2,
- (screen_height - allocation.height) / 2);
+ monitor_width / 2 - (allocation.width / 2 ),
+ monitor_height / 2 - (allocation.height / 2));
gtk_widget_show (GTK_WIDGET (retval));
diff --git a/mate-panel/panel-force-quit.h b/mate-panel/panel-force-quit.h
index 7f67dc76..feeacc8a 100644
--- a/mate-panel/panel-force-quit.h
+++ b/mate-panel/panel-force-quit.h
@@ -2,6 +2,7 @@
* panel-force-quit.h
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/mate-panel/panel-frame.c b/mate-panel/panel-frame.c
index 11ff9c85..414b3db4 100644
--- a/mate-panel/panel-frame.c
+++ b/mate-panel/panel-frame.c
@@ -2,6 +2,7 @@
* panel-frame.c: A frame which only draws certain edges.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -175,7 +176,6 @@ panel_frame_draw (GtkWidget *widget,
GtkBorder padding;
int x, y, width, height;
-
if (edges == PANEL_EDGE_NONE)
return;
diff --git a/mate-panel/panel-frame.h b/mate-panel/panel-frame.h
index f73ebc15..8e165ea3 100644
--- a/mate-panel/panel-frame.h
+++ b/mate-panel/panel-frame.h
@@ -2,6 +2,7 @@
* panel-frame.h: A frame which only draws certain edges.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-globals.h b/mate-panel/panel-globals.h
index f0ae9f45..f9b3d7fd 100644
--- a/mate-panel/panel-globals.h
+++ b/mate-panel/panel-globals.h
@@ -2,6 +2,7 @@
* panel-globals.h: panel global variables
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-layout.c b/mate-panel/panel-layout.c
index 92ffd660..d1710f9e 100644
--- a/mate-panel/panel-layout.c
+++ b/mate-panel/panel-layout.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2011 Novell, Inc.
* 2012 Stefano Karapetsas
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-layout.h b/mate-panel/panel-layout.h
index bc86a4b1..1071dc2e 100644
--- a/mate-panel/panel-layout.h
+++ b/mate-panel/panel-layout.h
@@ -2,6 +2,7 @@
* panel-layout.h: methods to load default panels from file
*
* Copyright (C) 2012 Stefano Karapetsas
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-lockdown.c b/mate-panel/panel-lockdown.c
index d0051082..8750be81 100644
--- a/mate-panel/panel-lockdown.c
+++ b/mate-panel/panel-lockdown.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2004 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -49,7 +50,6 @@ typedef struct {
static PanelLockdown panel_lockdown = { 0, };
-
static inline void
panel_lockdown_invoke_closures (PanelLockdown *lockdown)
{
@@ -64,7 +64,7 @@ locked_down_notify (GSettings *settings,
gchar *key,
PanelLockdown *lockdown)
{
- lockdown->locked_down = g_settings_get_boolean (settings, key);
+ lockdown->locked_down = (g_settings_get_boolean (settings, key) != FALSE);
panel_lockdown_invoke_closures (lockdown);
}
@@ -73,7 +73,7 @@ disable_command_line_notify (GSettings *settings,
gchar *key,
PanelLockdown *lockdown)
{
- lockdown->disable_command_line = g_settings_get_boolean (settings, key);
+ lockdown->disable_command_line = (g_settings_get_boolean (settings, key) != FALSE);
panel_lockdown_invoke_closures (lockdown);
}
@@ -82,7 +82,7 @@ disable_lock_screen_notify (GSettings *settings,
gchar *key,
PanelLockdown *lockdown)
{
- lockdown->disable_lock_screen = g_settings_get_boolean (settings, key);
+ lockdown->disable_lock_screen = (g_settings_get_boolean (settings, key) != FALSE);
panel_lockdown_invoke_closures (lockdown);
}
@@ -91,7 +91,7 @@ disable_log_out_notify (GSettings *settings,
gchar *key,
PanelLockdown *lockdown)
{
- lockdown->disable_log_out = g_settings_get_boolean (settings, key);
+ lockdown->disable_log_out = (g_settings_get_boolean (settings, key) != FALSE);
panel_lockdown_invoke_closures (lockdown);
}
@@ -100,7 +100,7 @@ disable_force_quit_notify (GSettings *settings,
gchar *key,
PanelLockdown *lockdown)
{
- lockdown->disable_force_quit = g_settings_get_boolean (settings, key);
+ lockdown->disable_force_quit = (g_settings_get_boolean (settings, key) != FALSE);
panel_lockdown_invoke_closures (lockdown);
}
@@ -161,34 +161,34 @@ panel_lockdown_init (void)
panel_lockdown.lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
panel_lockdown.locked_down =
- panel_lockdown_load_bool (&panel_lockdown,
- panel_lockdown.panel_settings,
- PANEL_LOCKED_DOWN_KEY,
- G_CALLBACK (locked_down_notify));
+ (panel_lockdown_load_bool (&panel_lockdown,
+ panel_lockdown.panel_settings,
+ PANEL_LOCKED_DOWN_KEY,
+ G_CALLBACK (locked_down_notify)) != FALSE);
panel_lockdown.disable_command_line =
- panel_lockdown_load_bool (&panel_lockdown,
- panel_lockdown.lockdown_settings,
- LOCKDOWN_DISABLE_COMMAND_LINE_KEY,
- G_CALLBACK (disable_command_line_notify));
+ (panel_lockdown_load_bool (&panel_lockdown,
+ panel_lockdown.lockdown_settings,
+ LOCKDOWN_DISABLE_COMMAND_LINE_KEY,
+ G_CALLBACK (disable_command_line_notify)) != FALSE);
panel_lockdown.disable_lock_screen =
- panel_lockdown_load_bool (&panel_lockdown,
- panel_lockdown.lockdown_settings,
- LOCKDOWN_DISABLE_LOCK_SCREEN_KEY,
- G_CALLBACK (disable_lock_screen_notify));
+ (panel_lockdown_load_bool (&panel_lockdown,
+ panel_lockdown.lockdown_settings,
+ LOCKDOWN_DISABLE_LOCK_SCREEN_KEY,
+ G_CALLBACK (disable_lock_screen_notify)) != FALSE);
panel_lockdown.disable_log_out =
- panel_lockdown_load_bool (&panel_lockdown,
- panel_lockdown.lockdown_settings,
- LOCKDOWN_DISABLE_LOG_OUT_KEY,
- G_CALLBACK (disable_log_out_notify));
+ (panel_lockdown_load_bool (&panel_lockdown,
+ panel_lockdown.lockdown_settings,
+ LOCKDOWN_DISABLE_LOG_OUT_KEY,
+ G_CALLBACK (disable_log_out_notify)) != FALSE);
panel_lockdown.disable_force_quit =
- panel_lockdown_load_bool (&panel_lockdown,
- panel_lockdown.panel_settings,
- PANEL_DISABLE_FORCE_QUIT_KEY,
- G_CALLBACK (disable_force_quit_notify));
+ (panel_lockdown_load_bool (&panel_lockdown,
+ panel_lockdown.panel_settings,
+ PANEL_DISABLE_FORCE_QUIT_KEY,
+ G_CALLBACK (disable_force_quit_notify)) != FALSE);
panel_lockdown.disabled_applets =
panel_lockdown_load_disabled_applets (&panel_lockdown,
@@ -269,12 +269,10 @@ panel_lockdown_get_disable_force_quit (void)
gboolean
panel_lockdown_is_applet_disabled (const char *iid)
{
- gint i;
-
g_assert (panel_lockdown.initialized != FALSE);
if (panel_lockdown.disabled_applets)
- for (i = 0; panel_lockdown.disabled_applets[i]; i++)
+ for (gint i = 0; panel_lockdown.disabled_applets[i]; i++)
if (!strcmp (panel_lockdown.disabled_applets[i], iid))
return TRUE;
@@ -286,9 +284,7 @@ panel_lockdown_notify_find (GSList *closures,
GCallback callback_func,
gpointer user_data)
{
- GSList *l;
-
- for (l = closures; l; l = l->next) {
+ for (GSList *l = closures; l; l = l->next) {
GCClosure *cclosure = l->data;
GClosure *closure = l->data;
diff --git a/mate-panel/panel-lockdown.h b/mate-panel/panel-lockdown.h
index a2e3703e..68c1a0bf 100644
--- a/mate-panel/panel-lockdown.h
+++ b/mate-panel/panel-lockdown.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2004 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c
index f2e71353..b348ae48 100644
--- a/mate-panel/panel-menu-bar.c
+++ b/mate-panel/panel-menu-bar.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2003 Sun Microsystems, Inc.
* Copyright (C) 2004 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -31,6 +32,8 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <libmate-desktop/mate-image-menu-item.h>
+
#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-launch.h>
#include <libpanel-util/panel-show.h>
@@ -105,7 +108,7 @@ static void panel_menu_bar_setup_tooltip(PanelMenuBar* menubar)
g_signal_connect(menubar->priv->desktop_item, "activate", G_CALLBACK (panel_menu_bar_hide_tooltip_and_focus), menubar);
/* Reset tooltip when the menu bar is not used */
- g_signal_connect(GTK_MENU_SHELL (menubar), "deactivate", G_CALLBACK (panel_menu_bar_reinit_tooltip), menubar);
+ g_signal_connect(menubar, "deactivate", G_CALLBACK (panel_menu_bar_reinit_tooltip), menubar);
}
static void
@@ -134,12 +137,12 @@ panel_menu_bar_update_visibility (GSettings *settings,
image = gtk_image_new_from_icon_name(str, icon_size);
else
image = gtk_image_new_from_icon_name(PANEL_ICON_MAIN_MENU, icon_size);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item), image);
+ mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (menubar->priv->applications_item), image);
gtk_image_set_pixel_size (GTK_IMAGE (image), icon_height);
g_free (str);
}
else
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item), NULL);
+ mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (menubar->priv->applications_item), NULL);
}
static void panel_menu_bar_init(PanelMenuBar* menubar)
diff --git a/mate-panel/panel-menu-bar.h b/mate-panel/panel-menu-bar.h
index 5c5f5c0e..f83bf1f1 100644
--- a/mate-panel/panel-menu-bar.h
+++ b/mate-panel/panel-menu-bar.h
@@ -2,6 +2,7 @@
* panel-menu-bar.h: panel Applications/Places/Desktop menu bar
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-menu-button.c b/mate-panel/panel-menu-button.c
index 64d96945..92925fd8 100644
--- a/mate-panel/panel-menu-button.c
+++ b/mate-panel/panel-menu-button.c
@@ -2,6 +2,7 @@
* panel-menu-button.c: panel menu button
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -107,7 +108,7 @@ static const char *
panel_menu_path_root_to_filename (MenuPathRoot path_root)
{
const char *retval;
- int i;
+ gsize i;
retval = NULL;
@@ -125,7 +126,7 @@ static const char *
panel_menu_filename_to_scheme (const char *filename)
{
const char *retval;
- int i;
+ gsize i;
gchar *basename;
retval = NULL;
@@ -161,7 +162,7 @@ static MenuPathRoot
panel_menu_scheme_to_path_root (const char *scheme)
{
MenuPathRoot retval;
- int i;
+ gsize i;
retval = LAST_MENU;
@@ -214,17 +215,10 @@ panel_menu_button_finalize (GObject *object)
button->priv->menu = NULL;
}
- g_free (button->priv->applet_id);
- button->priv->applet_id = NULL;
-
- g_free (button->priv->menu_path);
- button->priv->menu_path = NULL;
-
- g_free (button->priv->custom_icon);
- button->priv->custom_icon = NULL;
-
- g_free (button->priv->tooltip);
- button->priv->tooltip = NULL;
+ g_clear_pointer (&button->priv->applet_id, g_free);
+ g_clear_pointer (&button->priv->menu_path, g_free);
+ g_clear_pointer (&button->priv->custom_icon, g_free);
+ g_clear_pointer (&button->priv->tooltip, g_free);
G_OBJECT_CLASS (panel_menu_button_parent_class)->finalize (object);
}
@@ -465,19 +459,21 @@ panel_menu_button_popup_menu (PanelMenuButton *button,
switch (panel_toplevel_get_orientation (button->priv->toplevel)) {
case PANEL_ORIENTATION_TOP:
widget_anchor = GDK_GRAVITY_SOUTH_WEST;
- g_message ("PANEL_ORIENTATION_TOP");
+ /*g_message ("PANEL_ORIENTATION_TOP"); comment this out by default,
+ *it is useful in debugging menu issues in wayland so don't remove it
+ */
break;
case PANEL_ORIENTATION_BOTTOM:
menu_anchor = GDK_GRAVITY_SOUTH_WEST;
- g_message ("PANEL_ORIENTATION_BOTTOM");
+ /*g_message ("PANEL_ORIENTATION_BOTTOM");*/
break;
case PANEL_ORIENTATION_LEFT:
widget_anchor = GDK_GRAVITY_NORTH_EAST;
- g_message ("PANEL_ORIENTATION_LEFT");
+ /*g_message ("PANEL_ORIENTATION_LEFT");*/
break;
case PANEL_ORIENTATION_RIGHT:
menu_anchor = GDK_GRAVITY_NORTH_EAST;
- g_message ("PANEL_ORIENTATION_RIGHT");
+ /*g_message ("PANEL_ORIENTATION_RIGHT");*/
break;
}
@@ -589,7 +585,6 @@ panel_menu_button_class_init (PanelMenuButtonClass *klass)
FALSE,
G_PARAM_READWRITE));
-
g_object_class_install_property (
gobject_class,
PROP_HAS_ARROW,
@@ -824,8 +819,6 @@ panel_menu_button_set_menu_path (PanelMenuButton *button,
return;
g_free (button->priv->menu_path);
- button->priv->menu_path = NULL;
-
button->priv->menu_path = g_strdup (menu_path);
if (button->priv->menu)
@@ -842,10 +835,10 @@ panel_menu_button_set_custom_icon (PanelMenuButton *button,
g_return_if_fail (PANEL_IS_MENU_BUTTON (button));
g_free (button->priv->custom_icon);
- button->priv->custom_icon = NULL;
-
if (custom_icon && custom_icon [0])
button->priv->custom_icon = g_strdup (custom_icon);
+ else
+ button->priv->custom_icon = NULL;
panel_menu_button_set_icon (button);
}
@@ -857,11 +850,11 @@ panel_menu_button_set_tooltip (PanelMenuButton *button,
g_return_if_fail (PANEL_IS_MENU_BUTTON (button));
g_free (button->priv->tooltip);
- button->priv->tooltip = NULL;
-
if (tooltip && tooltip [0]) {
button->priv->tooltip = g_strdup (tooltip);
panel_util_set_tooltip_text (GTK_WIDGET (button), tooltip);
+ } else {
+ button->priv->tooltip = NULL;
}
}
@@ -876,11 +869,12 @@ panel_menu_button_set_use_menu_path (PanelMenuButton *button,
if (button->priv->use_menu_path == use_menu_path)
return;
- button->priv->use_menu_path = use_menu_path;
+ button->priv->use_menu_path = (use_menu_path != FALSE);
- if (button->priv->menu)
+ if (button->priv->menu) {
gtk_menu_detach (GTK_MENU (button->priv->menu));
- button->priv->menu = NULL;
+ button->priv->menu = NULL;
+ }
panel_menu_button_set_icon (button);
}
@@ -915,7 +909,6 @@ panel_menu_button_set_has_arrow (PanelMenuButton *button,
button_widget_set_has_arrow (BUTTON_WIDGET (button), has_arrow);
}
-
void
panel_menu_button_load_from_gsettings (PanelWidget *panel,
gboolean locked,
diff --git a/mate-panel/panel-menu-button.h b/mate-panel/panel-menu-button.h
index 829744b3..2a9d2d32 100644
--- a/mate-panel/panel-menu-button.h
+++ b/mate-panel/panel-menu-button.h
@@ -2,6 +2,7 @@
* panel-menu-button.h: panel menu button
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c
index a196b0be..14b58701 100644
--- a/mate-panel/panel-menu-items.c
+++ b/mate-panel/panel-menu-items.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2005 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -40,6 +41,7 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <libmate-desktop/mate-gsettings.h>
+#include <libmate-desktop/mate-image-menu-item.h>
#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-glib.h>
@@ -58,6 +60,7 @@
#include "panel-schemas.h"
#define MAX_BOOKMARK_ITEMS 100
+#define N_MENU_ITEM_SIGNALS 9
struct _PanelPlaceMenuItemPrivate {
GtkWidget *menu;
@@ -72,15 +75,7 @@ struct _PanelPlaceMenuItemPrivate {
GFileMonitor *bookmarks_monitor;
GVolumeMonitor *volume_monitor;
- gulong drive_changed_id;
- gulong drive_connected_id;
- gulong drive_disconnected_id;
- gulong volume_added_id;
- gulong volume_changed_id;
- gulong volume_removed_id;
- gulong mount_added_id;
- gulong mount_changed_id;
- gulong mount_removed_id;
+ gulong signal_id [N_MENU_ITEM_SIGNALS];
guint use_image : 1;
};
@@ -93,8 +88,8 @@ struct _PanelDesktopMenuItemPrivate {
guint append_lock_logout : 1;
};
-G_DEFINE_TYPE_WITH_PRIVATE (PanelPlaceMenuItem, panel_place_menu_item, GTK_TYPE_IMAGE_MENU_ITEM)
-G_DEFINE_TYPE_WITH_PRIVATE (PanelDesktopMenuItem, panel_desktop_menu_item, GTK_TYPE_IMAGE_MENU_ITEM)
+G_DEFINE_TYPE_WITH_PRIVATE (PanelPlaceMenuItem, panel_place_menu_item, MATE_TYPE_IMAGE_MENU_ITEM)
+G_DEFINE_TYPE_WITH_PRIVATE (PanelDesktopMenuItem, panel_desktop_menu_item, MATE_TYPE_IMAGE_MENU_ITEM)
static void activate_uri_on_screen(const char* uri, GdkScreen* screen)
{
@@ -148,7 +143,6 @@ panel_menu_items_append_from_desktop (GtkWidget *menu,
char *uri;
char *type;
gboolean is_application;
- char *tryexec;
char *icon;
char *name;
char *comment;
@@ -203,7 +197,7 @@ panel_menu_items_append_from_desktop (GtkWidget *menu,
g_free (type);
if (is_application) {
- tryexec = panel_key_file_get_string (key_file, "TryExec");
+ char *tryexec = panel_key_file_get_string (key_file, "TryExec");
if (tryexec) {
char *prog;
@@ -237,7 +231,7 @@ panel_menu_items_append_from_desktop (GtkWidget *menu,
if (use_icon) {
item = panel_image_menu_item_new ();
} else {
- item = gtk_image_menu_item_new ();
+ item = mate_image_menu_item_new ();
}
setup_menuitem_with_icon (item, panel_menu_icon_get_size (),
@@ -250,8 +244,9 @@ panel_menu_items_append_from_desktop (GtkWidget *menu,
G_CALLBACK (panel_menu_item_activate_desktop_file),
g_strdup (full_path),
(GClosureNotify) G_CALLBACK (g_free), 0);
- g_signal_connect (G_OBJECT (item), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
uri = g_filename_to_uri (full_path, NULL, NULL);
@@ -299,8 +294,9 @@ panel_menu_items_append_place_item (const char *icon_name,
g_signal_connect_data (item, "activate", callback, user_data,
(GClosureNotify) G_CALLBACK (g_free), 0);
- g_signal_connect (G_OBJECT (item), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
if (g_str_has_prefix (uri, "file:")) /*Links only work for local files*/
setup_uri_drag (item, uri, icon_name, GDK_ACTION_LINK);
@@ -316,7 +312,7 @@ panel_menu_items_create_action_item_full (PanelActionButtonType action_type,
if (panel_action_get_is_disabled (action_type))
return NULL;
- item = gtk_image_menu_item_new ();
+ item = mate_image_menu_item_new ();
setup_menuitem_with_icon (item,
panel_menu_icon_get_size (),
NULL,
@@ -329,9 +325,11 @@ panel_menu_items_create_action_item_full (PanelActionButtonType action_type,
panel_action_get_tooltip (action_type));
g_signal_connect (item, "activate",
- panel_action_get_invoke (action_type), NULL);
- g_signal_connect (G_OBJECT (item), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ panel_action_get_invoke (action_type),
+ NULL);
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
setup_internal_applet_drag (item, action_type);
return item;
@@ -410,7 +408,6 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu, guint max_items_or_
char *line = (char*) l->data;
if (line[0] && !g_hash_table_lookup (table, line)) {
- GFile *file;
char *space;
char *label;
gboolean keep;
@@ -431,7 +428,7 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu, guint max_items_or_
keep = TRUE;
if (!keep) {
- file = g_file_new_for_uri (line);
+ GFile *file = g_file_new_for_uri (line);
keep = !g_file_is_native (file) ||
g_file_query_exists (file, NULL);
g_object_unref (file);
@@ -460,7 +457,7 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu, guint max_items_or_
} else {
GtkWidget *item;
- item = gtk_image_menu_item_new ();
+ item = mate_image_menu_item_new ();
setup_menuitem_with_icon (item, panel_menu_icon_get_size (),
NULL, PANEL_ICON_BOOKMARKS,
_("Bookmarks"));
@@ -545,15 +542,16 @@ drive_poll_for_media_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- GdkScreen *screen;
- GError *error;
- char *primary;
- char *name;
+ GError *error;
error = NULL;
if (!g_drive_poll_for_media_finish (G_DRIVE (source_object),
res, &error)) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
+ GdkScreen *screen;
+ char *primary;
+ char *name;
+
screen = GDK_SCREEN (user_data);
name = g_drive_get_name (G_DRIVE (source_object));
@@ -614,8 +612,9 @@ panel_menu_item_append_drive (GtkWidget *menu,
g_object_ref (drive),
(GClosureNotify) G_CALLBACK (g_object_unref), 0);
- g_signal_connect (G_OBJECT (item), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
}
typedef struct {
@@ -633,10 +632,10 @@ volume_mount_cb (GObject *source_object,
error = NULL;
if (!g_volume_mount_finish (G_VOLUME (source_object), res, &error)) {
- char *primary;
- char *name;
-
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
+ char *primary;
+ char *name;
+
name = g_volume_get_name (G_VOLUME (source_object));
primary = g_strdup_printf (_("Unable to mount %s"),
name);
@@ -714,8 +713,9 @@ panel_menu_item_append_volume (GtkWidget *menu,
g_object_ref (volume),
(GClosureNotify) G_CALLBACK (g_object_unref), 0);
- g_signal_connect (G_OBJECT (item), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
}
static void
@@ -903,19 +903,19 @@ panel_place_menu_item_append_local_gio (PanelPlaceMenuItem *place_item,
if (g_slist_length (items) <= g_settings_get_uint (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)) {
add_menu = menu;
} else {
- GtkWidget *item;
+ GtkWidget *menu_item;
- item = gtk_image_menu_item_new ();
- setup_menuitem_with_icon (item, panel_menu_icon_get_size (),
- NULL,
- PANEL_ICON_REMOVABLE_MEDIA,
- _("Removable Media"));
+ menu_item = mate_image_menu_item_new ();
+ setup_menuitem_with_icon (menu_item, panel_menu_icon_get_size (),
+ NULL,
+ PANEL_ICON_REMOVABLE_MEDIA,
+ _("Removable Media"));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
add_menu = create_empty_menu ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), add_menu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), add_menu);
}
for (sl = items; sl; sl = sl->next) {
@@ -982,7 +982,6 @@ panel_place_menu_item_append_remote_gio (PanelPlaceMenuItem *place_item,
}
g_object_unref (root);
-
add_mounts = g_slist_prepend (add_mounts, mount);
}
add_mounts = g_slist_reverse (add_mounts);
@@ -1015,16 +1014,15 @@ panel_place_menu_item_append_remote_gio (PanelPlaceMenuItem *place_item,
g_list_free (mounts);
}
-
static GtkWidget *
panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
{
GtkWidget *places_menu;
- GtkWidget *item;
char *gsettings_name = NULL;
char *name;
char *uri;
GFile *file;
+ int recent_items_limit;
places_menu = panel_create_menu ();
@@ -1101,7 +1099,7 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
if (panel_is_program_in_path ("caja-connect-server") ||
panel_is_program_in_path ("nautilus-connect-server") ||
panel_is_program_in_path ("nemo-connect-server")) {
- item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
+ GtkWidget *item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
if (item != NULL)
gtk_menu_shell_append (GTK_MENU_SHELL (places_menu),
item);
@@ -1120,8 +1118,12 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
NULL,
FALSE);
+ recent_items_limit = g_settings_get_int (place_item->priv->menubar_settings,
+ PANEL_MENU_BAR_MAX_RECENT_ITEMS);
+
panel_recent_append_documents_menu (places_menu,
- place_item->priv->recent_manager);
+ place_item->priv->recent_manager,
+ recent_items_limit);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
GtkWidget *toplevel = gtk_widget_get_toplevel (places_menu);
GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
@@ -1260,73 +1262,31 @@ static void
panel_place_menu_item_finalize (GObject *object)
{
PanelPlaceMenuItem *menuitem = (PanelPlaceMenuItem *) object;
+ guint i;
- if (menuitem->priv->caja_desktop_settings) {
- g_object_unref (menuitem->priv->caja_desktop_settings);
- menuitem->priv->caja_desktop_settings = NULL;
- }
- if (menuitem->priv->caja_prefs_settings) {
- g_object_unref (menuitem->priv->caja_prefs_settings);
- menuitem->priv->caja_prefs_settings = NULL;
- }
-
- g_object_unref (menuitem->priv->menubar_settings);
- menuitem->priv->menubar_settings = NULL;
+ g_clear_object (&menuitem->priv->caja_desktop_settings);
+ g_clear_object (&menuitem->priv->caja_prefs_settings);
+ g_clear_object (&menuitem->priv->menubar_settings);
if (menuitem->priv->bookmarks_monitor != NULL) {
g_file_monitor_cancel (menuitem->priv->bookmarks_monitor);
- g_object_unref (menuitem->priv->bookmarks_monitor);
+ g_clear_object (&menuitem->priv->bookmarks_monitor);
}
- menuitem->priv->bookmarks_monitor = NULL;
-
- if (menuitem->priv->drive_changed_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->drive_changed_id);
- menuitem->priv->drive_changed_id = 0;
-
- if (menuitem->priv->drive_connected_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->drive_connected_id);
- menuitem->priv->drive_connected_id = 0;
-
- if (menuitem->priv->drive_disconnected_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->drive_disconnected_id);
- menuitem->priv->drive_disconnected_id = 0;
-
- if (menuitem->priv->volume_added_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->volume_added_id);
- menuitem->priv->volume_added_id = 0;
-
- if (menuitem->priv->volume_changed_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->volume_changed_id);
- menuitem->priv->volume_changed_id = 0;
-
- if (menuitem->priv->volume_removed_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->volume_removed_id);
- menuitem->priv->volume_removed_id = 0;
-
- if (menuitem->priv->mount_added_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->mount_added_id);
- menuitem->priv->mount_added_id = 0;
-
- if (menuitem->priv->mount_changed_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->mount_changed_id);
- menuitem->priv->mount_changed_id = 0;
-
- if (menuitem->priv->mount_removed_id)
- g_signal_handler_disconnect (menuitem->priv->volume_monitor,
- menuitem->priv->mount_removed_id);
- menuitem->priv->mount_removed_id = 0;
-
- if (menuitem->priv->volume_monitor != NULL)
- g_object_unref (menuitem->priv->volume_monitor);
- menuitem->priv->volume_monitor = NULL;
+
+ for (i = 0; i < N_MENU_ITEM_SIGNALS; i++) {
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&menuitem->priv->signal_id [i],
+ menuitem->priv->volume_monitor);
+#else
+ if (menuitem->priv->signal_id [i] != 0) {
+ g_signal_handler_disconnect (menuitem->priv->volume_monitor,
+ menuitem->priv->signal_id [i]);
+ menuitem->priv->signal_id [i] = 0;
+ }
+#endif
+ }
+
+ g_clear_object (&menuitem->priv->volume_monitor);
G_OBJECT_CLASS (panel_place_menu_item_parent_class)->finalize (object);
}
@@ -1348,6 +1308,7 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem)
GFile *bookmark;
char *bookmarks_filename;
GError *error;
+ guint i;
menuitem->priv = panel_place_menu_item_get_instance_private (menuitem);
@@ -1380,6 +1341,10 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem)
"changed::" PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU,
G_CALLBACK (panel_place_menu_item_key_changed),
G_OBJECT (menuitem));
+ g_signal_connect (menuitem->priv->menubar_settings,
+ "changed::" PANEL_MENU_BAR_MAX_RECENT_ITEMS,
+ G_CALLBACK (panel_place_menu_item_key_changed),
+ G_OBJECT (menuitem));
menuitem->priv->recent_manager = gtk_recent_manager_get_default ();
@@ -1398,8 +1363,7 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem)
bookmarks_filename, error->message);
g_error_free (error);
} else {
- g_signal_connect (G_OBJECT (menuitem->priv->bookmarks_monitor),
- "changed",
+ g_signal_connect (menuitem->priv->bookmarks_monitor, "changed",
(GCallback) panel_place_menu_item_gtk_bookmarks_changed,
menuitem);
}
@@ -1409,42 +1373,45 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem)
menuitem->priv->volume_monitor = g_volume_monitor_get ();
- menuitem->priv->drive_changed_id = g_signal_connect (menuitem->priv->volume_monitor,
- "drive-changed",
- G_CALLBACK (panel_place_menu_item_drives_changed),
- menuitem);
- menuitem->priv->drive_connected_id = g_signal_connect (menuitem->priv->volume_monitor,
- "drive-connected",
- G_CALLBACK (panel_place_menu_item_drives_changed),
- menuitem);
- menuitem->priv->drive_disconnected_id = g_signal_connect (menuitem->priv->volume_monitor,
- "drive-disconnected",
- G_CALLBACK (panel_place_menu_item_drives_changed),
- menuitem);
- menuitem->priv->volume_added_id = g_signal_connect (menuitem->priv->volume_monitor,
- "volume-added",
- G_CALLBACK (panel_place_menu_item_volumes_changed),
- menuitem);
- menuitem->priv->volume_changed_id = g_signal_connect (menuitem->priv->volume_monitor,
- "volume-changed",
- G_CALLBACK (panel_place_menu_item_volumes_changed),
- menuitem);
- menuitem->priv->volume_removed_id = g_signal_connect (menuitem->priv->volume_monitor,
- "volume-removed",
- G_CALLBACK (panel_place_menu_item_volumes_changed),
- menuitem);
- menuitem->priv->mount_added_id = g_signal_connect (menuitem->priv->volume_monitor,
- "mount-added",
- G_CALLBACK (panel_place_menu_item_mounts_changed),
- menuitem);
- menuitem->priv->mount_changed_id = g_signal_connect (menuitem->priv->volume_monitor,
- "mount-changed",
- G_CALLBACK (panel_place_menu_item_mounts_changed),
- menuitem);
- menuitem->priv->mount_removed_id = g_signal_connect (menuitem->priv->volume_monitor,
- "mount-removed",
- G_CALLBACK (panel_place_menu_item_mounts_changed),
- menuitem);
+ i = 0;
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "drive-changed",
+ G_CALLBACK (panel_place_menu_item_drives_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "drive-connected",
+ G_CALLBACK (panel_place_menu_item_drives_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "drive-disconnected",
+ G_CALLBACK (panel_place_menu_item_drives_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "volume-added",
+ G_CALLBACK (panel_place_menu_item_volumes_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "volume-changed",
+ G_CALLBACK (panel_place_menu_item_volumes_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "volume-removed",
+ G_CALLBACK (panel_place_menu_item_volumes_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "mount-added",
+ G_CALLBACK (panel_place_menu_item_mounts_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "mount-changed",
+ G_CALLBACK (panel_place_menu_item_mounts_changed),
+ menuitem);
+ menuitem->priv->signal_id [i++] =
+ g_signal_connect (menuitem->priv->volume_monitor, "mount-removed",
+ G_CALLBACK (panel_place_menu_item_mounts_changed),
+ menuitem);
+
+ g_assert (i == N_MENU_ITEM_SIGNALS);
}
@@ -1488,7 +1455,7 @@ GtkWidget* panel_place_menu_item_new(gboolean use_image)
setup_menuitem(GTK_WIDGET(menuitem), image ? panel_menu_icon_get_size() : GTK_ICON_SIZE_INVALID, image, _("Places"));
- menuitem->priv->use_image = use_image;
+ menuitem->priv->use_image = (use_image != FALSE);
menuitem->priv->menu = panel_place_menu_item_create_menu(menuitem);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menuitem->priv->menu);
@@ -1516,9 +1483,9 @@ panel_desktop_menu_item_new (gboolean use_image,
image,
_("System"));
- menuitem->priv->use_image = use_image;
+ menuitem->priv->use_image = (use_image != FALSE);
- menuitem->priv->append_lock_logout = append_lock_logout;
+ menuitem->priv->append_lock_logout = (append_lock_logout != FALSE);
if (append_lock_logout)
panel_lockdown_notify_add (G_CALLBACK (panel_desktop_menu_item_recreate_menu),
menuitem);
diff --git a/mate-panel/panel-menu-items.h b/mate-panel/panel-menu-items.h
index 054a7e4f..1b94a2d8 100644
--- a/mate-panel/panel-menu-items.h
+++ b/mate-panel/panel-menu-items.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -20,7 +21,6 @@
* Vincent Untz <[email protected]>
*/
-
#ifndef __PANEL_MENU_ITEMS_H__
#define __PANEL_MENU_ITEMS_H__
@@ -54,8 +54,6 @@ struct _PanelPlaceMenuItemClass {
GType panel_place_menu_item_get_type (void) G_GNUC_CONST;
-
-
#define PANEL_TYPE_DESKTOP_MENU_ITEM (panel_desktop_menu_item_get_type ())
#define PANEL_DESKTOP_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_DESKTOP_MENU_ITEM, PanelDesktopMenuItem))
#define PANEL_DESKTOP_MENU_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_DESKTOP_MENU_ITEM, PanelDesktopMenuItemClass))
@@ -79,7 +77,6 @@ struct _PanelDesktopMenuItemClass {
GType panel_desktop_menu_item_get_type (void) G_GNUC_CONST;
-
GtkWidget* panel_place_menu_item_new(gboolean use_image);
GtkWidget* panel_desktop_menu_item_new(gboolean use_image, gboolean append_lock_logout);
diff --git a/mate-panel/panel-modules.c b/mate-panel/panel-modules.c
index 918817a8..05c4bad7 100644
--- a/mate-panel/panel-modules.c
+++ b/mate-panel/panel-modules.c
@@ -2,6 +2,7 @@
* panel-modules.c
*
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-modules.h b/mate-panel/panel-modules.h
index 50c0b0ad..0573a547 100644
--- a/mate-panel/panel-modules.h
+++ b/mate-panel/panel-modules.h
@@ -2,6 +2,7 @@
* panel-modules.h
*
* Copyright (C) 2010 Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-multimonitor.c b/mate-panel/panel-multimonitor.c
index d2127436..c7ac14cc 100644
--- a/mate-panel/panel-multimonitor.c
+++ b/mate-panel/panel-multimonitor.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2001 George Lebl <[email protected]>
* 2002 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -70,7 +71,6 @@ _panel_multimonitor_output_should_be_first (Display *xdisplay,
unsigned long nitems;
unsigned long bytes_after;
unsigned char *prop;
- gboolean retval;
connector_type_atom = XInternAtom (xdisplay, "ConnectorType", False);
@@ -80,7 +80,7 @@ _panel_multimonitor_output_should_be_first (Display *xdisplay,
&nitems, &bytes_after, &prop) == Success) {
if (actual_type == XA_ATOM && nitems == 1 && actual_format == 32) {
char *connector_type = XGetAtomName (xdisplay, prop[0]);
- retval = g_strcmp0 (connector_type, "Panel") == 0;
+ gboolean retval = g_strcmp0 (connector_type, "Panel") == 0;
XFree (connector_type);
return retval;
}
@@ -104,7 +104,7 @@ panel_multimonitor_get_randr_monitors (int *monitors_ret,
Window xroot;
XRRScreenResources *resources;
RROutput primary;
- GArray *geometries;
+ GArray *geometries_array;
int scale;
int i;
@@ -158,9 +158,9 @@ panel_multimonitor_get_randr_monitors (int *monitors_ret,
/* Use scale factor to bring geometries down to device pixels to support HiDPI displays */
scale = gdk_monitor_get_scale_factor (monitor);
- geometries = g_array_sized_new (FALSE, FALSE,
- sizeof (GdkRectangle),
- resources->noutput);
+ geometries_array = g_array_sized_new (FALSE, FALSE,
+ sizeof (GdkRectangle),
+ resources->noutput);
for (i = 0; i < resources->noutput; i++) {
XRROutputInfo *output;
@@ -186,9 +186,9 @@ panel_multimonitor_get_randr_monitors (int *monitors_ret,
if (_panel_multimonitor_output_should_be_first (xdisplay,
resources->outputs[i],
output, primary))
- g_array_prepend_vals (geometries, &rect, 1);
+ g_array_prepend_vals (geometries_array, &rect, 1);
else
- g_array_append_vals (geometries, &rect, 1);
+ g_array_append_vals (geometries_array, &rect, 1);
}
XRRFreeOutputInfo (output);
@@ -196,19 +196,19 @@ panel_multimonitor_get_randr_monitors (int *monitors_ret,
XRRFreeScreenResources (resources);
- if (geometries->len == 0) {
+ if (geometries_array->len == 0) {
/* This can happen in at least one case:
* https://bugzilla.novell.com/show_bug.cgi?id=543876 where all
* monitors appear disconnected (possibly because the screen
* is behing a KVM switch) -- see comment #8.
* There might be other cases too, so we stay on the safe side.
*/
- g_array_free (geometries, TRUE);
+ g_array_free (geometries_array, TRUE);
return FALSE;
}
- *monitors_ret = geometries->len;
- *geometries_ret = (GdkRectangle *) g_array_free (geometries, FALSE);
+ *monitors_ret = geometries_array->len;
+ *geometries_ret = (GdkRectangle *) g_array_free (geometries_array, FALSE);
return TRUE;
}
@@ -221,39 +221,41 @@ panel_multimonitor_get_gdk_monitors (int *monitors_ret,
{
GdkDisplay *display;
int num_monitors;
- GdkRectangle *geometries;
+ GdkRectangle *geometries_array;
int i;
display = gdk_display_get_default ();
num_monitors = gdk_display_get_n_monitors (display);
- geometries = g_new (GdkRectangle, num_monitors);
+ geometries_array = g_new (GdkRectangle, num_monitors);
for (i = 0; i < num_monitors; i++)
- gdk_monitor_get_geometry (gdk_display_get_monitor (display, i), &(geometries[i]));
+ gdk_monitor_get_geometry (gdk_display_get_monitor (display, i), &(geometries_array[i]));
*monitors_ret = num_monitors;
- *geometries_ret = geometries;
+ *geometries_ret = geometries_array;
}
static void
panel_multimonitor_get_raw_monitors (int *monitors_ret,
GdkRectangle **geometries_ret)
{
- gboolean res = FALSE;
-
*monitors_ret = 0;
*geometries_ret = NULL;
#ifdef HAVE_X11
#ifdef HAVE_RANDR
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()) && have_randr)
- res = panel_multimonitor_get_randr_monitors (monitors_ret, geometries_ret);
+ {
+ gboolean res;
+
+ res = panel_multimonitor_get_randr_monitors (monitors_ret,
+ geometries_ret);
+ if (res && *monitors_ret > 0)
+ return;
+ }
#endif /* HAVE_RANDR */
#endif /* HAVE_X11 */
- if (res && *monitors_ret > 0)
- return;
-
panel_multimonitor_get_gdk_monitors (monitors_ret, geometries_ret);
}
@@ -275,11 +277,11 @@ panel_multimonitor_compress_overlapping_monitors (int *num_monitors_in
GdkRectangle **geometries_inout)
{
int num_monitors;
- GdkRectangle *geometries;
+ GdkRectangle *geometries_array;
int i;
num_monitors = *num_monitors_inout;
- geometries = *geometries_inout;
+ geometries_array = *geometries_inout;
/* http://bugzilla.gnome.org/show_bug.cgi?id=530969
* https://bugzilla.novell.com/show_bug.cgi?id=310208
@@ -330,27 +332,27 @@ panel_multimonitor_compress_overlapping_monitors (int *num_monitors_in
long max_pixels;
int j;
- max_pixels = pixels_in_rectangle (&geometries[i]);
+ max_pixels = pixels_in_rectangle (&geometries_array[i]);
j = i + 1;
while (j < num_monitors) {
- if (rectangle_overlaps (&geometries[i],
- &geometries[j])) {
+ if (rectangle_overlaps (&geometries_array[i],
+ &geometries_array[j])) {
long pixels;
- pixels = pixels_in_rectangle (&geometries[j]);
+ pixels = pixels_in_rectangle (&geometries_array[j]);
if (pixels > max_pixels) {
max_pixels = pixels;
/* keep the maximum */
- geometries[i] = geometries[j];
+ geometries_array[i] = geometries_array[j];
}
/* Shift the remaining monitors to the left */
if (num_monitors - j - 1 > 0)
- memmove (&geometries[j],
- &geometries[j + 1],
- sizeof (geometries[0]) * (num_monitors - j - 1));
+ memmove (&geometries_array[j],
+ &geometries_array[j + 1],
+ sizeof (geometries_array[0]) * (num_monitors - j - 1));
num_monitors--;
g_assert (num_monitors > 0);
@@ -360,7 +362,7 @@ panel_multimonitor_compress_overlapping_monitors (int *num_monitors_in
}
*num_monitors_inout = num_monitors;
- *geometries_inout = geometries;
+ *geometries_inout = geometries_array;
}
static gboolean
diff --git a/mate-panel/panel-multimonitor.h b/mate-panel/panel-multimonitor.h
index 13aa6472..aa10cda3 100644
--- a/mate-panel/panel-multimonitor.h
+++ b/mate-panel/panel-multimonitor.h
@@ -3,6 +3,7 @@
*
* Copyright (C) 2001 George Lebl <[email protected]>
* 2002 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c
index 0401f388..b637563a 100644
--- a/mate-panel/panel-profile.c
+++ b/mate-panel/panel-profile.c
@@ -2,6 +2,7 @@
* panel-profile.c:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -23,7 +24,6 @@
*/
#include <config.h>
-#include <math.h>
#include "panel-profile.h"
#include "panel-layout.h"
@@ -158,8 +158,7 @@ panel_profile_find_new_id (PanelGSettingsKeyType type)
for (j = 0; existing_ids[j] != NULL; j++) {
if (g_strcmp0 (existing_ids[j], retval) == 0) {
- g_free (retval);
- retval = NULL;
+ g_clear_pointer (&retval, g_free);
break;
}
}
@@ -239,20 +238,6 @@ void
panel_profile_set_background_color (PanelToplevel *toplevel,
GdkRGBA *color)
{
- panel_profile_set_background_gdk_rgba (toplevel, color);
-}
-
-void
-panel_profile_get_background_color (PanelToplevel *toplevel,
- GdkRGBA *color)
-{
- panel_profile_get_background_gdk_rgba (toplevel, color);
-}
-
-void
-panel_profile_set_background_gdk_rgba (PanelToplevel *toplevel,
- GdkRGBA *color)
-{
char *color_str;
color_str = gdk_rgba_to_string (color);
@@ -263,8 +248,8 @@ panel_profile_set_background_gdk_rgba (PanelToplevel *toplevel,
}
void
-panel_profile_get_background_gdk_rgba (PanelToplevel *toplevel,
- GdkRGBA *color)
+panel_profile_get_background_color (PanelToplevel *toplevel,
+ GdkRGBA *color)
{
char *color_str;
@@ -281,20 +266,20 @@ panel_profile_get_background_gdk_rgba (PanelToplevel *toplevel,
void
panel_profile_set_background_opacity (PanelToplevel *toplevel,
- guint16 opacity)
+ gdouble percentage)
{
GdkRGBA color;
panel_profile_get_background_color (toplevel, &color);
- color.alpha = opacity / 65535.0;
+ color.alpha = percentage / 100.0;
panel_profile_set_background_color (toplevel, &color);
}
-guint16
+gdouble
panel_profile_get_background_opacity (PanelToplevel *toplevel)
{
GdkRGBA color;
panel_profile_get_background_color (toplevel, &color);
- return (guint16) round (color.alpha * 65535);
+ return color.alpha * 100.0;
}
void
@@ -493,22 +478,6 @@ panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel)
return is_writable;
}
-static void
-get_background_color (PanelToplevel *toplevel,
- GdkRGBA *color)
-{
- char *color_str;
- color_str = g_settings_get_string (toplevel->background_settings, "color");
- if (!color_str || !gdk_rgba_parse (color, color_str)) {
- color->red = 0;
- color->green = 0;
- color->blue = 0;
- color->alpha = 1;
- }
-
- g_free (color_str);
-}
-
static char *
get_background_image (PanelToplevel *toplevel,
gboolean *fit,
@@ -540,7 +509,7 @@ panel_profile_load_background (PanelToplevel *toplevel)
background = &panel_widget->toplevel->background;
background_type = panel_profile_get_background_type (toplevel);
- get_background_color (toplevel, &color);
+ panel_profile_get_background_color (toplevel, &color);
image = get_background_image (toplevel, &fit, &stretch, &rotate);
@@ -866,6 +835,52 @@ key_from_type (PanelGSettingsKeyType type) {
return NULL;
}
+static GVariant *
+remove_from_dict (GVariant *dict, const gchar *path)
+{
+ GVariantIter iter;
+ GVariantBuilder builder;
+
+ gchar *key;
+ gchar *value;
+
+ g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
+ g_variant_iter_init (&iter, dict);
+
+ while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
+ if ( g_strcmp0 (value, path) != 0) {
+ g_variant_builder_add (&builder, "{ss}", key, value);
+ }
+
+ g_free (key);
+ g_free (value);
+ }
+
+ return g_variant_ref_sink (g_variant_builder_end (&builder));
+}
+
+static void
+unregister_dconf_editor_relocatable_schema (const gchar *path)
+{
+ GSettings *dconf_editor_settings;
+ dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
+
+ if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
+ GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
+
+ if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY)) {
+ GVariant * new_relocatable_schemas = remove_from_dict (relocatable_schemas, path);
+ g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
+ g_variant_unref (new_relocatable_schemas);
+ }
+
+ g_variant_unref (relocatable_schemas);
+ }
+
+ g_object_unref (dconf_editor_settings);
+}
+
+
void
panel_profile_add_to_list (PanelGSettingsKeyType type,
const char *id)
@@ -1341,6 +1356,7 @@ panel_profile_delete_dir (PanelGSettingsKeyType type,
gchar *subdir;
subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH "%s/prefs/", id);
mate_dconf_recursive_reset (subdir, NULL);
+ unregister_dconf_editor_relocatable_schema (subdir);
g_free (subdir);
}
@@ -1417,8 +1433,7 @@ panel_profile_load_added_ids (GSList *list,
if (id && id[0])
load_handler (id);
- g_free (l->data);
- l->data = NULL;
+ g_clear_pointer (&l->data, g_free);
}
g_slist_free (added_ids);
@@ -1449,8 +1464,7 @@ panel_profile_delete_removed_ids (PanelGSettingsKeyType type,
panel_profile_delete_dir (type, id);
destroy_handler (id);
- g_free (l->data);
- l->data = NULL;
+ g_clear_pointer (&l->data, g_free);
}
g_slist_free (removed_ids);
}
@@ -1569,11 +1583,9 @@ panel_profile_load_list (GSettings *settings,
PanelProfileLoadFunc load_handler,
GCallback notify_handler)
{
-
const gchar *key = key_from_type (type);
gchar *changed_signal;
gchar **list;
- gint i;
changed_signal = g_strdup_printf ("changed::%s", key);
g_signal_connect (settings, changed_signal, G_CALLBACK (notify_handler), NULL);
@@ -1581,12 +1593,13 @@ panel_profile_load_list (GSettings *settings,
list = g_settings_get_strv (settings, key);
- for (i = 0; list[i]; i++) {
- load_handler (list[i]);
- }
+ if (list) {
+ for (gint i = 0; list[i]; i++) {
+ load_handler (list[i]);
+ }
- if (list)
g_strfreev (list);
+ }
}
static void
diff --git a/mate-panel/panel-profile.h b/mate-panel/panel-profile.h
index 3648d82d..36d4f217 100644
--- a/mate-panel/panel-profile.h
+++ b/mate-panel/panel-profile.h
@@ -2,6 +2,7 @@
* panel-profile.h:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -43,14 +44,12 @@ const char *panel_profile_get_toplevel_id (PanelToplevel *toplevel);
PanelToplevel *panel_profile_get_toplevel_by_id (const char *toplevel_id);
char *panel_profile_find_new_id (PanelGSettingsKeyType type);
-
gboolean panel_profile_get_show_program_list (void);
void panel_profile_set_show_program_list (gboolean show_program_list);
gboolean panel_profile_is_writable_show_program_list (void);
gboolean panel_profile_get_enable_program_list (void);
gboolean panel_profile_get_enable_autocompletion (void);
-
void panel_profile_add_to_list (PanelGSettingsKeyType type,
const char *id);
void panel_profile_remove_from_list (PanelGSettingsKeyType type,
@@ -114,14 +113,9 @@ void panel_profile_set_background_color (PanelToplevel *topl
void panel_profile_get_background_color (PanelToplevel *toplevel,
GdkRGBA *color);
-void panel_profile_set_background_gdk_rgba (PanelToplevel *toplevel,
- GdkRGBA *color);
-void panel_profile_get_background_gdk_rgba (PanelToplevel *toplevel,
- GdkRGBA *color);
-
void panel_profile_set_background_opacity (PanelToplevel *toplevel,
- guint16 opacity);
-guint16 panel_profile_get_background_opacity (PanelToplevel *toplevel);
+ gdouble percentage);
+gdouble panel_profile_get_background_opacity (PanelToplevel *toplevel);
void panel_profile_set_background_image (PanelToplevel *toplevel,
const char *image);
diff --git a/mate-panel/panel-properties-dialog.c b/mate-panel/panel-properties-dialog.c
index 95ffd00d..24642a91 100644
--- a/mate-panel/panel-properties-dialog.c
+++ b/mate-panel/panel-properties-dialog.c
@@ -2,6 +2,7 @@
* panel-properties-dialog.c:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -170,7 +171,7 @@ panel_properties_dialog_setup_orientation_combo (PanelPropertiesDialog *dialog,
GtkListStore *model;
GtkTreeIter iter;
GtkCellRenderer *renderer;
- int i;
+ gsize i;
dialog->orientation_combo = PANEL_GTK_BUILDER_GET (gui, "orientation_combo");
g_return_if_fail (dialog->orientation_combo != NULL);
@@ -238,7 +239,7 @@ panel_properties_dialog_setup_size_spin (PanelPropertiesDialog *dialog,
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->size_spin),
panel_profile_get_toplevel_size (dialog->toplevel));
- g_signal_connect_swapped (dialog->size_spin, "value_changed",
+ g_signal_connect_swapped (dialog->size_spin, "value-changed",
G_CALLBACK (panel_properties_dialog_size_changed),
dialog);
@@ -332,7 +333,7 @@ panel_properties_dialog_color_changed (PanelPropertiesDialog *dialog,
g_assert (dialog->color_button == GTK_WIDGET (color_button));
gtk_color_chooser_get_rgba (color_button, &color);
- panel_profile_set_background_gdk_rgba (dialog->toplevel, &color);
+ panel_profile_set_background_color (dialog->toplevel, &color);
panel_properties_dialog_opacity_changed (dialog);
}
@@ -349,10 +350,13 @@ panel_properties_dialog_setup_color_button (PanelPropertiesDialog *dialog,
panel_profile_get_background_color (dialog->toplevel, &color);
+ if (!gdk_screen_is_composited (gdk_screen_get_default ()))
+ color.alpha = 1.0;
+
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog->color_button),
- &color);
+ &color);
- g_signal_connect_swapped (dialog->color_button, "color_set",
+ g_signal_connect_swapped (dialog->color_button, "color-set",
G_CALLBACK (panel_properties_dialog_color_changed),
dialog);
@@ -416,7 +420,6 @@ static void
panel_properties_dialog_opacity_changed (PanelPropertiesDialog *dialog)
{
gdouble percentage;
- guint16 opacity;
percentage = gtk_range_get_value (GTK_RANGE (dialog->opacity_scale));
@@ -425,16 +428,14 @@ panel_properties_dialog_opacity_changed (PanelPropertiesDialog *dialog)
else if (percentage <= 2)
percentage = 0;
- opacity = (percentage / 100) * 65535;
-
- panel_profile_set_background_opacity (dialog->toplevel, opacity);
+ panel_profile_set_background_opacity (dialog->toplevel, percentage);
}
static void
panel_properties_dialog_setup_opacity_scale (PanelPropertiesDialog *dialog,
GtkBuilder *gui)
{
- guint16 opacity;
+ gboolean slider_active;
gdouble percentage;
dialog->opacity_scale = PANEL_GTK_BUILDER_GET (gui, "opacity_scale");
@@ -444,22 +445,30 @@ panel_properties_dialog_setup_opacity_scale (PanelPropertiesDialog *dialog,
dialog->opacity_legend = PANEL_GTK_BUILDER_GET (gui, "opacity_legend");
g_return_if_fail (dialog->opacity_legend != NULL);
- opacity = panel_profile_get_background_opacity (dialog->toplevel);
+ slider_active = gdk_screen_is_composited (gdk_screen_get_default ());
- percentage = (opacity * 100.0) / 65535;
+ if (slider_active) {
+ percentage = panel_profile_get_background_opacity (dialog->toplevel);
+ } else {
+ percentage = 100.0;
+ }
gtk_range_set_value (GTK_RANGE (dialog->opacity_scale), percentage);
- g_signal_connect_swapped (dialog->opacity_scale, "value_changed",
- G_CALLBACK (panel_properties_dialog_opacity_changed),
- dialog);
+ if (!panel_profile_background_key_is_writable (dialog->toplevel, "opacity")) {
+ slider_active = FALSE;
+ gtk_widget_show (dialog->writability_warn_background);
+ }
- if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "opacity")) {
+ if (!slider_active) {
gtk_widget_set_sensitive (dialog->opacity_scale, FALSE);
gtk_widget_set_sensitive (dialog->opacity_label, FALSE);
gtk_widget_set_sensitive (dialog->opacity_legend, FALSE);
- gtk_widget_show (dialog->writability_warn_background);
}
+
+ g_signal_connect_swapped (dialog->opacity_scale, "value-changed",
+ G_CALLBACK (panel_properties_dialog_opacity_changed),
+ dialog);
}
static void
@@ -728,6 +737,21 @@ panel_properties_dialog_update_background_image (PanelPropertiesDialog *dialog,
}
static void
+panel_properties_dialog_update_opacity (PanelPropertiesDialog *dialog,
+ gdouble percentage)
+{
+ gboolean slider_active;
+
+ slider_active = gdk_screen_is_composited (gdk_screen_get_default ());
+
+ if (!slider_active) {
+ percentage = 100.0;
+ }
+
+ gtk_range_set_value (GTK_RANGE (dialog->opacity_scale), percentage);
+}
+
+static void
panel_properties_dialog_background_notify (GSettings *settings,
gchar *key,
PanelPropertiesDialog *dialog)
@@ -741,6 +765,8 @@ panel_properties_dialog_background_notify (GSettings *settings,
{
char *color = g_settings_get_string (settings, key);
panel_properties_dialog_update_background_color (dialog, color);
+ gdouble percentage = panel_profile_get_background_opacity (dialog->toplevel);
+ panel_properties_dialog_update_opacity (dialog, percentage);
g_free (color);
}
else if (!strcmp (key, "image"))
@@ -822,11 +848,11 @@ panel_properties_dialog_update_for_attached (PanelPropertiesDialog *dialog,
}
static PanelPropertiesDialog *
-panel_properties_dialog_new (PanelToplevel *toplevel,
- GtkBuilder *gui)
+panel_properties_dialog_new (PanelToplevel *toplevel)
{
PanelPropertiesDialog *dialog;
char *toplevel_settings_path;
+ GtkBuilder *gui;
dialog = g_new0 (PanelPropertiesDialog, 1);
@@ -837,6 +863,9 @@ panel_properties_dialog_new (PanelToplevel *toplevel,
dialog->toplevel = toplevel;
+ gui = gtk_builder_new_from_resource (PANEL_RESOURCE_PATH "panel-properties-dialog.ui");
+ gtk_builder_set_translation_domain (gui, GETTEXT_PACKAGE);
+
dialog->properties_dialog = PANEL_GTK_BUILDER_GET (gui, "panel_properties_dialog");
g_signal_connect_swapped (dialog->properties_dialog, "response",
G_CALLBACK (panel_properties_dialog_response), dialog);
@@ -900,9 +929,7 @@ panel_properties_dialog_new (PanelToplevel *toplevel,
panel_toplevel_push_autohide_disabler (dialog->toplevel);
panel_widget_register_open_dialog (panel_toplevel_get_panel_widget (dialog->toplevel),
dialog->properties_dialog);
-
- gtk_widget_show (dialog->properties_dialog);
-
+ g_object_unref (gui);
return dialog;
}
@@ -910,7 +937,6 @@ void
panel_properties_dialog_present (PanelToplevel *toplevel)
{
PanelPropertiesDialog *dialog;
- GtkBuilder *gui;
if (!panel_properties_dialog_quark)
panel_properties_dialog_quark =
@@ -921,16 +947,8 @@ panel_properties_dialog_present (PanelToplevel *toplevel)
gtk_window_set_screen (GTK_WINDOW (dialog->properties_dialog),
gtk_window_get_screen (GTK_WINDOW (toplevel)));
gtk_window_present (GTK_WINDOW (dialog->properties_dialog));
- return;
+ } else {
+ dialog = panel_properties_dialog_new (toplevel);
+ gtk_widget_show (dialog->properties_dialog);
}
-
- gui = gtk_builder_new ();
- gtk_builder_set_translation_domain (gui, GETTEXT_PACKAGE);
- gtk_builder_add_from_resource (gui,
- PANEL_RESOURCE_PATH "panel-properties-dialog.ui",
- NULL);
-
- dialog = panel_properties_dialog_new (toplevel, gui);
-
- g_object_unref (gui);
}
diff --git a/mate-panel/panel-properties-dialog.h b/mate-panel/panel-properties-dialog.h
index 98a9a94d..ba899008 100644
--- a/mate-panel/panel-properties-dialog.h
+++ b/mate-panel/panel-properties-dialog.h
@@ -2,6 +2,7 @@
* panel-properties-dialog.h:
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-properties-dialog.ui b/mate-panel/panel-properties-dialog.ui
index 7dc881e9..9073f182 100644
--- a/mate-panel/panel-properties-dialog.ui
+++ b/mate-panel/panel-properties-dialog.ui
@@ -534,16 +534,29 @@ Author: Wolfgang Ulbrich
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">&lt;small&gt;Opaque&lt;/small&gt;</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
+ <property name="width">2</property>
</packing>
</child>
<child>
@@ -573,19 +586,6 @@ Author: Wolfgang Ulbrich
</packing>
</child>
<child>
- <object class="GtkLabel" id="label15">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">&lt;small&gt;Opaque&lt;/small&gt;</property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
<placeholder/>
</child>
</object>
diff --git a/mate-panel/panel-recent.c b/mate-panel/panel-recent.c
index 5f39584b..2ed4715e 100644
--- a/mate-panel/panel-recent.c
+++ b/mate-panel/panel-recent.c
@@ -3,6 +3,7 @@
* panel-recent.c
*
* Copyright (C) 2002 James Willcox <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -29,6 +30,8 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <libmate-desktop/mate-image-menu-item.h>
+
#include <libpanel-util/panel-error.h>
#include <libpanel-util/panel-show.h>
#include <libpanel-util/panel-gtk.h>
@@ -49,7 +52,6 @@ show_uri (const char *uri, const char *mime_type, GdkScreen *screen,
error);
}
-
static void
recent_documents_activate_cb (GtkRecentChooser *chooser,
gpointer data)
@@ -185,13 +187,14 @@ recent_documents_clear_cb (GtkMenuItem *menuitem,
void
panel_recent_append_documents_menu (GtkWidget *top_menu,
- GtkRecentManager *manager)
+ GtkRecentManager *manager,
+ int recent_items_limit)
{
GtkWidget *recent_menu;
GtkWidget *menu_item;
int size;
- menu_item = gtk_image_menu_item_new ();
+ menu_item = mate_image_menu_item_new ();
setup_menuitem_with_icon (menu_item,
panel_menu_icon_get_size (),
NULL,
@@ -200,8 +203,12 @@ panel_recent_append_documents_menu (GtkWidget *top_menu,
recent_menu = gtk_recent_chooser_menu_new_for_manager (manager);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), recent_menu);
- g_signal_connect (G_OBJECT (recent_menu), "button_press_event",
- G_CALLBACK (menu_dummy_button_press_event), NULL);
+ gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (recent_menu),
+ recent_items_limit);
+
+ g_signal_connect (recent_menu, "button-press-event",
+ G_CALLBACK (menu_dummy_button_press_event),
+ NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (top_menu), menu_item);
gtk_widget_show_all (menu_item);
@@ -213,8 +220,7 @@ panel_recent_append_documents_menu (GtkWidget *top_menu,
gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu),
GTK_RECENT_SORT_MRU);
- g_signal_connect (GTK_RECENT_CHOOSER (recent_menu),
- "item-activated",
+ g_signal_connect (recent_menu, "item-activated",
G_CALLBACK (recent_documents_activate_cb),
NULL);
@@ -230,7 +236,7 @@ panel_recent_append_documents_menu (GtkWidget *top_menu,
add_menu_separator (recent_menu);
- menu_item = gtk_image_menu_item_new ();
+ menu_item = mate_image_menu_item_new ();
setup_menuitem_with_icon (menu_item,
panel_menu_icon_get_size (),
NULL,
diff --git a/mate-panel/panel-recent.h b/mate-panel/panel-recent.h
index 7605342c..e0afb6bd 100644
--- a/mate-panel/panel-recent.h
+++ b/mate-panel/panel-recent.h
@@ -2,6 +2,7 @@
* panel-recent.h
*
* Copyright (C) 2002 James Willcox <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -32,7 +33,8 @@ extern "C" {
#endif
void panel_recent_append_documents_menu (GtkWidget *menu,
- GtkRecentManager *manager);
+ GtkRecentManager *manager,
+ int recent_items_limit);
#ifdef __cplusplus
}
diff --git a/mate-panel/panel-reset.c b/mate-panel/panel-reset.c
index cdeba7ed..4a101781 100644
--- a/mate-panel/panel-reset.c
+++ b/mate-panel/panel-reset.c
@@ -2,6 +2,7 @@
* panel-reset.c
*
* Copyright (C) 2010 Perberos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/mate-panel/panel-reset.h b/mate-panel/panel-reset.h
index f9b6e33a..33fd8012 100644
--- a/mate-panel/panel-reset.h
+++ b/mate-panel/panel-reset.h
@@ -2,6 +2,7 @@
* panel-reset.h
*
* Copyright (C) 2010 Perberos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c
index 815dc42d..49c4e761 100644
--- a/mate-panel/panel-run-dialog.c
+++ b/mate-panel/panel-run-dialog.c
@@ -2,6 +2,7 @@
* panel-run-dialog.c:
*
* Copyright (C) 2003 Frank Worsley <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -38,6 +39,7 @@
#include <unistd.h>
#include <glib/gi18n.h>
+#include <glib.h>
#include <gio/gio.h>
#include <gdk/gdkkeysyms.h>
#include <matemenu-tree.h>
@@ -88,7 +90,7 @@ typedef struct {
GHashTable *dir_hash;
GList *possible_executables;
GList *completion_items;
- GCompletion *completion;
+ GtkEntryCompletion *completion;
int add_items_idle_id;
int find_command_idle_id;
@@ -105,6 +107,8 @@ typedef struct {
enum {
COLUMN_GICON,
COLUMN_NAME,
+ COLUMN_ACCELERATOR_MASK,
+ COLUMN_ACCELERATOR_KEY_VALUE,
COLUMN_COMMENT,
COLUMN_PATH,
COLUMN_EXEC,
@@ -112,6 +116,28 @@ enum {
NUM_COLUMNS
};
+typedef struct {
+ gint list_item_idx;
+ GdkModifierType modifier;
+ guint key_id;
+} AcceleratorKeyMapping;
+
+const AcceleratorKeyMapping accelerator_key_mapping[] =
+{
+ {0, GDK_MOD1_MASK, GDK_KEY_1 },
+ {1, GDK_MOD1_MASK, GDK_KEY_2 },
+ {2, GDK_MOD1_MASK, GDK_KEY_3 },
+ {3, GDK_MOD1_MASK, GDK_KEY_4 },
+ {4, GDK_MOD1_MASK, GDK_KEY_5 },
+ {5, GDK_MOD1_MASK, GDK_KEY_6 },
+ {6, GDK_MOD1_MASK, GDK_KEY_7 },
+ {7, GDK_MOD1_MASK, GDK_KEY_8 },
+ {8, GDK_MOD1_MASK, GDK_KEY_9 },
+ {9, GDK_MOD1_MASK, GDK_KEY_0 },
+};
+
+static GHashTable *accelerator_keys_to_tree_iter_map = NULL;
+
static PanelRunDialog *static_dialog = NULL;
static void panel_run_dialog_disconnect_pixmap (PanelRunDialog *dialog);
@@ -136,9 +162,7 @@ _panel_run_get_recent_programs_list (PanelRunDialog *dialog)
history_max_size = g_settings_get_uint (dialog->settings, PANEL_RUN_HISTORY_MAX_SIZE_KEY);
history_reverse = g_settings_get_boolean (dialog->settings, PANEL_RUN_HISTORY_REVERSE_KEY);
items = g_settings_get_strv (dialog->settings, PANEL_RUN_HISTORY_KEY);
- for (i = 0;
- items[i] && i < history_max_size;
- i++) {
+ for (i = 0; i < history_max_size && items[i]; i++) {
GtkTreeIter iter;
/* add history in reverse */
if (history_reverse)
@@ -198,8 +222,7 @@ _panel_run_save_recent_programs_list (PanelRunDialog *dialog,
}
if (history_max_size < items_added + 1) {
- g_free (items[history_max_size]);
- items[history_max_size] = NULL;
+ g_clear_pointer (&items[history_max_size], g_free);
} else {
items[items_added + 1] = NULL;
}
@@ -220,11 +243,9 @@ panel_run_dialog_destroy (PanelRunDialog *dialog)
g_object_unref (dialog->program_list_box);
- g_clear_object (&(dialog->icon));
- g_free (dialog->desktop_path);
- dialog->desktop_path = NULL;
- g_free (dialog->item_name);
- dialog->item_name = NULL;
+ g_clear_object (&dialog->icon);
+ g_clear_pointer (&dialog->desktop_path, g_free);
+ g_clear_pointer (&dialog->item_name, g_free);
if (dialog->add_items_idle_id)
g_source_remove (dialog->add_items_idle_id);
@@ -234,14 +255,16 @@ panel_run_dialog_destroy (PanelRunDialog *dialog)
g_source_remove (dialog->find_command_idle_id);
dialog->find_command_idle_id = 0;
- if (dialog->settings != NULL)
- g_object_unref (dialog->settings);
- dialog->settings = NULL;
+ g_clear_object (&dialog->settings);
if (dialog->dir_hash)
g_hash_table_destroy (dialog->dir_hash);
dialog->dir_hash = NULL;
+ if (accelerator_keys_to_tree_iter_map)
+ g_hash_table_destroy (accelerator_keys_to_tree_iter_map);
+ accelerator_keys_to_tree_iter_map = NULL;
+
for (l = dialog->possible_executables; l; l = l->next)
g_free (l->data);
g_list_free (dialog->possible_executables);
@@ -252,10 +275,6 @@ panel_run_dialog_destroy (PanelRunDialog *dialog)
g_list_free (dialog->completion_items);
dialog->completion_items = NULL;
- if (dialog->completion)
- g_completion_free (dialog->completion);
- dialog->completion = NULL;
-
panel_run_dialog_disconnect_pixmap (dialog);
g_free (dialog);
@@ -335,6 +354,9 @@ command_is_executable (const char *command,
char ***argvp)
{
gboolean result;
+ GRegex *regex = NULL;
+ gsize argv_len;
+ g_autofree gchar *home_path = NULL;
char **argv;
char *path;
int argc;
@@ -344,6 +366,18 @@ command_is_executable (const char *command,
if (!result)
return FALSE;
+ regex = g_regex_new ("^~/", 0, 0, NULL);
+ argv_len = g_strv_length (argv);
+ home_path = g_build_filename (g_get_home_dir (), "/", NULL);
+ for (gsize i = 0; i < argv_len; i++)
+ {
+ gchar *tmp_argv = NULL;
+
+ tmp_argv = g_regex_replace_literal (regex, argv[i], -1, 0, home_path, 0, NULL);
+ g_free (argv[i]);
+ argv[i] = tmp_argv;
+ }
+ g_regex_unref (regex);
path = g_find_program_in_path (argv[0]);
if (!path) {
@@ -373,15 +407,6 @@ command_is_executable (const char *command,
return TRUE;
}
-/*
- * Set the DISPLAY variable, to be use by g_spawn_async.
- */
-static void
-set_environment (gpointer display)
-{
- g_setenv ("DISPLAY", display, TRUE);
-}
-
static void
dummy_child_watch (GPid pid,
gint status,
@@ -398,32 +423,24 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog,
const char *command,
const char *locale_command)
{
- GdkDisplay *display;
- GdkScreen *screen;
gboolean result;
GError *error = NULL;
char **argv;
int argc;
- char *display_name;
GPid pid;
if (!command_is_executable (locale_command, &argc, &argv))
return FALSE;
- screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
-
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)))
mate_desktop_prepend_terminal_to_vector (&argc, &argv);
- display = gdk_screen_get_display (screen);
- display_name = g_strdup (gdk_display_get_name (display));
-
result = g_spawn_async (NULL, /* working directory */
argv,
NULL, /* envp */
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- set_environment,
- display_name,
+ NULL,
+ NULL,
&pid,
&error);
@@ -443,7 +460,6 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog,
}
g_strfreev (argv);
- g_free (display_name);
return result;
}
@@ -657,19 +673,6 @@ fuzzy_command_match (const char *cmd1,
}
static gboolean
-panel_run_dialog_make_all_list_visible (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
-{
- gtk_list_store_set (GTK_LIST_STORE (model), iter,
- COLUMN_VISIBLE, TRUE,
- -1);
-
- return FALSE;
-}
-
-static gboolean
panel_run_dialog_find_command_idle (PanelRunDialog *dialog)
{
GtkTreeIter iter;
@@ -679,6 +682,7 @@ panel_run_dialog_find_command_idle (PanelRunDialog *dialog)
GIcon *found_icon;
char *found_name;
gboolean fuzzy;
+ gint visible_program_idx = 0;
model = GTK_TREE_MODEL (dialog->program_list_store);
path = gtk_tree_path_new_first ();
@@ -697,12 +701,14 @@ panel_run_dialog_find_command_idle (PanelRunDialog *dialog)
found_icon = NULL;
found_name = NULL;
fuzzy = FALSE;
+ g_hash_table_remove_all (accelerator_keys_to_tree_iter_map);
do {
char *exec = NULL;
GIcon *icon = NULL;
char *name = NULL;
char *comment = NULL;
+ gboolean visible = FALSE;
gtk_tree_model_get (model, &iter,
COLUMN_EXEC, &exec,
@@ -737,6 +743,23 @@ panel_run_dialog_find_command_idle (PanelRunDialog *dialog)
-1);
}
+ gtk_tree_model_get (model, &iter, COLUMN_VISIBLE, &visible, -1);
+ if (visible && visible_program_idx < G_N_ELEMENTS (accelerator_key_mapping)) {
+ gtk_list_store_set (dialog->program_list_store,
+ &iter,
+ COLUMN_ACCELERATOR_MASK, (gint)accelerator_key_mapping[visible_program_idx].modifier,
+ COLUMN_ACCELERATOR_KEY_VALUE, accelerator_key_mapping[visible_program_idx].key_id,
+ -1);
+ g_hash_table_insert (accelerator_keys_to_tree_iter_map, GUINT_TO_POINTER(accelerator_key_mapping[visible_program_idx].key_id), GINT_TO_POINTER(visible_program_idx));
+ visible_program_idx++;
+ } else {
+ gtk_list_store_set (dialog->program_list_store,
+ &iter,
+ COLUMN_ACCELERATOR_MASK, 0,
+ COLUMN_ACCELERATOR_KEY_VALUE, 0,
+ -1);
+ }
+
g_free (exec);
if (icon != NULL)
g_object_unref (icon);
@@ -888,6 +911,8 @@ panel_run_dialog_add_items_idle (PanelRunDialog *dialog)
dialog->program_list_store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_ICON,
G_TYPE_STRING,
+ G_TYPE_INT, // For accelerator modifier mask
+ G_TYPE_UINT, // For accelerator key value
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
@@ -915,6 +940,9 @@ panel_run_dialog_add_items_idle (PanelRunDialog *dialog)
}
}
+ gint i = 0;
+ g_hash_table_remove_all (accelerator_keys_to_tree_iter_map);
+
for (l = all_applications; l; l = l->next) {
MateMenuTreeEntry *entry = l->data;
GtkTreeIter iter;
@@ -933,6 +961,19 @@ panel_run_dialog_add_items_idle (PanelRunDialog *dialog)
COLUMN_PATH, matemenu_tree_entry_get_desktop_file_path (entry),
COLUMN_VISIBLE, TRUE,
-1);
+ if (i < G_N_ELEMENTS (accelerator_key_mapping)) {
+ gtk_list_store_set (dialog->program_list_store, &iter,
+ COLUMN_ACCELERATOR_MASK, (gint)accelerator_key_mapping[i].modifier,
+ COLUMN_ACCELERATOR_KEY_VALUE, accelerator_key_mapping[i].key_id,
+ -1);
+ g_hash_table_insert (accelerator_keys_to_tree_iter_map, GUINT_TO_POINTER(accelerator_key_mapping[i].key_id), GINT_TO_POINTER(i));
+ i++;
+ } else {
+ gtk_list_store_set (dialog->program_list_store, &iter,
+ COLUMN_ACCELERATOR_MASK, (gint)GDK_MOD1_MASK,
+ COLUMN_ACCELERATOR_KEY_VALUE, 0,
+ -1);
+ }
}
g_slist_free_full (all_applications, matemenu_tree_item_unref);
@@ -956,11 +997,23 @@ panel_run_dialog_add_items_idle (PanelRunDialog *dialog)
NULL);
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer,
"text", COLUMN_NAME,
NULL);
+ gtk_tree_view_column_set_sizing (column,
+ GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->program_list), column);
+
+ renderer = gtk_cell_renderer_accel_new ();
+ g_object_set (renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
+ "editable", FALSE, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes ("Shortcut", renderer,
+ "accel-mods", COLUMN_ACCELERATOR_MASK, "accel-key",
+ COLUMN_ACCELERATOR_KEY_VALUE, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->program_list), column);
dialog->add_items_idle_id = 0;
@@ -1047,12 +1100,9 @@ program_list_selection_changed (GtkTreeSelection *selection,
}
dialog->use_program_list = TRUE;
- if (dialog->desktop_path)
- g_free (dialog->desktop_path);
+ g_free (dialog->desktop_path);
dialog->desktop_path = g_strdup (path);
- if (dialog->item_name)
- g_free (dialog->item_name);
- dialog->item_name = NULL;
+ g_clear_pointer (&dialog->item_name, g_free);
/* Order is important here. We have to set the text first so that the
* drag source is enabled, otherwise the drag icon can't be set by
@@ -1108,7 +1158,6 @@ program_list_selection_activated (GtkTreeView *view,
gtk_dialog_response (GTK_DIALOG (dialog->run_dialog), GTK_RESPONSE_OK);
}
-
static void
panel_run_dialog_setup_program_list (PanelRunDialog *dialog,
GtkBuilder *gui)
@@ -1314,8 +1363,7 @@ fill_files_from (const char *dirname,
char *item;
const char *suffix;
- if (!dent->d_name ||
- dent->d_name [0] != prefix)
+ if (dent->d_name [0] != prefix)
continue;
file = g_build_filename (dirname, dent->d_name, NULL);
@@ -1418,6 +1466,33 @@ fill_executables (GList *possible_executables,
return list;
}
+static GtkTreeModel *
+create_completion_model (GList *list)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GList *l;
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ for (l = list; l; l = l->next)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, l->data, -1);
+ }
+
+ return GTK_TREE_MODEL (store);
+}
+
+static void
+completion_add_items (GtkEntryCompletion *completion, GList *list)
+{
+ GtkTreeModel *completion_model;
+
+ completion_model = create_completion_model (list);
+ gtk_entry_completion_set_model (completion, completion_model);
+ g_object_unref (completion_model);
+}
+
static void
panel_run_dialog_update_completion (PanelRunDialog *dialog,
const char *text)
@@ -1435,14 +1510,6 @@ panel_run_dialog_update_completion (PanelRunDialog *dialog,
list = NULL;
executables = NULL;
- if (!dialog->completion) {
- dialog->completion = g_completion_new (NULL);
- dialog->possible_executables = fill_possible_executables ();
- dialog->dir_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free, NULL);
- }
-
buf = g_path_get_basename (text);
prefix = buf[0];
g_free (buf);
@@ -1486,8 +1553,7 @@ panel_run_dialog_update_completion (PanelRunDialog *dialog,
if (list == NULL)
return;
- g_completion_add_items (dialog->completion, list);
-
+ completion_add_items (dialog->completion, list);
dialog->completion_items = g_list_concat (dialog->completion_items,
list);
}
@@ -1499,7 +1565,6 @@ entry_event (GtkEditable *entry,
{
char *prefix;
char *nospace_prefix;
- char *nprefix;
char *temp;
int pos, tmp;
@@ -1525,7 +1590,7 @@ entry_event (GtkEditable *entry,
if (dialog->completion_started &&
pos != tmp &&
pos != 1 &&
- tmp == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
+ ((size_t) tmp) == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
gtk_editable_select_region (entry, 0, 0);
gtk_editable_set_position (entry, -1);
@@ -1538,12 +1603,12 @@ entry_event (GtkEditable *entry,
if (dialog->completion_started &&
pos != tmp &&
pos != 0 &&
- tmp == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
+ ((size_t) tmp) == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
temp = gtk_editable_get_chars (entry, 0, pos);
prefix = g_strconcat (temp, event->string, NULL);
g_free (temp);
} else if (pos == tmp &&
- tmp == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
+ ((size_t) tmp) == strlen (gtk_entry_get_text (GTK_ENTRY (entry)))) {
prefix = g_strconcat (gtk_entry_get_text (GTK_ENTRY (entry)),
event->string, NULL);
} else {
@@ -1564,43 +1629,6 @@ entry_event (GtkEditable *entry,
return FALSE;
}
- pos = strlen (prefix);
- nprefix = NULL;
-
- g_completion_complete_utf8 (dialog->completion, nospace_prefix,
- &nprefix);
-
- if (nprefix) {
- int insertpos;
- insertpos = 0;
-
- temp = g_strndup (prefix, nospace_prefix - prefix);
- g_free (prefix);
-
- prefix = g_strconcat (temp, nprefix, NULL);
-
- g_signal_handler_block (dialog->combobox,
- dialog->changed_id);
- gtk_editable_delete_text (entry, 0, -1);
- g_signal_handler_unblock (dialog->combobox,
- dialog->changed_id);
-
- gtk_editable_insert_text (entry,
- prefix, strlen (prefix),
- &insertpos);
-
- gtk_editable_set_position (entry, pos);
- gtk_editable_select_region (entry, pos, -1);
-
- dialog->completion_started = TRUE;
-
- g_free (temp);
- g_free (nprefix);
- g_free (prefix);
-
- return TRUE;
- }
-
g_free (prefix);
}
@@ -1630,7 +1658,7 @@ combobox_changed (GtkComboBox *combobox,
}
/* desensitize run button if no text entered */
- if (!start || !start [0]) {
+ if (!start [0]) {
g_free (text);
gtk_widget_set_sensitive (dialog->run_button, FALSE);
@@ -1648,12 +1676,31 @@ combobox_changed (GtkComboBox *combobox,
}
if (panel_profile_get_enable_program_list ()) {
- GtkTreeIter iter;
- GtkTreePath *path;
-
- gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->program_list_store),
- panel_run_dialog_make_all_list_visible,
- NULL);
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ gint i = 0;
+ gboolean valid = FALSE;
+
+ g_hash_table_remove_all (accelerator_keys_to_tree_iter_map);
+ model = GTK_TREE_MODEL (dialog->program_list_store);
+ for (valid = gtk_tree_model_get_iter_first (model, &iter); valid; valid = gtk_tree_model_iter_next (model, &iter)) {
+ if (i < G_N_ELEMENTS (accelerator_key_mapping)) {
+ gtk_list_store_set (GTK_LIST_STORE (GTK_TREE_MODEL (dialog->program_list_store)), &iter,
+ COLUMN_VISIBLE, TRUE,
+ COLUMN_ACCELERATOR_MASK, (gint)accelerator_key_mapping[i].modifier,
+ COLUMN_ACCELERATOR_KEY_VALUE, accelerator_key_mapping[i].key_id,
+ -1);
+ g_hash_table_insert (accelerator_keys_to_tree_iter_map, GUINT_TO_POINTER (accelerator_key_mapping[i].key_id), GINT_TO_POINTER(i));
+ i++;
+ } else {
+ gtk_list_store_set (GTK_LIST_STORE (GTK_TREE_MODEL (dialog->program_list_store)), &iter,
+ COLUMN_VISIBLE, TRUE,
+ COLUMN_ACCELERATOR_MASK, (gint)GDK_MOD1_MASK,
+ COLUMN_ACCELERATOR_KEY_VALUE, 0,
+ -1);
+ }
+ }
path = gtk_tree_path_new_first ();
if (gtk_tree_model_get_iter (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->program_list)),
@@ -1748,10 +1795,18 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog,
GtkWidget *entry;
dialog->combobox = PANEL_GTK_BUILDER_GET (gui, "comboboxentry");
+ dialog->possible_executables = fill_possible_executables ();
+ dialog->dir_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
entry = gtk_bin_get_child (GTK_BIN (dialog->combobox));
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+ dialog->completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_inline_completion (dialog->completion, TRUE);
+ gtk_entry_completion_set_popup_completion (dialog->completion, FALSE);
+ gtk_entry_set_completion (GTK_ENTRY (entry), dialog->completion);
+ gtk_entry_completion_set_text_column (dialog->completion, 0);
+
gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox),
_panel_run_get_recent_programs_list (dialog));
gtk_combo_box_set_entry_text_column
@@ -1778,7 +1833,7 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog,
GDK_ACTION_COPY);
gtk_drag_dest_add_uri_targets (dialog->combobox);
- g_signal_connect (dialog->combobox, "drag_data_received",
+ g_signal_connect (dialog->combobox, "drag-data-received",
G_CALLBACK (entry_drag_data_received), dialog);
}
@@ -1847,10 +1902,8 @@ panel_run_dialog_create_desktop_file (PanelRunDialog *dialog)
save_uri = panel_make_unique_desktop_uri (g_get_tmp_dir (), name);
disk = g_filename_from_uri (save_uri, NULL, NULL);
- if (!disk || !panel_key_file_to_file (key_file, disk, NULL)) {
- g_free (save_uri);
- save_uri = NULL;
- }
+ if (!disk || !panel_key_file_to_file (key_file, disk, NULL))
+ g_clear_pointer (&save_uri, g_free);
g_key_file_free (key_file);
g_free (disk);
@@ -1923,7 +1976,7 @@ panel_run_dialog_setup_pixmap (PanelRunDialog *dialog,
G_CALLBACK (panel_run_dialog_screen_changed),
dialog);
- g_signal_connect (dialog->run_dialog, "drag_data_get",
+ g_signal_connect (dialog->run_dialog, "drag-data-get",
G_CALLBACK (pixmap_drag_data_get),
dialog);
}
@@ -1957,6 +2010,22 @@ key_press_event (GtkWidget *run_dialog,
return FALSE;
}
+static void
+panel_run_dialog_accelerator_key_pressed (GtkAccelGroup *accel_group,
+ GObject *acceleratable,
+ guint keyval,
+ GdkModifierType modifier,
+ PanelRunDialog *dialog)
+{
+ GtkTreePath *path;
+ gpointer index_of_entry;
+ gboolean found = g_hash_table_lookup_extended (accelerator_keys_to_tree_iter_map, GUINT_TO_POINTER(keyval), NULL, &index_of_entry);
+ if (!found) return;
+ path = gtk_tree_path_new_from_indices(GPOINTER_TO_INT(index_of_entry), -1);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->program_list), path, NULL, FALSE);
+ gtk_widget_grab_focus (dialog->program_list);
+}
+
static PanelRunDialog *
panel_run_dialog_new (GdkScreen *screen,
GtkBuilder *gui,
@@ -1974,6 +2043,20 @@ panel_run_dialog_new (GdkScreen *screen,
g_signal_connect_swapped (dialog->run_dialog, "destroy",
G_CALLBACK (panel_run_dialog_destroy), dialog);
+ GtkAccelGroup* accel_group = gtk_accel_group_new ();
+ gtk_window_add_accel_group (GTK_WINDOW(dialog->run_dialog), accel_group);
+ g_object_unref (accel_group);
+ for (gint i = 0; i < G_N_ELEMENTS (accelerator_key_mapping); i++)
+ {
+ GClosure *closure_key = g_cclosure_new (
+ G_CALLBACK (panel_run_dialog_accelerator_key_pressed), dialog, NULL);
+ gtk_accel_group_connect (accel_group,
+ accelerator_key_mapping[i].key_id,
+ accelerator_key_mapping[i].modifier,
+ 0,
+ closure_key);
+ }
+
dialog->run_button = PANEL_GTK_BUILDER_GET (gui, "run_button");
dialog->terminal_checkbox = PANEL_GTK_BUILDER_GET (gui, "terminal_checkbox");
@@ -2035,6 +2118,7 @@ panel_run_dialog_present (GdkScreen *screen,
guint32 activate_time)
{
GtkBuilder *gui;
+ accelerator_keys_to_tree_iter_map = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
if (panel_lockdown_get_disable_command_line ())
return;
diff --git a/mate-panel/panel-run-dialog.h b/mate-panel/panel-run-dialog.h
index 49adc49c..b32ce992 100644
--- a/mate-panel/panel-run-dialog.h
+++ b/mate-panel/panel-run-dialog.h
@@ -2,6 +2,7 @@
* panel-run-dialog.h:
*
* Copyright (C) 2003 Frank Worsley <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-schemas.h b/mate-panel/panel-schemas.h
index abcb7cbb..1b787288 100644
--- a/mate-panel/panel-schemas.h
+++ b/mate-panel/panel-schemas.h
@@ -66,6 +66,7 @@
#define PANEL_MENU_BAR_SHOW_ICON_KEY "show-icon"
#define PANEL_MENU_BAR_ICON_NAME_KEY "icon-name"
#define PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU "max-items-or-submenu"
+#define PANEL_MENU_BAR_MAX_RECENT_ITEMS "max-recent-items"
/* external schemas */
diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c
index 1c2dce72..864d3107 100644
--- a/mate-panel/panel-separator.c
+++ b/mate-panel/panel-separator.c
@@ -2,6 +2,7 @@
* panel-separator.c: panel "Separator" module
*
* Copyright (C) 2005 Carlos Garcia Campos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-separator.h b/mate-panel/panel-separator.h
index 02ed13e5..d91cb1a9 100644
--- a/mate-panel/panel-separator.h
+++ b/mate-panel/panel-separator.h
@@ -2,6 +2,7 @@
* panel-separator.h: panel "Separator" module
*
* Copyright (C) 2005 Carlos Garcia Campos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-session.c b/mate-panel/panel-session.c
index e7a45995..ec13f135 100644
--- a/mate-panel/panel-session.c
+++ b/mate-panel/panel-session.c
@@ -2,6 +2,7 @@
* panel-session.c: panel session management routines
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-session.h b/mate-panel/panel-session.h
index 7a029539..19899549 100644
--- a/mate-panel/panel-session.h
+++ b/mate-panel/panel-session.h
@@ -2,6 +2,7 @@
* panel-session.h: panel session management routines
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-shell.c b/mate-panel/panel-shell.c
index affc20f9..321fdb57 100644
--- a/mate-panel/panel-shell.c
+++ b/mate-panel/panel-shell.c
@@ -5,6 +5,7 @@
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2010 Carlos Garcia Campos <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-shell.h b/mate-panel/panel-shell.h
index 26ccbc24..0ef2eda9 100644
--- a/mate-panel/panel-shell.h
+++ b/mate-panel/panel-shell.h
@@ -4,6 +4,7 @@
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-stock-icons.c b/mate-panel/panel-stock-icons.c
index 836f7729..8e124709 100644
--- a/mate-panel/panel-stock-icons.c
+++ b/mate-panel/panel-stock-icons.c
@@ -2,6 +2,7 @@
* panel-stock-icons.c panel stock icons registration
*
* Copyright (C) 2002 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -66,8 +67,7 @@ static void
panel_init_stock_icons (GtkIconFactory *factory)
{
GtkIconSource *source;
- int i;
-
+ gsize i;
source = gtk_icon_source_new ();
@@ -104,11 +104,13 @@ static void
panel_init_stock_items (GtkIconFactory *factory)
{
GtkStockItem *items;
- int i;
+ gsize n_items;
+ gsize i;
- items = g_new (GtkStockItem, G_N_ELEMENTS (stock_items));
+ n_items = G_N_ELEMENTS (stock_items);
+ items = g_new (GtkStockItem, n_items);
- for (i = 0; i < G_N_ELEMENTS (stock_items); i++) {
+ for (i = 0; i < n_items; i++) {
GtkIconSet *icon_set;
items [i].stock_id = g_strdup (stock_items [i].stock_id);
@@ -122,7 +124,7 @@ panel_init_stock_items (GtkIconFactory *factory)
gtk_icon_factory_add (factory, stock_items [i].stock_id, icon_set);
}
- gtk_stock_add_static (items, G_N_ELEMENTS (stock_items));
+ gtk_stock_add_static (items, n_items);
}
void
diff --git a/mate-panel/panel-stock-icons.h b/mate-panel/panel-stock-icons.h
index bc775572..a43ca699 100644
--- a/mate-panel/panel-stock-icons.h
+++ b/mate-panel/panel-stock-icons.h
@@ -2,6 +2,7 @@
* panel-stock-icons.h: panel stock icons registration
*
* Copyright (C) 2002 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/panel-struts.c b/mate-panel/panel-struts.c
index f371f9b3..7c0a9e38 100644
--- a/mate-panel/panel-struts.c
+++ b/mate-panel/panel-struts.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2003 Sun Microsystems, Inc.
* Copyright (C) 2003,2004 Rob Adams
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -18,7 +19,7 @@
* 02110-1301, USA.
* Authors:
- * Mark McLoughlin <[email protected]>
+ * Mark McLoughlin <[email protected]>
*/
#include <config.h>
@@ -34,335 +35,334 @@
#include "panel-multimonitor.h"
#include "panel-xutils.h"
-
typedef struct {
- PanelToplevel *toplevel;
+ PanelToplevel *toplevel;
- GdkScreen *screen;
- int monitor;
+ GdkScreen *screen;
+ int monitor;
- PanelOrientation orientation;
- GdkRectangle geometry;
- int strut_size;
- int strut_start;
- int strut_end;
+ PanelOrientation orientation;
+ GdkRectangle geometry;
+ int strut_size;
+ int strut_start;
+ int strut_end;
- GdkRectangle allocated_geometry;
- int allocated_strut_size;
- int allocated_strut_start;
- int allocated_strut_end;
+ GdkRectangle allocated_geometry;
+ int allocated_strut_size;
+ int allocated_strut_start;
+ int allocated_strut_end;
} PanelStrut;
-
static GSList *panel_struts_list = NULL;
-
static inline PanelStrut *
panel_struts_find_strut (PanelToplevel *toplevel)
{
- GSList *l;
+ GSList *l;
- for (l = panel_struts_list; l; l = l->next) {
- PanelStrut *strut = l->data;
+ for (l = panel_struts_list; l; l = l->next) {
+ PanelStrut *strut = l->data;
- if (strut->toplevel == toplevel)
- break;
- }
+ if (strut->toplevel == toplevel)
+ break;
+ }
- return l ? l->data : NULL;
+ return l ? l->data : NULL;
}
static void
panel_struts_get_monitor_geometry (int monitor,
- int *x,
- int *y,
- int *width,
- int *height)
+ int *x,
+ int *y,
+ int *width,
+ int *height)
{
- *x = panel_multimonitor_x (monitor);
- *y = panel_multimonitor_y (monitor);
- *width = panel_multimonitor_width (monitor);
- *height = panel_multimonitor_height (monitor);
+ *x = panel_multimonitor_x (monitor);
+ *y = panel_multimonitor_y (monitor);
+ *width = panel_multimonitor_width (monitor);
+ *height = panel_multimonitor_height (monitor);
}
static PanelStrut *
panel_struts_intersect (GSList *struts,
- GdkRectangle *geometry,
- int skip)
+ GdkRectangle *geometry,
+ int skip)
{
- GSList *l;
- int i;
+ GSList *l;
+ int i;
- i = 0;
- for (l = struts; l; l = l->next) {
- PanelStrut *strut = l->data;
- int x1, y1, x2, y2;
+ i = 0;
+ for (l = struts; l; l = l->next) {
+ PanelStrut *strut = l->data;
+ int x1, y1, x2, y2;
- x1 = MAX (strut->allocated_geometry.x, geometry->x);
- y1 = MAX (strut->allocated_geometry.y, geometry->y);
+ x1 = MAX (strut->allocated_geometry.x, geometry->x);
+ y1 = MAX (strut->allocated_geometry.y, geometry->y);
- x2 = MIN (strut->allocated_geometry.x + strut->allocated_geometry.width,
- geometry->x + geometry->width);
- y2 = MIN (strut->allocated_geometry.y + strut->allocated_geometry.height,
- geometry->y + geometry->height);
+ x2 = MIN (strut->allocated_geometry.x + strut->allocated_geometry.width,
+ geometry->x + geometry->width);
+ y2 = MIN (strut->allocated_geometry.y + strut->allocated_geometry.height,
+ geometry->y + geometry->height);
- if (x2 - x1 > 0 && y2 - y1 > 0 && ++i > skip)
- break;
- }
+ if (x2 - x1 > 0 && y2 - y1 > 0 && ++i > skip)
+ break;
+ }
- return l ? l->data : NULL;
+ return l ? l->data : NULL;
}
static int
panel_struts_allocation_overlapped (PanelStrut *strut,
- PanelStrut *overlap,
- GdkRectangle *geometry,
- gboolean *moved_down,
- int skip)
+ PanelStrut *overlap,
+ GdkRectangle *geometry,
+ gboolean *moved_down,
+ int skip)
{
- int overlap_x1, overlap_y1, overlap_x2, overlap_y2;
-
- overlap_x1 = overlap->allocated_geometry.x;
- overlap_y1 = overlap->allocated_geometry.y;
- overlap_x2 = overlap->allocated_geometry.x + overlap->allocated_geometry.width;
- overlap_y2 = overlap->allocated_geometry.y + overlap->allocated_geometry.height;
-
- if (strut->orientation == overlap->orientation) {
- int old_x, old_y;
-
- old_x = geometry->x;
- old_y = geometry->y;
-
- switch (strut->orientation) {
- case PANEL_ORIENTATION_TOP:
- geometry->y = overlap_y2;
- strut->allocated_strut_size += geometry->y - old_y;
- break;
- case PANEL_ORIENTATION_BOTTOM:
- geometry->y = overlap_y1 - geometry->height;
- strut->allocated_strut_size += old_y - geometry->y;
- break;
- case PANEL_ORIENTATION_LEFT:
- geometry->x = overlap_x2;
- strut->allocated_strut_size += geometry->x - old_x;
- break;
- case PANEL_ORIENTATION_RIGHT:
- geometry->x = overlap_x1 - geometry->width;
- strut->allocated_strut_size += old_x - geometry->x;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- } else {
- if (strut->orientation & PANEL_HORIZONTAL_MASK ||
- overlap->orientation & PANEL_VERTICAL_MASK)
- return ++skip;
-
- switch (overlap->orientation) {
- case PANEL_ORIENTATION_TOP:
- geometry->y = overlap_y2;
- *moved_down = TRUE;
- break;
- case PANEL_ORIENTATION_BOTTOM:
- if (!*moved_down)
- geometry->y = overlap_y1 - geometry->height;
- else if (overlap_y1 > geometry->y)
- geometry->height = overlap_y1 - geometry->y;
- else
- return ++skip;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- strut->allocated_strut_start = geometry->y;
- strut->allocated_strut_end = geometry->y + geometry->height - 1;
- }
-
- return skip;
+ int overlap_x1, overlap_y1, overlap_x2, overlap_y2;
+
+ overlap_x1 = overlap->allocated_geometry.x;
+ overlap_y1 = overlap->allocated_geometry.y;
+ overlap_x2 = overlap->allocated_geometry.x + overlap->allocated_geometry.width;
+ overlap_y2 = overlap->allocated_geometry.y + overlap->allocated_geometry.height;
+
+ if (strut->orientation == overlap->orientation) {
+ int old_x, old_y;
+
+ old_x = geometry->x;
+ old_y = geometry->y;
+
+ switch (strut->orientation) {
+ case PANEL_ORIENTATION_TOP:
+ geometry->y = overlap_y2;
+ strut->allocated_strut_size += geometry->y - old_y;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ geometry->y = overlap_y1 - geometry->height;
+ strut->allocated_strut_size += old_y - geometry->y;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ geometry->x = overlap_x2;
+ strut->allocated_strut_size += geometry->x - old_x;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ geometry->x = overlap_x1 - geometry->width;
+ strut->allocated_strut_size += old_x - geometry->x;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ } else {
+ if (strut->orientation & PANEL_HORIZONTAL_MASK ||
+ overlap->orientation & PANEL_VERTICAL_MASK)
+ return ++skip;
+
+ switch (overlap->orientation) {
+ case PANEL_ORIENTATION_TOP:
+ geometry->y = overlap_y2;
+ *moved_down = TRUE;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ if (!*moved_down)
+ geometry->y = overlap_y1 - geometry->height;
+ else if (overlap_y1 > geometry->y)
+ geometry->height = overlap_y1 - geometry->y;
+ else
+ return ++skip;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ strut->allocated_strut_start = geometry->y;
+ strut->allocated_strut_end = geometry->y + geometry->height - 1;
+ }
+
+ return skip;
}
static gboolean
panel_struts_allocate_struts (PanelToplevel *toplevel,
- GdkScreen *screen,
- int monitor)
+ GdkScreen *screen,
+ int monitor)
{
- GSList *allocated = NULL;
- GSList *l;
- gboolean toplevel_changed = FALSE;
-
- for (l = panel_struts_list; l; l = l->next) {
- PanelStrut *strut = l->data;
- PanelStrut *overlap;
- GdkRectangle geometry;
- int monitor_x, monitor_y;
- int monitor_width, monitor_height;
- gboolean moved_down;
- int skip;
-
- if (strut->screen != screen || strut->monitor != monitor)
- continue;
-
- panel_struts_get_monitor_geometry (strut->monitor,
- &monitor_x, &monitor_y,
- &monitor_width, &monitor_height);
-
- strut->allocated_strut_size = strut->strut_size;
- strut->allocated_strut_start = strut->strut_start;
- strut->allocated_strut_end = strut->strut_end;
-
- geometry = strut->geometry;
-
- moved_down = FALSE;
- skip = 0;
- while ((overlap = panel_struts_intersect (allocated, &geometry, skip)))
- skip = panel_struts_allocation_overlapped (
- strut, overlap, &geometry, &moved_down, skip);
-
- if (strut->orientation & PANEL_VERTICAL_MASK) {
- if (geometry.y < monitor_y) {
- geometry.height = geometry.y + geometry.height - monitor_y;
- geometry.y = monitor_y;
- }
-
- if (geometry.y + geometry.height > monitor_y + monitor_height)
- geometry.height = monitor_y + monitor_height - geometry.y;
- }
-
- if (strut->allocated_geometry.x != geometry.x ||
- strut->allocated_geometry.y != geometry.y ||
- strut->allocated_geometry.width != geometry.width ||
- strut->allocated_geometry.height != geometry.height) {
- strut->allocated_geometry = geometry;
-
- if (strut->toplevel == toplevel)
- toplevel_changed = TRUE;
- else
- gtk_widget_queue_resize (GTK_WIDGET (strut->toplevel));
- }
-
- allocated = g_slist_append (allocated, strut);
- }
-
- g_slist_free (allocated);
-
- return toplevel_changed;
+ GSList *allocated = NULL;
+ GSList *l;
+ gboolean toplevel_changed = FALSE;
+
+ for (l = panel_struts_list; l; l = l->next) {
+ PanelStrut *strut = l->data;
+ PanelStrut *overlap;
+ GdkRectangle geometry;
+ int monitor_x, monitor_y;
+ int monitor_width, monitor_height;
+ gboolean moved_down;
+ int skip;
+
+ if (strut->screen != screen || strut->monitor != monitor)
+ continue;
+
+ panel_struts_get_monitor_geometry (strut->monitor,
+ &monitor_x, &monitor_y,
+ &monitor_width, &monitor_height);
+
+ strut->allocated_strut_size = strut->strut_size;
+ strut->allocated_strut_start = strut->strut_start;
+ strut->allocated_strut_end = strut->strut_end;
+
+ geometry = strut->geometry;
+
+ moved_down = FALSE;
+ skip = 0;
+ while ((overlap = panel_struts_intersect (allocated, &geometry, skip)))
+ skip = panel_struts_allocation_overlapped (
+ strut, overlap, &geometry, &moved_down, skip);
+
+ if (strut->orientation & PANEL_VERTICAL_MASK) {
+ if (geometry.y < monitor_y) {
+ geometry.height = geometry.y + geometry.height - monitor_y;
+ geometry.y = monitor_y;
+ }
+
+ if (geometry.y + geometry.height > monitor_y + monitor_height)
+ geometry.height = monitor_y + monitor_height - geometry.y;
+ }
+
+ if (strut->allocated_geometry.x != geometry.x ||
+ strut->allocated_geometry.y != geometry.y ||
+ strut->allocated_geometry.width != geometry.width ||
+ strut->allocated_geometry.height != geometry.height) {
+ strut->allocated_geometry = geometry;
+
+ if (strut->toplevel == toplevel)
+ toplevel_changed = TRUE;
+ else
+ gtk_widget_queue_resize (GTK_WIDGET (strut->toplevel));
+ }
+
+ allocated = g_slist_append (allocated, strut);
+ }
+
+ g_slist_free (allocated);
+
+ return toplevel_changed;
}
void
panel_struts_set_window_hint (PanelToplevel *toplevel)
{
- GtkWidget *widget;
- PanelStrut *strut;
- int strut_size;
- int monitor_x, monitor_y, monitor_width, monitor_height;
- int screen_width, screen_height;
- int leftmost, rightmost, topmost, bottommost;
- int scale;
-
- widget = GTK_WIDGET (toplevel);
-
- g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)));
-
- if (!gtk_widget_get_realized (widget))
- return;
-
- if (!(strut = panel_struts_find_strut (toplevel))) {
- panel_struts_unset_window_hint (toplevel);
- return;
- }
-
- scale = gtk_widget_get_scale_factor (widget);
- strut_size = strut->allocated_strut_size;
-
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
-
- panel_struts_get_monitor_geometry (strut->monitor,
- &monitor_x,
- &monitor_y,
- &monitor_width,
- &monitor_height);
-
- panel_multimonitor_is_at_visible_extreme (strut->monitor,
- &leftmost,
- &rightmost,
- &topmost,
- &bottommost);
-
- switch (strut->orientation) {
- case PANEL_ORIENTATION_TOP:
- if (monitor_y > 0)
- strut_size += monitor_y;
- if (!topmost) strut_size = 0;
- break;
- case PANEL_ORIENTATION_BOTTOM:
- if (monitor_y + monitor_height < screen_height)
- strut_size += screen_height - (monitor_y + monitor_height);
- if (!bottommost) strut_size = 0;
- break;
- case PANEL_ORIENTATION_LEFT:
- if (leftmost && monitor_x > 0)
- strut_size += monitor_x;
- if (!leftmost) strut_size = 0;
- break;
- case PANEL_ORIENTATION_RIGHT:
- if (monitor_x + monitor_width < screen_width)
- strut_size += screen_width - (monitor_x + monitor_width);
- if (!rightmost) strut_size = 0;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- panel_xutils_set_strut (gtk_widget_get_window (widget),
- strut->orientation,
- strut_size,
- strut->allocated_strut_start * scale,
- strut->allocated_strut_end * scale);
+ GtkWidget *widget;
+ PanelStrut *strut;
+ int strut_size;
+ int monitor_x, monitor_y, monitor_width, monitor_height;
+ int screen_width, screen_height;
+ int leftmost, rightmost, topmost, bottommost;
+ int scale;
+
+ widget = GTK_WIDGET (toplevel);
+
+ g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)));
+
+ if (!gtk_widget_get_realized (widget))
+ return;
+
+ if (!(strut = panel_struts_find_strut (toplevel))) {
+ panel_struts_unset_window_hint (toplevel);
+ return;
+ }
+
+ scale = gtk_widget_get_scale_factor (widget);
+ strut_size = strut->allocated_strut_size;
+
+ screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
+ screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (strut->screen)) / scale;
+
+ panel_struts_get_monitor_geometry (strut->monitor,
+ &monitor_x,
+ &monitor_y,
+ &monitor_width,
+ &monitor_height);
+
+ panel_multimonitor_is_at_visible_extreme (strut->monitor,
+ &leftmost,
+ &rightmost,
+ &topmost,
+ &bottommost);
+
+ switch (strut->orientation) {
+ case PANEL_ORIENTATION_TOP:
+ if (monitor_y > 0)
+ strut_size += monitor_y;
+ if (!topmost) strut_size = 0;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ if (monitor_y + monitor_height < screen_height)
+ strut_size += screen_height - (monitor_y + monitor_height);
+ if (!bottommost) strut_size = 0;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ if (leftmost && monitor_x > 0)
+ strut_size += monitor_x;
+ if (!leftmost) strut_size = 0;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ if (monitor_x + monitor_width < screen_width)
+ strut_size += screen_width - (monitor_x + monitor_width);
+ if (!rightmost) strut_size = 0;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ panel_xutils_set_strut (gtk_widget_get_window (widget),
+ strut->orientation,
+ strut_size,
+ strut->allocated_strut_start,
+ strut->allocated_strut_end,
+ &strut->allocated_geometry,
+ scale);
}
void
panel_struts_unset_window_hint (PanelToplevel *toplevel)
{
- g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))));
+ g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))));
- if (!gtk_widget_get_realized (GTK_WIDGET (toplevel)))
- return;
+ if (!gtk_widget_get_realized (GTK_WIDGET (toplevel)))
+ return;
- panel_xutils_set_strut (gtk_widget_get_window (GTK_WIDGET (toplevel)), 0, 0, 0, 0);
+ panel_xutils_unset_strut (gtk_widget_get_window (GTK_WIDGET (toplevel)));
}
static inline int
orientation_to_order (PanelOrientation orientation)
{
- switch (orientation) {
- case PANEL_ORIENTATION_TOP:
- return 1;
- case PANEL_ORIENTATION_BOTTOM:
- return 2;
- case PANEL_ORIENTATION_LEFT:
- return 3;
- case PANEL_ORIENTATION_RIGHT:
- return 4;
- default:
- g_assert_not_reached ();
- return -1;
- }
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ return 1;
+ case PANEL_ORIENTATION_BOTTOM:
+ return 2;
+ case PANEL_ORIENTATION_LEFT:
+ return 3;
+ case PANEL_ORIENTATION_RIGHT:
+ return 4;
+ default:
+ g_assert_not_reached ();
+ return -1;
+ }
}
static inline int
get_toplevel_depth (PanelToplevel *toplevel)
{
- int depth = 0;
+ int depth = 0;
- while ((toplevel = panel_toplevel_get_attach_toplevel (toplevel)))
- depth++;
+ while ((toplevel = panel_toplevel_get_attach_toplevel (toplevel)))
+ depth++;
- return depth;
+ return depth;
}
/* Sort in order of
@@ -375,165 +375,156 @@ get_toplevel_depth (PanelToplevel *toplevel)
*/
static int
panel_struts_compare (const PanelStrut *s1,
- const PanelStrut *s2)
+ const PanelStrut *s2)
{
- int s1_depth;
- int s2_depth;
+ int s1_depth;
+ int s2_depth;
- if (s1->screen != s2->screen)
- return gdk_x11_screen_get_screen_number (s1->screen) -
- gdk_x11_screen_get_screen_number (s2->screen);
+ if (s1->screen != s2->screen)
+ return gdk_x11_screen_get_screen_number (s1->screen) -
+ gdk_x11_screen_get_screen_number (s2->screen);
- if (s1->monitor != s2->monitor)
- return s1->monitor - s2->monitor;
+ if (s1->monitor != s2->monitor)
+ return s1->monitor - s2->monitor;
- s1_depth = get_toplevel_depth (s1->toplevel);
- s2_depth = get_toplevel_depth (s2->toplevel);
- if (s1_depth != s2_depth)
- return s2_depth - s1_depth;
+ s1_depth = get_toplevel_depth (s1->toplevel);
+ s2_depth = get_toplevel_depth (s2->toplevel);
+ if (s1_depth != s2_depth)
+ return s2_depth - s1_depth;
- if (s1->orientation != s2->orientation)
- return orientation_to_order (s1->orientation) -
- orientation_to_order (s2->orientation);
+ if (s1->orientation != s2->orientation)
+ return orientation_to_order (s1->orientation) -
+ orientation_to_order (s2->orientation);
- if (s1->strut_start != s2->strut_start)
- return s1->strut_start - s2->strut_start;
+ if (s1->strut_start != s2->strut_start)
+ return s1->strut_start - s2->strut_start;
- if (s1->strut_end != s2->strut_end)
- return s2->strut_end - s1->strut_end;
+ if (s1->strut_end != s2->strut_end)
+ return s2->strut_end - s1->strut_end;
- return 0;
+ return 0;
}
gboolean
panel_struts_register_strut (PanelToplevel *toplevel,
- GdkScreen *screen,
- int monitor,
- PanelOrientation orientation,
- int strut_size,
- int strut_start,
- int strut_end,
- gint scale)
+ GdkScreen *screen,
+ int monitor,
+ PanelOrientation orientation,
+ int strut_size,
+ int strut_start,
+ int strut_end)
{
- PanelStrut *strut;
- gboolean new_strut = FALSE;
- int monitor_x, monitor_y, monitor_width, monitor_height;
-
- g_return_val_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))), FALSE);
-
- if (!(strut = panel_struts_find_strut (toplevel))) {
- strut = g_new0 (PanelStrut, 1);
- new_strut = TRUE;
-
- } else if (strut->toplevel == toplevel &&
- strut->orientation == orientation &&
- strut->screen == screen &&
- strut->monitor == monitor &&
- strut->strut_size == strut_size &&
- strut->strut_start == strut_start &&
- strut->strut_end == strut_end)
- return FALSE;
-
- strut->toplevel = toplevel;
- strut->orientation = orientation;
- strut->screen = screen;
- strut->monitor = monitor;
- strut->strut_size = strut_size;
- strut->strut_start = strut_start;
- strut->strut_end = strut_end;
-
- panel_struts_get_monitor_geometry (monitor,
- &monitor_x, &monitor_y,
- &monitor_width, &monitor_height);
-
- switch (strut->orientation) {
- case PANEL_ORIENTATION_TOP:
- strut->geometry.x = strut->strut_start;
- strut->geometry.y = monitor_y;
- strut->geometry.width = strut->strut_end - strut->strut_start + 1;
- strut->geometry.height = strut->strut_size / scale;
- if (scale > 1)
- strut->geometry.width -= (strut->strut_size / scale);
- break;
- case PANEL_ORIENTATION_BOTTOM:
- strut->geometry.x = strut->strut_start;
- strut->geometry.y = monitor_y + monitor_height - strut->strut_size;
- strut->geometry.width = strut->strut_end - strut->strut_start + 1;
- strut->geometry.height = strut->strut_size / scale;
- if (scale > 1)
- strut->geometry.width -= (strut->strut_size / scale);
- break;
- case PANEL_ORIENTATION_LEFT:
- strut->geometry.x = monitor_x;
- strut->geometry.y = strut->strut_start;
- strut->geometry.width = strut->strut_size / scale;
- strut->geometry.height = strut->strut_end - strut->strut_start + 1;
- if (scale > 1)
- strut->geometry.height -= (strut->strut_size / scale);
- break;
- case PANEL_ORIENTATION_RIGHT:
- strut->geometry.x = monitor_x + monitor_width - strut->strut_size;
- strut->geometry.y = strut->strut_start;
- strut->geometry.width = strut->strut_size / scale;
- strut->geometry.height = strut->strut_end - strut->strut_start + 1;
- if (scale > 1)
- strut->geometry.height -= (strut->strut_size / scale);
- break;
- }
-
- if (new_strut)
- panel_struts_list = g_slist_append (panel_struts_list, strut);
-
- panel_struts_list = g_slist_sort (panel_struts_list,
- (GCompareFunc) panel_struts_compare);
-
- return panel_struts_allocate_struts (toplevel, screen, monitor);
+ PanelStrut *strut;
+ gboolean new_strut = FALSE;
+ int monitor_x, monitor_y, monitor_width, monitor_height;
+
+ g_return_val_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))), FALSE);
+
+ if (!(strut = panel_struts_find_strut (toplevel))) {
+ strut = g_new0 (PanelStrut, 1);
+ new_strut = TRUE;
+
+ } else if (strut->toplevel == toplevel &&
+ strut->orientation == orientation &&
+ strut->screen == screen &&
+ strut->monitor == monitor &&
+ strut->strut_size == strut_size &&
+ strut->strut_start == strut_start &&
+ strut->strut_end == strut_end)
+ return FALSE;
+
+ strut->toplevel = toplevel;
+ strut->orientation = orientation;
+ strut->screen = screen;
+ strut->monitor = monitor;
+ strut->strut_size = strut_size;
+ strut->strut_start = strut_start;
+ strut->strut_end = strut_end;
+
+ panel_struts_get_monitor_geometry (monitor,
+ &monitor_x, &monitor_y,
+ &monitor_width, &monitor_height);
+
+ switch (strut->orientation) {
+ case PANEL_ORIENTATION_TOP:
+ strut->geometry.x = strut->strut_start;
+ strut->geometry.y = monitor_y;
+ strut->geometry.width = strut->strut_end - strut->strut_start + 1;
+ strut->geometry.height = strut->strut_size;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ strut->geometry.x = strut->strut_start;
+ strut->geometry.y = monitor_y + monitor_height - strut->strut_size;
+ strut->geometry.width = strut->strut_end - strut->strut_start + 1;
+ strut->geometry.height = strut->strut_size;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ strut->geometry.x = monitor_x;
+ strut->geometry.y = strut->strut_start;
+ strut->geometry.width = strut->strut_size;
+ strut->geometry.height = strut->strut_end - strut->strut_start + 1;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ strut->geometry.x = monitor_x + monitor_width - strut->strut_size;
+ strut->geometry.y = strut->strut_start;
+ strut->geometry.width = strut->strut_size;
+ strut->geometry.height = strut->strut_end - strut->strut_start + 1;
+ break;
+ }
+
+ if (new_strut)
+ panel_struts_list = g_slist_append (panel_struts_list, strut);
+
+ panel_struts_list = g_slist_sort (panel_struts_list,
+ (GCompareFunc) panel_struts_compare);
+
+ return panel_struts_allocate_struts (toplevel, screen, monitor);
}
void
panel_struts_unregister_strut (PanelToplevel *toplevel)
{
- PanelStrut *strut;
- GdkScreen *screen;
- int monitor;
+ PanelStrut *strut;
+ GdkScreen *screen;
+ int monitor;
- g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))));
+ g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))));
- if (!(strut = panel_struts_find_strut (toplevel)))
- return;
+ if (!(strut = panel_struts_find_strut (toplevel)))
+ return;
- screen = strut->screen;
- monitor = strut->monitor;
+ screen = strut->screen;
+ monitor = strut->monitor;
- panel_struts_list = g_slist_remove (panel_struts_list, strut);
- g_free (strut);
+ panel_struts_list = g_slist_remove (panel_struts_list, strut);
+ g_free (strut);
- panel_struts_allocate_struts (toplevel, screen, monitor);
+ panel_struts_allocate_struts (toplevel, screen, monitor);
}
gboolean
panel_struts_update_toplevel_geometry (PanelToplevel *toplevel,
- int *x,
- int *y,
- int *width,
- int *height)
+ int *x,
+ int *y,
+ int *width,
+ int *height)
{
- PanelStrut *strut;
+ PanelStrut *strut;
- g_return_val_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))), FALSE);
- g_return_val_if_fail (x != NULL, FALSE);
- g_return_val_if_fail (y != NULL, FALSE);
+ g_return_val_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))), FALSE);
+ g_return_val_if_fail (x != NULL, FALSE);
+ g_return_val_if_fail (y != NULL, FALSE);
- if (!(strut = panel_struts_find_strut (toplevel)))
- return FALSE;
+ if (!(strut = panel_struts_find_strut (toplevel)))
+ return FALSE;
- *x += strut->allocated_geometry.x - strut->geometry.x;
- *y += strut->allocated_geometry.y - strut->geometry.y;
+ *x += strut->allocated_geometry.x - strut->geometry.x;
+ *y += strut->allocated_geometry.y - strut->geometry.y;
- if (width != NULL && *width != -1)
- *width += strut->allocated_geometry.width - strut->geometry.width;
- if (height != NULL && *height != -1)
- *height += strut->allocated_geometry.height - strut->geometry.height;
+ if (width != NULL && *width != -1)
+ *width += strut->allocated_geometry.width - strut->geometry.width;
+ if (height != NULL && *height != -1)
+ *height += strut->allocated_geometry.height - strut->geometry.height;
- return TRUE;
+ return TRUE;
}
diff --git a/mate-panel/panel-struts.h b/mate-panel/panel-struts.h
index 01003ec2..6741e084 100644
--- a/mate-panel/panel-struts.h
+++ b/mate-panel/panel-struts.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -17,7 +18,7 @@
* 02110-1301, USA.
* Authors:
- * Mark McLoughlin <[email protected]>
+ * Mark McLoughlin <[email protected]>
*/
#ifndef __PANEL_STRUTS_H__
@@ -37,13 +38,12 @@ extern "C" {
#endif
gboolean panel_struts_register_strut (PanelToplevel *toplevel,
- GdkScreen *screen,
- int monitor,
- PanelOrientation orientation,
- int strut_size,
- int strut_start,
- int strut_end,
- gint scale);
+ GdkScreen *screen,
+ int monitor,
+ PanelOrientation orientation,
+ int strut_size,
+ int strut_start,
+ int strut_end);
void panel_struts_unregister_strut (PanelToplevel *toplevel);
@@ -51,10 +51,10 @@ void panel_struts_set_window_hint (PanelToplevel *toplevel);
void panel_struts_unset_window_hint (PanelToplevel *toplevel);
gboolean panel_struts_update_toplevel_geometry (PanelToplevel *toplevel,
- int *x,
- int *y,
- int *w,
- int *h);
+ int *x,
+ int *y,
+ int *w,
+ int *h);
#ifdef __cplusplus
}
diff --git a/mate-panel/panel-test-applets.c b/mate-panel/panel-test-applets.c
index 4d0a4046..79b48d36 100644
--- a/mate-panel/panel-test-applets.c
+++ b/mate-panel/panel-test-applets.c
@@ -7,6 +7,7 @@
*
* Copyright 2002 Sun Microsystems, Inc.
* 2012 Stefano Karapetsas
+ * Copyright (C) 2012-2021 MATE Developers
*/
#include <config.h>
@@ -40,7 +41,7 @@ static const GOptionEntry options [] = {
{ "prefs-path", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_path, N_("Specify a gsettings path in which the applet preferences should be stored"), NULL},
{ "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, medium, large etc.)"), NULL},
{ "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL},
- { NULL}
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
enum {
@@ -61,7 +62,6 @@ static ComboItem orient_items [] = {
{ NC_("Orientation", "Right"), PANEL_ORIENTATION_RIGHT }
};
-
static ComboItem size_items [] = {
{ NC_("Size", "XX Small"), 12 },
{ NC_("Size", "X Small"), 24 },
@@ -178,13 +178,12 @@ static void
load_applet_from_command_line (void)
{
guint size = 24, orient = PANEL_ORIENTATION_TOP;
- gint i;
g_assert (cli_iid != NULL);
if (cli_size || cli_orient) {
if (cli_size) {
- for (i = 0; i < G_N_ELEMENTS (size_items); i++) {
+ for (gsize i = 0; i < G_N_ELEMENTS (size_items); i++) {
if (strcmp (g_dpgettext2 (NULL, "Size", size_items[i].name), cli_size) == 0) {
size = size_items[i].value;
break;
@@ -193,7 +192,7 @@ load_applet_from_command_line (void)
}
if (cli_orient) {
- for (i = 0; i < G_N_ELEMENTS (orient_items); i++) {
+ for (gsize i = 0; i < G_N_ELEMENTS (orient_items); i++) {
if (strcmp (g_dpgettext2 (NULL, "Orientation", orient_items[i].name), cli_orient) == 0) {
orient = orient_items[i].value;
break;
@@ -240,7 +239,6 @@ setup_combo (GtkWidget *combo_box,
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
GTK_TREE_MODEL (model));
-
for (i = 0; i < nb_items; i++) {
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
@@ -286,8 +284,8 @@ setup_options (void)
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
- COLUMN_TEXT, g_strdup (mate_panel_applet_info_get_name (info)),
- COLUMN_ITEM, g_strdup (mate_panel_applet_info_get_iid (info)),
+ COLUMN_TEXT, mate_panel_applet_info_get_name (info),
+ COLUMN_ITEM, mate_panel_applet_info_get_iid (info),
-1);
}
g_list_free (applet_list);
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index 58bcf86a..2eb6e77a 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -4,6 +4,7 @@
*
* Copyright (C) 2003 Sun Microsystems, Inc.
* Copyright (C) 2004 Rob Adams
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -505,7 +506,7 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp
window = gtk_widget_get_window (widget);
toplevel->priv->grab_op = op_type;
- toplevel->priv->grab_is_keyboard = grab_keyboard;
+ toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE);
toplevel->priv->orig_monitor = toplevel->priv->monitor;
toplevel->priv->orig_x = toplevel->priv->x;
@@ -529,7 +530,6 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp
cursor_type = panel_toplevel_grab_op_cursor (
toplevel, toplevel->priv->grab_op);
-
cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
cursor_type);
display = gdk_window_get_display (window);
@@ -773,7 +773,6 @@ static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y
y = new_y - panel_multimonitor_y (new_monitor);
if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
- y_centered = FALSE;
if (new_y <= display_min.y + snap_tolerance ||
new_y + height >= display_max.y - snap_tolerance)
x_centered = abs (x - ((monitor_geom.width - width) / 2))
@@ -781,7 +780,6 @@ static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y
else
x_centered = FALSE;
} else {
- x_centered = FALSE;
if (new_x <= display_min.x + snap_tolerance ||
new_x + width >= display_max.x - snap_tolerance)
y_centered = abs (y - ((monitor_geom.height - height) / 2))
@@ -1146,7 +1144,7 @@ static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButto
arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"));
if (toplevel->priv->state == PANEL_STATE_NORMAL) {
- GtkDirectionType direction = -1;
+ GtkDirectionType direction;
switch (arrow_type) {
case GTK_ARROW_UP:
@@ -1166,7 +1164,7 @@ static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButto
break;
}
- panel_toplevel_hide (toplevel, FALSE, direction);
+ panel_toplevel_hide (toplevel, FALSE, (gint) direction);
} else
panel_toplevel_unhide (toplevel);
}
@@ -1220,9 +1218,9 @@ panel_toplevel_add_hide_button (PanelToplevel *toplevel,
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel);
- g_signal_connect_swapped (button, "button_press_event",
+ g_signal_connect_swapped (button, "button-press-event",
G_CALLBACK (panel_toplevel_hide_button_event), toplevel);
- g_signal_connect_swapped (button, "button_release_event",
+ g_signal_connect_swapped (button, "button-release-event",
G_CALLBACK (panel_toplevel_hide_button_event), toplevel);
gtk_grid_attach (GTK_GRID (toplevel->priv->grid), button, left, top, 1, 1);
@@ -1519,10 +1517,6 @@ static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean e
}
}
- /* Adjust strut size based on scale factor */
- if (strut > 0)
- strut += toplevel->priv->size * (toplevel->priv->scale - 1);
-
if (orientation != toplevel->priv->orientation) {
toplevel->priv->orientation = orientation;
g_object_notify (G_OBJECT (toplevel), "orientation");
@@ -1542,8 +1536,7 @@ static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean e
orientation,
strut,
strut_start,
- strut_end,
- toplevel->priv->scale);
+ strut_end);
}
else {
panel_struts_unregister_strut (toplevel);
@@ -2516,7 +2509,7 @@ panel_toplevel_update_geometry (PanelToplevel *toplevel,
#ifdef HAVE_X11
if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))) {
if (toplevel->priv->state == PANEL_STATE_NORMAL ||
- toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
+ toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
panel_struts_update_toplevel_geometry (toplevel,
&toplevel->priv->geometry.x,
&toplevel->priv->geometry.y,
@@ -2663,27 +2656,35 @@ panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
static void
panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
{
- int i;
+ guint i;
+#if GLIB_CHECK_VERSION(2,62,0)
for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS; i++) {
- if (!toplevel->priv->attach_toplevel_signals [i])
- continue;
-
- g_signal_handler_disconnect (
- toplevel->priv->attach_toplevel,
- toplevel->priv->attach_toplevel_signals [i]);
- toplevel->priv->attach_toplevel_signals [i] = 0;
+ g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],
+ toplevel->priv->attach_toplevel);
}
for (i = 0; i < N_ATTACH_WIDGET_SIGNALS; i++) {
- if (!toplevel->priv->attach_widget_signals [i])
- continue;
+ g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],
+ toplevel->priv->attach_widget);
+ }
+#else
+ for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS; i++) {
+ if (toplevel->priv->attach_toplevel_signals [i] != 0) {
+ g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
+ toplevel->priv->attach_toplevel_signals [i]);
+ toplevel->priv->attach_toplevel_signals [i] = 0;
+ }
+ }
- g_signal_handler_disconnect (
- toplevel->priv->attach_widget,
- toplevel->priv->attach_widget_signals [i]);
- toplevel->priv->attach_widget_signals [i] = 0;
+ for (i = 0; i < N_ATTACH_WIDGET_SIGNALS; i++) {
+ if (toplevel->priv->attach_widget_signals [i] != 0) {
+ g_signal_handler_disconnect (toplevel->priv->attach_widget,
+ toplevel->priv->attach_widget_signals [i]);
+ toplevel->priv->attach_widget_signals [i] = 0;
+ }
}
+#endif
}
static void
@@ -2826,7 +2827,7 @@ panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
{
gboolean retval = FALSE;
- g_signal_emit_by_name (toplevel, "popup_menu", &retval);
+ g_signal_emit_by_name (toplevel, "popup-menu", &retval);
return retval;
}
@@ -3063,26 +3064,18 @@ panel_toplevel_dispose (GObject *widget)
{
PanelToplevel *toplevel = (PanelToplevel *) widget;
- if (toplevel->priv->settings_path) {
- g_free (toplevel->priv->settings_path);
- toplevel->priv->settings_path = NULL;
- }
+ g_clear_pointer (&toplevel->priv->settings_path, g_free);
if (toplevel->settings) {
g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel);
- g_object_unref (toplevel->settings);
- toplevel->settings = NULL;
+ g_clear_object (&toplevel->settings);
}
- if (toplevel->queued_settings) {
- g_object_unref (toplevel->queued_settings);
- toplevel->queued_settings = NULL;
- }
+ g_clear_object (&toplevel->queued_settings);
if (toplevel->background_settings) {
g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel);
- g_object_unref (toplevel->background_settings);
- toplevel->background_settings = NULL;
+ g_clear_object (&toplevel->background_settings);
}
if (toplevel->priv->gtk_settings) {
@@ -3102,15 +3095,8 @@ panel_toplevel_dispose (GObject *widget)
toplevel->priv->attach_widget = NULL;
}
- if (toplevel->priv->description) {
- g_free (toplevel->priv->description);
- toplevel->priv->description = NULL;
- }
-
- if (toplevel->priv->name) {
- g_free (toplevel->priv->name);
- toplevel->priv->name = NULL;
- }
+ g_clear_pointer (&toplevel->priv->description, g_free);
+ g_clear_pointer (&toplevel->priv->name, g_free);
panel_toplevel_disconnect_timeouts (toplevel);
@@ -3243,7 +3229,7 @@ panel_toplevel_size_allocate (GtkWidget *widget,
GtkBin *bin = (GtkBin *) widget;
GtkStyleContext *context;
GtkStateFlags state;
- GtkBorder padding;
+ GtkBorder padding;
GtkWidget *child;
GtkAllocation challoc;
GtkAllocation child_allocation;
@@ -3299,10 +3285,11 @@ panel_toplevel_size_allocate (GtkWidget *widget,
challoc.y != child_allocation.y ||
challoc.width != child_allocation.width ||
challoc.height != child_allocation.height)) {
- GtkAllocation allocation;
+ GtkAllocation allocation_to_invalidate;
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_invalidate_rect (gtk_widget_get_window (widget), &allocation, FALSE);
+ gtk_widget_get_allocation (widget, &allocation_to_invalidate);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+ &allocation_to_invalidate, FALSE);
}
if (child && gtk_widget_get_visible (child))
@@ -3690,7 +3677,7 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
void
panel_toplevel_hide (PanelToplevel *toplevel,
gboolean auto_hide,
- GtkDirectionType direction)
+ gint direction)
{
g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel));
@@ -3705,14 +3692,18 @@ panel_toplevel_hide (PanelToplevel *toplevel,
if (auto_hide)
toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
else {
+ GtkDirectionType hide_direction;
+
if (direction == -1) {
if (toplevel->priv->orientation & PANEL_VERTICAL_MASK)
- direction = GTK_DIR_UP;
+ hide_direction = GTK_DIR_UP;
else
- direction = GTK_DIR_LEFT;
+ hide_direction = GTK_DIR_LEFT;
+ } else {
+ hide_direction = (GtkDirectionType) direction;
}
- switch (direction) {
+ switch (hide_direction) {
case GTK_DIR_UP:
g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK);
toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
@@ -4022,10 +4013,9 @@ panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget));
- g_signal_connect_swapped (G_OBJECT (toplevel->priv->gtk_settings),
- "notify::gtk-dnd-drag-threshold",
- G_CALLBACK (panel_toplevel_drag_threshold_changed),
- toplevel);
+ g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",
+ G_CALLBACK (panel_toplevel_drag_threshold_changed),
+ toplevel);
panel_toplevel_drag_threshold_changed (toplevel);
}
@@ -4354,7 +4344,6 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
DEFAULT_SIZE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
g_object_class_install_property (
gobject_class,
PROP_X,
@@ -4797,7 +4786,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
/* Prevent the window from being deleted via Alt+F4 by accident. This
* happens with "alternative" window managers such as Sawfish or XFWM4.
*/
- g_signal_connect(GTK_WIDGET(toplevel), "delete-event", G_CALLBACK(gtk_true), NULL);
+ g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL);
panel_background_init (&toplevel->background,
(PanelBackgroundChangedNotify) background_changed,
@@ -4850,12 +4839,11 @@ panel_toplevel_set_name (PanelToplevel *toplevel,
!strcmp (toplevel->priv->name, name))
return;
- if (toplevel->priv->name)
- g_free (toplevel->priv->name);
- toplevel->priv->name = NULL;
-
+ g_free (toplevel->priv->name);
if (name && name [0])
toplevel->priv->name = g_strdup (name);
+ else
+ toplevel->priv->name = NULL;
panel_toplevel_update_name (toplevel);
@@ -5158,7 +5146,7 @@ panel_toplevel_set_x (PanelToplevel *toplevel,
}
if (toplevel->priv->x_centered != x_centered) {
- toplevel->priv->x_centered = x_centered;
+ toplevel->priv->x_centered = (x_centered != FALSE);
changed = TRUE;
g_object_notify (G_OBJECT (toplevel), "x-centered");
}
@@ -5196,7 +5184,7 @@ panel_toplevel_set_y (PanelToplevel *toplevel,
}
if (toplevel->priv->y_centered != y_centered) {
- toplevel->priv->y_centered = y_centered;
+ toplevel->priv->y_centered = (y_centered != FALSE);
changed = TRUE;
g_object_notify (G_OBJECT (toplevel), "y-centered");
}
@@ -5339,7 +5327,7 @@ panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
if (toplevel->priv->auto_hide == auto_hide)
return;
- toplevel->priv->auto_hide = auto_hide;
+ toplevel->priv->auto_hide = (auto_hide != FALSE);
if (toplevel->priv->auto_hide)
panel_toplevel_queue_auto_hide (toplevel);
@@ -5415,7 +5403,7 @@ panel_toplevel_set_animate (PanelToplevel *toplevel,
if (toplevel->priv->animate == animate)
return;
- toplevel->priv->animate = animate;
+ toplevel->priv->animate = (animate != FALSE);
g_object_notify (G_OBJECT (toplevel), "animate");
}
@@ -5485,7 +5473,7 @@ panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
if (toplevel->priv->arrows_enabled == enable_arrows)
return;
- toplevel->priv->arrows_enabled = enable_arrows;
+ toplevel->priv->arrows_enabled = (enable_arrows != FALSE);
panel_toplevel_update_hide_buttons (toplevel);
diff --git a/mate-panel/panel-toplevel.h b/mate-panel/panel-toplevel.h
index 206397da..2d8961c0 100644
--- a/mate-panel/panel-toplevel.h
+++ b/mate-panel/panel-toplevel.h
@@ -2,6 +2,7 @@
* panel-toplevel.h: The panel's toplevel window object.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,7 +20,7 @@
* 02110-1301, USA.
* Authors:
- * Mark McLoughlin <[email protected]>
+ * Mark McLoughlin <[email protected]>
*/
#ifndef __PANEL_TOPLEVEL_H__
@@ -37,7 +38,7 @@ extern "C" {
/* We need PanelWidget type but don't want to include
the panel-widget.h */
#ifndef TYPEDEF_PANEL_WIDGET
-typedef struct _PanelWidget PanelWidget;
+typedef struct _PanelWidget PanelWidget;
#define TYPEDEF_PANEL_WIDGET
#endif /* TYPEDEF_PANEL_WIDGET */
@@ -53,29 +54,29 @@ typedef struct _PanelToplevelClass PanelToplevelClass;
typedef struct _PanelToplevelPrivate PanelToplevelPrivate;
struct _PanelToplevel {
- GtkWindow window_instance;
- GSettings *settings;
- GSettings *queued_settings;
- GSettings *background_settings;
- PanelBackground background;
- PanelToplevelPrivate *priv;
+ GtkWindow window_instance;
+ GSettings *settings;
+ GSettings *queued_settings;
+ GSettings *background_settings;
+ PanelBackground background;
+ PanelToplevelPrivate *priv;
};
struct _PanelToplevelClass {
- GtkWindowClass window_class;
-
- /* key bindings */
- gboolean (*popup_panel_menu) (PanelToplevel *toplevel);
- gboolean (*toggle_expand) (PanelToplevel *toplevel);
- gboolean (*expand) (PanelToplevel *toplevel);
- gboolean (*unexpand) (PanelToplevel *toplevel);
- gboolean (*toggle_hidden) (PanelToplevel *toplevel);
- gboolean (*begin_move) (PanelToplevel *toplevel);
- gboolean (*begin_resize) (PanelToplevel *toplevel);
-
- /* signals */
- void (*hiding) (PanelToplevel *toplevel);
- void (*unhiding) (PanelToplevel *toplevel);
+ GtkWindowClass window_class;
+
+ /* key bindings */
+ gboolean (*popup_panel_menu) (PanelToplevel *toplevel);
+ gboolean (*toggle_expand) (PanelToplevel *toplevel);
+ gboolean (*expand) (PanelToplevel *toplevel);
+ gboolean (*unexpand) (PanelToplevel *toplevel);
+ gboolean (*toggle_hidden) (PanelToplevel *toplevel);
+ gboolean (*begin_move) (PanelToplevel *toplevel);
+ gboolean (*begin_resize) (PanelToplevel *toplevel);
+
+ /* signals */
+ void (*hiding) (PanelToplevel *toplevel);
+ void (*unhiding) (PanelToplevel *toplevel);
};
GType panel_toplevel_get_type (void) G_GNUC_CONST;
@@ -83,61 +84,61 @@ GType panel_toplevel_get_type (void) G_GNUC_CONST;
PanelWidget *panel_toplevel_get_panel_widget (PanelToplevel *toplevel);
void panel_toplevel_set_name (PanelToplevel *toplevel,
- const char *name);
-const char* panel_toplevel_get_name(PanelToplevel* toplevel);
+ const char *name);
+const char *panel_toplevel_get_name (PanelToplevel *toplevel);
void panel_toplevel_set_settings_path (PanelToplevel *toplevel,
- const char *settings_path);
-const char* panel_toplevel_get_description(PanelToplevel* toplevel);
+ const char *settings_path);
+const char *panel_toplevel_get_description (PanelToplevel *toplevel);
void panel_toplevel_set_expand (PanelToplevel *toplevel,
- gboolean expand);
+ gboolean expand);
gboolean panel_toplevel_get_expand (PanelToplevel *toplevel);
void panel_toplevel_set_orientation (PanelToplevel *toplevel,
- PanelOrientation orientation);
+ PanelOrientation orientation);
PanelOrientation panel_toplevel_get_orientation (PanelToplevel *toplevel);
void panel_toplevel_set_size (PanelToplevel *toplevel,
- int size);
+ int size);
int panel_toplevel_get_size (PanelToplevel *toplevel);
void panel_toplevel_set_monitor (PanelToplevel *toplevel,
- int monitor);
+ int monitor);
int panel_toplevel_get_monitor (PanelToplevel *toplevel);
void panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
- int autohide_size);
+ int autohide_size);
int panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel);
void panel_toplevel_set_x (PanelToplevel *toplevel,
- int x,
- int x_right,
- gboolean x_centered);
+ int x,
+ int x_right,
+ gboolean x_centered);
void panel_toplevel_set_y (PanelToplevel *toplevel,
- int y,
- int y_bottom,
- gboolean y_centered);
+ int y,
+ int y_bottom,
+ gboolean y_centered);
void panel_toplevel_get_position (PanelToplevel *toplevel,
- int *x,
- int *x_right,
- int *y,
- int *y_bottom);
+ int *x,
+ int *x_right,
+ int *y,
+ int *y_bottom);
gboolean panel_toplevel_get_x_centered (PanelToplevel *toplevel);
gboolean panel_toplevel_get_y_centered (PanelToplevel *toplevel);
void panel_toplevel_rotate (PanelToplevel *toplevel,
- gboolean clockwise);
+ gboolean clockwise);
void panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
- PanelToplevel *attach_toplevel,
- GtkWidget *attach_widget);
+ PanelToplevel *attach_toplevel,
+ GtkWidget *attach_widget);
void panel_toplevel_detach (PanelToplevel *toplevel);
gboolean panel_toplevel_get_is_attached (PanelToplevel *toplevel);
PanelToplevel *panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel);
GtkWidget *panel_toplevel_get_attach_widget (PanelToplevel *toplevel);
-gboolean panel_toplevel_get_is_floating (PanelToplevel *toplevel);
+gboolean panel_toplevel_get_is_floating (PanelToplevel *toplevel);
gboolean panel_toplevel_get_is_hidden (PanelToplevel *toplevel);
PanelState panel_toplevel_get_state (PanelToplevel *toplevel);
void panel_toplevel_hide (PanelToplevel *toplevel,
- gboolean auto_hide,
- GtkDirectionType direction);
+ gboolean auto_hide,
+ gint direction);
void panel_toplevel_unhide (PanelToplevel *toplevel);
void panel_toplevel_queue_auto_hide (PanelToplevel *toplevel);
void panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel);
@@ -146,33 +147,33 @@ void panel_toplevel_push_autohide_disabler (PanelToplevel
void panel_toplevel_pop_autohide_disabler (PanelToplevel *toplevel);
void panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
- gboolean autohide);
+ gboolean autohide);
gboolean panel_toplevel_get_auto_hide (PanelToplevel *toplevel);
void panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
- int hide_delay);
+ int hide_delay);
int panel_toplevel_get_hide_delay (PanelToplevel *toplevel);
void panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
- int unhide_delay);
+ int unhide_delay);
int panel_toplevel_get_unhide_delay (PanelToplevel *toplevel);
void panel_toplevel_set_animate (PanelToplevel *toplevel,
- gboolean animate);
+ gboolean animate);
gboolean panel_toplevel_get_animate (PanelToplevel *toplevel);
void panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
- PanelAnimationSpeed animation_speed);
+ PanelAnimationSpeed animation_speed);
PanelAnimationSpeed panel_toplevel_get_animation_speed (PanelToplevel *toplevel);
void panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
- gboolean enable_buttons);
+ gboolean enable_buttons);
gboolean panel_toplevel_get_enable_buttons (PanelToplevel *toplevel);
void panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
- gboolean enable_arrows);
+ gboolean enable_arrows);
gboolean panel_toplevel_get_enable_arrows (PanelToplevel *toplevel);
void panel_toplevel_update_edges (PanelToplevel *toplevel);
gboolean panel_toplevel_is_last_unattached (PanelToplevel *toplevel);
-int panel_toplevel_get_minimum_size (PanelToplevel *toplevel);
-int panel_toplevel_get_maximum_size (PanelToplevel *toplevel);
+int panel_toplevel_get_minimum_size (PanelToplevel *toplevel);
+int panel_toplevel_get_maximum_size (PanelToplevel *toplevel);
GSList *panel_toplevel_list_toplevels (void);
#ifdef __cplusplus
diff --git a/mate-panel/panel-util.c b/mate-panel/panel-util.c
index 093a0099..a7cd615e 100644
--- a/mate-panel/panel-util.c
+++ b/mate-panel/panel-util.c
@@ -6,6 +6,7 @@
* Copyright 2000,2001 Eazel, Inc.
* Copyright 2001 George Lebl
* Copyright 2002 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: George Lebl
* Jacob Berkman
@@ -485,7 +486,6 @@ void panel_lock_screen(GdkScreen* screen)
panel_lock_screen_action(screen, "lock");
}
-
static char* panel_launcher_get_personal_path(void)
{
return g_build_filename(g_get_user_config_dir(), "mate", "panel2.d", "default", "launchers", NULL);
diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c
index 079d62ee..1ba1d586 100644
--- a/mate-panel/panel-widget.c
+++ b/mate-panel/panel-widget.c
@@ -1,6 +1,7 @@
/* Mate panel: panel widget
* (C) 1997,1998,1999,2000 the Free Software Foundation
* (C) 2000 Eazel, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: George Lebl
*/
@@ -288,7 +289,7 @@ panel_widget_class_init (PanelWidgetClass *class)
GtkContainerClass *container_class = (GtkContainerClass*) class;
panel_widget_signals[SIZE_CHANGE_SIGNAL] =
- g_signal_new ("size_change",
+ g_signal_new ("size-change",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelWidgetClass, size_change),
@@ -299,7 +300,7 @@ panel_widget_class_init (PanelWidgetClass *class)
0);
panel_widget_signals[BACK_CHANGE_SIGNAL] =
- g_signal_new ("back_change",
+ g_signal_new ("back-change",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelWidgetClass, back_change),
@@ -310,7 +311,7 @@ panel_widget_class_init (PanelWidgetClass *class)
0);
panel_widget_signals[APPLET_MOVE_SIGNAL] =
- g_signal_new ("applet_move",
+ g_signal_new ("applet-move",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelWidgetClass, applet_move),
@@ -322,7 +323,7 @@ panel_widget_class_init (PanelWidgetClass *class)
G_TYPE_POINTER);
panel_widget_signals[APPLET_ADDED_SIGNAL] =
- g_signal_new ("applet_added",
+ g_signal_new ("applet-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelWidgetClass, applet_added),
@@ -334,7 +335,7 @@ panel_widget_class_init (PanelWidgetClass *class)
G_TYPE_POINTER);
panel_widget_signals[APPLET_REMOVED_SIGNAL] =
- g_signal_new ("applet_removed",
+ g_signal_new ("applet-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PanelWidgetClass, applet_removed),
@@ -489,7 +490,7 @@ run_up_forbidden(PanelWidget *panel,
g_return_if_fail(PANEL_IS_WIDGET(panel));
for(list = panel->applet_list;list!=NULL;list = g_list_next(list)) {
- AppletData *ad = list->data;
+ const AppletData *ad = list->data;
PanelWidget *p =
g_object_get_data (G_OBJECT(ad->applet),
MATE_PANEL_APPLET_ASSOC_PANEL_KEY);
@@ -564,7 +565,7 @@ panel_widget_cadd (GtkContainer *container,
static void
panel_widget_cremove (GtkContainer *container, GtkWidget *widget)
{
- AppletData *ad;
+ const AppletData *ad;
PanelWidget *p;
PanelWidget *panel;
@@ -600,7 +601,6 @@ panel_widget_cremove (GtkContainer *container, GtkWidget *widget)
g_object_unref (widget);
}
-
/*get the list item of the data on the position pos*/
static GList *
get_applet_list_pos (PanelWidget *panel,
@@ -611,7 +611,7 @@ get_applet_list_pos (PanelWidget *panel,
g_return_val_if_fail (PANEL_IS_WIDGET (panel), NULL);
for (l = panel->applet_list; l; l = l->next) {
- AppletData *ad = l->data;
+ const AppletData *ad = l->data;
if (ad->pos <= pos) {
if (ad->pos + ad->cells > pos)
@@ -683,7 +683,7 @@ panel_widget_jump_applet_right (PanelWidget *panel,
int pos)
{
AppletData *ad;
- AppletData *nad = NULL;
+ const AppletData *nad = NULL;
ad = list->data;
if (next)
@@ -759,7 +759,7 @@ panel_widget_jump_applet_left (PanelWidget *panel,
int pos)
{
AppletData *ad;
- AppletData *pad = NULL;
+ const AppletData *pad = NULL;
ad = list->data;
if (prev)
@@ -832,7 +832,7 @@ panel_widget_try_push_right (PanelWidget *panel,
int push)
{
AppletData *ad;
- AppletData *nad = NULL;
+ const AppletData *nad = NULL;
g_assert (list != NULL);
@@ -858,7 +858,7 @@ panel_widget_get_right_jump_pos (PanelWidget *panel,
GList *next,
int pos)
{
- AppletData *nad = NULL;
+ const AppletData *nad = NULL;
if (next)
nad = next->data;
@@ -880,7 +880,7 @@ panel_widget_get_right_switch_pos (PanelWidget *panel,
GList *list)
{
AppletData *ad;
- AppletData *nad = NULL;
+ const AppletData *nad = NULL;
g_assert (list != NULL);
@@ -906,7 +906,7 @@ panel_widget_try_push_left (PanelWidget *panel,
int push)
{
AppletData *ad;
- AppletData *pad = NULL;
+ const AppletData *pad = NULL;
g_assert (list != NULL);
@@ -932,7 +932,7 @@ panel_widget_get_left_jump_pos (PanelWidget *panel,
GList *prev,
int pos)
{
- AppletData *pad = NULL;
+ const AppletData *pad = NULL;
if (prev)
pad = prev->data;
@@ -954,7 +954,7 @@ panel_widget_get_left_switch_pos (PanelWidget *panel,
GList *list)
{
AppletData *ad;
- AppletData *pad = NULL;
+ const AppletData *pad = NULL;
g_assert (list != NULL);
@@ -995,7 +995,7 @@ panel_widget_switch_move (PanelWidget *panel,
finalpos = ad->constrained + moveby;
if (ad->constrained < finalpos) {
- AppletData *pad;
+ const AppletData *pad;
if (list->prev) {
pad = list->prev->data;
@@ -1021,7 +1021,7 @@ panel_widget_switch_move (PanelWidget *panel,
} else {
if (list->next) {
- AppletData *nad = list->next->data;
+ const AppletData *nad = list->next->data;
if (nad->expand_major)
gtk_widget_queue_resize (GTK_WIDGET (panel));
}
@@ -1044,7 +1044,7 @@ panel_widget_push_applet_right (PanelWidget *panel,
int push)
{
AppletData *ad;
- AppletData *nad = NULL;
+ const AppletData *nad = NULL;
g_assert (list != NULL);
@@ -1083,7 +1083,7 @@ panel_widget_push_applet_left (PanelWidget *panel,
int push)
{
AppletData *ad;
- AppletData *pad = NULL;
+ const AppletData *pad = NULL;
g_assert (list != NULL);
@@ -1141,7 +1141,7 @@ panel_widget_push_move (PanelWidget *panel,
break;
if (list->prev) {
- AppletData *pad = list->prev->data;
+ const AppletData *pad = list->prev->data;
if (pad->expand_major)
gtk_widget_queue_resize (GTK_WIDGET (panel));
}
@@ -1152,7 +1152,6 @@ panel_widget_push_move (PanelWidget *panel,
}
}
-
/*this is a special function and may fail if called improperly, it works
only under special circumstance when we know there is nothing from
old_size to panel->size*/
@@ -1272,12 +1271,8 @@ panel_widget_get_preferred_size(GtkWidget *widget,
}
panel->nb_applets_size_hints = 0;
- if (panel->applets_hints != NULL)
- g_free (panel->applets_hints);
- panel->applets_hints = NULL;
- if (panel->applets_using_hint != NULL)
- g_free (panel->applets_using_hint);
- panel->applets_using_hint = NULL;
+ g_clear_pointer (&panel->applets_hints, g_free);
+ g_clear_pointer (&panel->applets_using_hint, g_free);
if (panel->packed) {
/* put the list in the correct order: this is important
@@ -1293,7 +1288,7 @@ panel_widget_get_preferred_size(GtkWidget *widget,
for (list = ad_with_hints;
list != NULL;
list = g_list_next (list)) {
- AppletData *ad = list->data;
+ const AppletData *ad = list->data;
panel->applets_hints[i].hints = ad->size_hints;
panel->applets_hints[i].len = ad->size_hints_len;
@@ -1355,7 +1350,7 @@ queue_resize_on_all_applets(PanelWidget *panel)
GList *li;
for(li = panel->applet_list; li != NULL;
li = g_list_next(li)) {
- AppletData *ad = li->data;
+ const AppletData *ad = li->data;
gtk_widget_queue_resize (ad->applet);
}
}
@@ -1454,7 +1449,6 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
list = g_list_next (list)) {
AppletData *ad = list->data;
GtkRequisition chreq;
-
gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
if (!ad->expand_major || !ad->size_hints) {
@@ -1470,7 +1464,6 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
}
ad->constrained = ad->pos;
-
if (ad->constrained < i)
ad->constrained = i;
@@ -1596,13 +1589,8 @@ panel_widget_finalize (GObject *obj)
panel = PANEL_WIDGET (obj);
- if (panel->applets_hints != NULL)
- g_free (panel->applets_hints);
- panel->applets_hints = NULL;
- if (panel->applets_using_hint != NULL)
- g_free (panel->applets_using_hint);
- panel->applets_using_hint = NULL;
-
+ g_clear_pointer (&panel->applets_hints, g_free);
+ g_clear_pointer (&panel->applets_using_hint, g_free);
G_OBJECT_CLASS (panel_widget_parent_class)->finalize (obj);
}
@@ -1699,7 +1687,7 @@ panel_widget_new (PanelToplevel *toplevel,
panel->orient = orient;
panel->sz = sz;
- panel->packed = packed;
+ panel->packed = (packed != FALSE);
panel->size = 0;
panel->toplevel = toplevel;
@@ -1761,7 +1749,6 @@ panel_widget_applet_drag_start_no_grab (PanelWidget *panel,
return TRUE;
}
-
static void
panel_widget_applet_drag_end_no_grab (PanelWidget *panel)
{
@@ -1886,7 +1873,7 @@ panel_widget_get_moveby (PanelWidget *panel, int pos, int offset)
static GList *
walk_up_to (int pos, GList *list)
{
- AppletData *ad;
+ const AppletData *ad;
g_return_val_if_fail (list != NULL, NULL);
@@ -1909,7 +1896,7 @@ walk_up_to (int pos, GList *list)
}
static GtkWidget *
-is_in_applet (int pos, AppletData *ad)
+is_in_applet (int pos, const AppletData *ad)
{
g_return_val_if_fail (ad != NULL, NULL);
@@ -1948,7 +1935,7 @@ panel_widget_get_free_spot (PanelWidget *panel,
if (start < 0)
start = 0;
for (e = 0, i = start; i < panel->size; i++) {
- GtkWidget *applet;
+ const GtkWidget *applet;
list = walk_up_to (i, list);
applet = is_in_applet (i, list->data);
if (applet == NULL ||
@@ -1967,7 +1954,7 @@ panel_widget_get_free_spot (PanelWidget *panel,
if (start >= panel->size)
start = panel->size - 1;
for (e = 0, i = start; i >= 0; i--) {
- GtkWidget *applet;
+ const GtkWidget *applet;
list = walk_up_to (i, list);
applet = is_in_applet (i, list->data);
if (applet == NULL ||
@@ -2310,7 +2297,6 @@ panel_sub_event_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
return FALSE;
}
-
static void
bind_applet_events(GtkWidget *widget, gpointer data)
{
@@ -2325,9 +2311,9 @@ bind_applet_events(GtkWidget *widget, gpointer data)
*/
if (gtk_widget_get_has_window (widget))
- g_signal_connect (G_OBJECT(widget), "event",
- G_CALLBACK (panel_sub_event_handler),
- data);
+ g_signal_connect (widget, "event",
+ G_CALLBACK (panel_sub_event_handler),
+ data);
if (GTK_IS_CONTAINER(widget))
gtk_container_foreach (GTK_CONTAINER (widget),
@@ -2366,7 +2352,7 @@ bind_top_applet_events (GtkWidget *widget)
{
g_return_if_fail(GTK_IS_WIDGET(widget));
- g_signal_connect (G_OBJECT(widget), "destroy",
+ g_signal_connect (widget, "destroy",
G_CALLBACK (panel_widget_applet_destroy),
NULL);
@@ -2505,7 +2491,7 @@ panel_widget_add (PanelWidget *panel,
ad->size_constrained = FALSE;
ad->expand_major = FALSE;
ad->expand_minor = FALSE;
- ad->locked = locked;
+ ad->locked = (locked != FALSE);
ad->size_hints = NULL;
g_object_set_data (G_OBJECT (applet),
MATE_PANEL_APPLET_DATA, ad);
@@ -2526,7 +2512,6 @@ panel_widget_add (PanelWidget *panel,
gtk_fixed_put(GTK_FIXED(panel),applet,
0,pos);
-
gtk_widget_queue_resize(GTK_WIDGET(panel));
g_signal_emit (G_OBJECT(panel),
@@ -2612,7 +2597,7 @@ void
panel_widget_set_packed (PanelWidget *panel_widget,
gboolean packed)
{
- panel_widget->packed = packed;
+ panel_widget->packed = (packed != FALSE);
gtk_widget_queue_resize (GTK_WIDGET (panel_widget));
}
@@ -2810,7 +2795,6 @@ panel_widget_focus (PanelWidget *panel_widget)
gtk_widget_grab_focus (GTK_WIDGET (panel_widget));
}
-
PanelOrientation
panel_widget_get_applet_orientation (PanelWidget *panel)
{
@@ -2836,7 +2820,7 @@ panel_widget_set_applet_size_constrained (PanelWidget *panel,
if (ad->size_constrained == size_constrained)
return;
- ad->size_constrained = size_constrained;
+ ad->size_constrained = (size_constrained != FALSE);
gtk_widget_queue_resize (GTK_WIDGET (panel));
}
@@ -2859,8 +2843,8 @@ panel_widget_set_applet_expandable (PanelWidget *panel,
if (ad->expand_major == major && ad->expand_minor == minor)
return;
- ad->expand_major = major;
- ad->expand_minor = minor;
+ ad->expand_major = (major != FALSE);
+ ad->expand_minor = (minor != FALSE);
gtk_widget_queue_resize (GTK_WIDGET (panel));
}
@@ -2901,7 +2885,7 @@ panel_widget_set_applet_locked (PanelWidget *panel,
if (!ad)
return;
- ad->locked = locked;
+ ad->locked = (locked != FALSE);
}
gboolean
diff --git a/mate-panel/panel-widget.h b/mate-panel/panel-widget.h
index e84cc6c2..e5dc3da8 100644
--- a/mate-panel/panel-widget.h
+++ b/mate-panel/panel-widget.h
@@ -1,5 +1,6 @@
/* Mate panel: panel widget
* (C) 1997-1998 the Free Software Foundation
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: George Lebl
*/
@@ -10,7 +11,6 @@
#ifndef PANEL_WIDGET_H
#define PANEL_WIDGET_H
-
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "button-widget.h"
@@ -191,7 +191,6 @@ void panel_widget_draw_all (PanelWidget *panel,
void panel_widget_draw_icon (PanelWidget *panel,
ButtonWidget *applet);
-
/*tells us if an applet is "stuck" on the right side*/
int panel_widget_is_applet_stuck (PanelWidget *panel,
GtkWidget *applet);
diff --git a/mate-panel/panel-xutils.c b/mate-panel/panel-xutils.c
index 73fc059c..5331ff59 100644
--- a/mate-panel/panel-xutils.c
+++ b/mate-panel/panel-xutils.c
@@ -2,6 +2,7 @@
* panel-xutils.c: X related utility methods.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,7 +20,7 @@
* 02110-1301, USA.
*
* Authors:
- * Mark McLoughlin <[email protected]>
+ * Mark McLoughlin <[email protected]>
*/
#include <config.h>
@@ -38,183 +39,236 @@
static Atom net_wm_strut = None;
static Atom net_wm_strut_partial = None;
+static Atom gnome_wm_strut_area = None;
enum {
- STRUT_LEFT = 0,
- STRUT_RIGHT = 1,
- STRUT_TOP = 2,
- STRUT_BOTTOM = 3,
- STRUT_LEFT_START = 4,
- STRUT_LEFT_END = 5,
- STRUT_RIGHT_START = 6,
- STRUT_RIGHT_END = 7,
- STRUT_TOP_START = 8,
- STRUT_TOP_END = 9,
- STRUT_BOTTOM_START = 10,
- STRUT_BOTTOM_END = 11
+ STRUT_LEFT = 0,
+ STRUT_RIGHT = 1,
+ STRUT_TOP = 2,
+ STRUT_BOTTOM = 3,
+ STRUT_LEFT_START = 4,
+ STRUT_LEFT_END = 5,
+ STRUT_RIGHT_START = 6,
+ STRUT_RIGHT_END = 7,
+ STRUT_TOP_START = 8,
+ STRUT_TOP_END = 9,
+ STRUT_BOTTOM_START = 10,
+ STRUT_BOTTOM_END = 11
+};
+
+enum {
+ STRUT_AREA_X = 0,
+ STRUT_AREA_Y,
+ STRUT_AREA_WIDTH,
+ STRUT_AREA_HEIGHT,
+ STRUT_AREA_LAST
};
void
panel_xutils_set_strut (GdkWindow *gdk_window,
- PanelOrientation orientation,
- guint32 strut,
- guint32 strut_start,
- guint32 strut_end)
+ PanelOrientation orientation,
+ guint32 strut,
+ guint32 strut_start,
+ guint32 strut_end,
+ GdkRectangle *rect,
+ int scale)
{
- Display *xdisplay;
- Window window;
- gulong struts [12] = { 0, };
- GdkDisplay *display;
-
- g_return_if_fail (GDK_IS_WINDOW (gdk_window));
- g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_window_get_display (gdk_window)));
-
- xdisplay = GDK_WINDOW_XDISPLAY (gdk_window);
- window = GDK_WINDOW_XID (gdk_window);
-
- if (net_wm_strut == None)
- net_wm_strut = XInternAtom (xdisplay, "_NET_WM_STRUT", False);
- if (net_wm_strut_partial == None)
- net_wm_strut_partial = XInternAtom (xdisplay, "_NET_WM_STRUT_PARTIAL", False);
-
- switch (orientation) {
- case PANEL_ORIENTATION_LEFT:
- struts [STRUT_LEFT] = strut;
- struts [STRUT_LEFT_START] = strut_start;
- struts [STRUT_LEFT_END] = strut_end;
- break;
- case PANEL_ORIENTATION_RIGHT:
- struts [STRUT_RIGHT] = strut;
- struts [STRUT_RIGHT_START] = strut_start;
- struts [STRUT_RIGHT_END] = strut_end;
- break;
- case PANEL_ORIENTATION_TOP:
- struts [STRUT_TOP] = strut;
- struts [STRUT_TOP_START] = strut_start;
- struts [STRUT_TOP_END] = strut_end;
- break;
- case PANEL_ORIENTATION_BOTTOM:
- struts [STRUT_BOTTOM] = strut;
- struts [STRUT_BOTTOM_START] = strut_start;
- struts [STRUT_BOTTOM_END] = strut_end;
- break;
- }
-
- display = gdk_window_get_display (gdk_window);
- gdk_x11_display_error_trap_push (display);
- XChangeProperty (xdisplay, window, net_wm_strut,
- XA_CARDINAL, 32, PropModeReplace,
- (guchar *) &struts, 4);
- XChangeProperty (xdisplay, window, net_wm_strut_partial,
- XA_CARDINAL, 32, PropModeReplace,
- (guchar *) &struts, 12);
- gdk_x11_display_error_trap_pop_ignored (display);
+ Display *xdisplay;
+ Window window;
+ gulong struts [12] = { 0, };
+ gulong area [STRUT_AREA_LAST];
+ GdkDisplay *display;
+
+ g_return_if_fail (GDK_IS_WINDOW (gdk_window));
+ g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_window_get_display (gdk_window)));
+
+ xdisplay = GDK_WINDOW_XDISPLAY (gdk_window);
+ window = GDK_WINDOW_XID (gdk_window);
+
+ if (net_wm_strut == None)
+ net_wm_strut = XInternAtom (xdisplay, "_NET_WM_STRUT", False);
+ if (net_wm_strut_partial == None)
+ net_wm_strut_partial = XInternAtom (xdisplay, "_NET_WM_STRUT_PARTIAL", False);
+ if (gnome_wm_strut_area == None)
+ gnome_wm_strut_area = XInternAtom (xdisplay, "_GNOME_WM_STRUT_AREA", False);
+
+ strut *= scale;
+ strut_start *= scale;
+ strut_end *= scale;
+
+ switch (orientation) {
+ case PANEL_ORIENTATION_LEFT:
+ struts [STRUT_LEFT] = strut;
+ struts [STRUT_LEFT_START] = strut_start;
+ struts [STRUT_LEFT_END] = strut_end;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ struts [STRUT_RIGHT] = strut;
+ struts [STRUT_RIGHT_START] = strut_start;
+ struts [STRUT_RIGHT_END] = strut_end;
+ break;
+ case PANEL_ORIENTATION_TOP:
+ struts [STRUT_TOP] = strut;
+ struts [STRUT_TOP_START] = strut_start;
+ struts [STRUT_TOP_END] = strut_end;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ struts [STRUT_BOTTOM] = strut;
+ struts [STRUT_BOTTOM_START] = strut_start;
+ struts [STRUT_BOTTOM_END] = strut_end;
+ break;
+ }
+
+ area [STRUT_AREA_X] = rect->x * scale;
+ area [STRUT_AREA_Y] = rect->y * scale;
+ area [STRUT_AREA_WIDTH] = rect->width * scale;
+ area [STRUT_AREA_HEIGHT] = rect->height * scale;
+
+ display = gdk_window_get_display (gdk_window);
+ gdk_x11_display_error_trap_push (display);
+ XChangeProperty (xdisplay, window, net_wm_strut,
+ XA_CARDINAL, 32, PropModeReplace,
+ (guchar *) &struts, 4);
+ XChangeProperty (xdisplay, window, net_wm_strut_partial,
+ XA_CARDINAL, 32, PropModeReplace,
+ (guchar *) &struts, 12);
+ XChangeProperty (xdisplay, window, gnome_wm_strut_area,
+ XA_CARDINAL, 32, PropModeReplace,
+ (guchar *) &area, 4);
+ gdk_x11_display_error_trap_pop_ignored (display);
+}
+
+void
+panel_xutils_unset_strut (GdkWindow *gdk_window)
+{
+ GdkDisplay *display;
+ Display *xdisplay;
+ Window xwindow;
+
+ display = gdk_window_get_display (gdk_window);
+ xdisplay = gdk_x11_display_get_xdisplay (display);
+ xwindow = gdk_x11_window_get_xid (gdk_window);
+
+ if (net_wm_strut == None)
+ net_wm_strut = XInternAtom (xdisplay, "_NET_WM_STRUT", False);
+ if (net_wm_strut_partial == None)
+ net_wm_strut_partial = XInternAtom (xdisplay, "_NET_WM_STRUT_PARTIAL", False);
+ if (gnome_wm_strut_area == None)
+ gnome_wm_strut_area = XInternAtom (xdisplay, "_GNOME_WM_STRUT_AREA", False);
+
+ gdk_x11_display_error_trap_push (display);
+
+ XDeleteProperty (xdisplay, xwindow, net_wm_strut);
+ XDeleteProperty (xdisplay, xwindow, net_wm_strut_partial);
+ XDeleteProperty (xdisplay, xwindow, gnome_wm_strut_area);
+
+ gdk_x11_display_error_trap_pop_ignored (display);
}
void
panel_warp_pointer (GdkWindow *gdk_window,
- int x,
- int y)
+ int x,
+ int y)
{
- Display *xdisplay;
- Window window;
- GdkDisplay *display;
+ Display *xdisplay;
+ Window window;
+ GdkDisplay *display;
- g_return_if_fail (GDK_IS_WINDOW (gdk_window));
- g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_window_get_display (gdk_window)));
+ g_return_if_fail (GDK_IS_WINDOW (gdk_window));
+ g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_window_get_display (gdk_window)));
- xdisplay = GDK_WINDOW_XDISPLAY (gdk_window);
- window = GDK_WINDOW_XID (gdk_window);
+ xdisplay = GDK_WINDOW_XDISPLAY (gdk_window);
+ window = GDK_WINDOW_XID (gdk_window);
- display = gdk_window_get_display (gdk_window);
- gdk_x11_display_error_trap_push (display);
- XWarpPointer (xdisplay, None, window, 0, 0, 0, 0, x, y);
- gdk_x11_display_error_trap_pop_ignored (display);
+ display = gdk_window_get_display (gdk_window);
+ gdk_x11_display_error_trap_push (display);
+ XWarpPointer (xdisplay, None, window, 0, 0, 0, 0, x, y);
+ gdk_x11_display_error_trap_pop_ignored (display);
}
guint
panel_get_real_modifier_mask (guint mask)
{
- guint real_mask;
- Display *display;
- int i, min_keycode, max_keycode, keysyms_per_keycode;
- int max_keycodes_per_modifier;
- KeySym *keysyms_for_keycodes;
- XModifierKeymap *modifier_keymap;
-
- real_mask = mask & ((Mod5Mask << 1) - 1);
-
- /* Already real */
- if (mask == real_mask) {
- return mask;
- }
-
- g_return_val_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()), mask);
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
- XDisplayKeycodes (display, &min_keycode, &max_keycode);
- keysyms_for_keycodes = XGetKeyboardMapping (display,
- min_keycode,
- max_keycode - min_keycode + 1,
- &keysyms_per_keycode);
-
- modifier_keymap = XGetModifierMapping (display);
- max_keycodes_per_modifier = modifier_keymap->max_keypermod;
-
- /* Loop through all the modifiers and find out which "real"
- * (Mod2..Mod5) modifiers Super, Hyper, and Meta are mapped to.
- * Note, Mod1 is used by the Alt modifier */
- for (i = Mod2MapIndex * max_keycodes_per_modifier;
- i < (Mod5MapIndex + 1) * max_keycodes_per_modifier;
- i++) {
- int keycode;
- int j;
- KeySym *keysyms_for_keycode;
- int map_index;
- int map_mask;
-
- keycode = modifier_keymap->modifiermap[i];
-
- /* The array is sparse, there may be some
- * empty entries. Filter those out
- * (along with any invalid entries) */
- if (keycode < min_keycode || keycode > max_keycode)
- continue;
-
- keysyms_for_keycode = keysyms_for_keycodes +
- (keycode - min_keycode) * keysyms_per_keycode;
-
- map_index = i / max_keycodes_per_modifier;
-
- g_assert (map_index <= Mod5MapIndex);
-
- map_mask = 1 << map_index;
-
- for (j = 0; j < keysyms_per_keycode; j++) {
- switch (keysyms_for_keycode[j]) {
- case XK_Super_L:
- case XK_Super_R:
- if (mask & GDK_SUPER_MASK)
- real_mask |= map_mask;
- break;
- case XK_Hyper_L:
- case XK_Hyper_R:
- if (mask & GDK_HYPER_MASK)
- real_mask |= map_mask;
- break;
- case XK_Meta_L:
- case XK_Meta_R:
- if (mask & GDK_META_MASK)
- real_mask |= map_mask;
- break;
- default:
- break;
- }
- }
- }
-
- XFreeModifiermap (modifier_keymap);
- XFree (keysyms_for_keycodes);
-
- return real_mask;
+ guint real_mask;
+ Display *display;
+ int i, min_keycode, max_keycode, keysyms_per_keycode;
+ int max_keycodes_per_modifier;
+ KeySym *keysyms_for_keycodes;
+ XModifierKeymap *modifier_keymap;
+
+ real_mask = mask & ((Mod5Mask << 1) - 1);
+
+ /* Already real */
+ if (mask == real_mask) {
+ return mask;
+ }
+
+ g_return_val_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()), mask);
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+ XDisplayKeycodes (display, &min_keycode, &max_keycode);
+ keysyms_for_keycodes = XGetKeyboardMapping (display,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &keysyms_per_keycode);
+
+ modifier_keymap = XGetModifierMapping (display);
+ max_keycodes_per_modifier = modifier_keymap->max_keypermod;
+
+ /* Loop through all the modifiers and find out which "real"
+ * (Mod2..Mod5) modifiers Super, Hyper, and Meta are mapped to.
+ * Note, Mod1 is used by the Alt modifier */
+ for (i = Mod2MapIndex * max_keycodes_per_modifier;
+ i < (Mod5MapIndex + 1) * max_keycodes_per_modifier;
+ i++) {
+ int keycode;
+ int j;
+ KeySym *keysyms_for_keycode;
+ int map_index;
+ int map_mask;
+
+ keycode = modifier_keymap->modifiermap[i];
+
+ /* The array is sparse, there may be some
+ * empty entries. Filter those out
+ * (along with any invalid entries) */
+ if (keycode < min_keycode || keycode > max_keycode)
+ continue;
+
+ keysyms_for_keycode = keysyms_for_keycodes +
+ (keycode - min_keycode) * keysyms_per_keycode;
+
+ map_index = i / max_keycodes_per_modifier;
+
+ g_assert (map_index <= Mod5MapIndex);
+
+ map_mask = 1 << map_index;
+
+ for (j = 0; j < keysyms_per_keycode; j++) {
+ switch (keysyms_for_keycode[j]) {
+ case XK_Super_L:
+ case XK_Super_R:
+ if (mask & GDK_SUPER_MASK)
+ real_mask |= map_mask;
+ break;
+ case XK_Hyper_L:
+ case XK_Hyper_R:
+ if (mask & GDK_HYPER_MASK)
+ real_mask |= map_mask;
+ break;
+ case XK_Meta_L:
+ case XK_Meta_R:
+ if (mask & GDK_META_MASK)
+ real_mask |= map_mask;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ XFreeModifiermap (modifier_keymap);
+ XFree (keysyms_for_keycodes);
+
+ return real_mask;
}
diff --git a/mate-panel/panel-xutils.h b/mate-panel/panel-xutils.h
index 2d792aca..988153d3 100644
--- a/mate-panel/panel-xutils.h
+++ b/mate-panel/panel-xutils.h
@@ -2,6 +2,7 @@
* panel-xutils.h: X related utility methods.
*
* Copyright (C) 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,7 +20,7 @@
* 02110-1301, USA.
*
* Authors:
- * Mark McLoughlin <[email protected]>
+ * Mark McLoughlin <[email protected]>
*/
#ifndef __PANEL_XUTILS_H__
@@ -44,14 +45,18 @@ extern "C" {
#endif
void panel_xutils_set_strut (GdkWindow *gdk_window,
- PanelOrientation orientation,
- guint32 strut,
- guint32 strut_start,
- guint32 strut_end);
+ PanelOrientation orientation,
+ guint32 strut,
+ guint32 strut_start,
+ guint32 strut_end,
+ GdkRectangle *rect,
+ int scale);
+
+void panel_xutils_unset_strut (GdkWindow *gdk_window);
void panel_warp_pointer (GdkWindow *gdk_window,
- int x,
- int y);
+ int x,
+ int y);
guint panel_get_real_modifier_mask (guint modifier_mask);
diff --git a/mate-panel/panel.c b/mate-panel/panel.c
index e5fd3940..e854cf73 100644
--- a/mate-panel/panel.c
+++ b/mate-panel/panel.c
@@ -1,6 +1,7 @@
/* Mate panel: Initialization routines
* (C) 1997,1998,1999,2000 the Free Software Foundation
* (C) 2000 Eazel, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Federico Mena
* Miguel de Icaza
@@ -115,7 +116,6 @@ orient_change_foreach(GtkWidget *w, gpointer data)
orientation_change(info,panel);
}
-
static void
panel_orient_change (GtkWidget *widget, gpointer data)
{
@@ -145,7 +145,6 @@ size_change_foreach(GtkWidget *w, gpointer data)
size_change(info,panel);
}
-
static void
panel_size_change (GtkWidget *widget, gpointer data)
{
@@ -893,8 +892,7 @@ move_applet (PanelWidget *panel, int pos, int applet_index)
parent = gtk_widget_get_parent (info->widget);
- if (info != NULL &&
- info->widget != NULL &&
+ if (info->widget != NULL &&
parent != NULL &&
PANEL_IS_WIDGET (parent)) {
GSList *forb;
@@ -1322,24 +1320,19 @@ drag_data_recieved_cb (GtkWidget *widget,
static void
panel_widget_setup(PanelWidget *panel)
{
- g_signal_connect (G_OBJECT(panel),
- "applet_added",
+ g_signal_connect (panel, "applet-added",
G_CALLBACK(mate_panel_applet_added),
NULL);
- g_signal_connect (G_OBJECT(panel),
- "applet_removed",
+ g_signal_connect (panel, "applet-removed",
G_CALLBACK(mate_panel_applet_removed),
NULL);
- g_signal_connect (G_OBJECT(panel),
- "applet_move",
+ g_signal_connect (panel, "applet-move",
G_CALLBACK(mate_panel_applet_move),
NULL);
- g_signal_connect (G_OBJECT (panel),
- "back_change",
+ g_signal_connect (panel, "back-change",
G_CALLBACK (panel_back_change),
NULL);
- g_signal_connect (G_OBJECT (panel),
- "size_change",
+ g_signal_connect (panel, "size-change",
G_CALLBACK (panel_size_change),
NULL);
}
@@ -1369,13 +1362,13 @@ panel_setup (PanelToplevel *toplevel)
panel_widget_setup (panel_widget);
- g_signal_connect (toplevel, "drag_data_received",
+ g_signal_connect (toplevel, "drag-data-received",
G_CALLBACK (drag_data_recieved_cb), NULL);
- g_signal_connect (toplevel, "drag_motion",
+ g_signal_connect (toplevel, "drag-motion",
G_CALLBACK (drag_motion_cb), NULL);
- g_signal_connect (toplevel, "drag_leave",
+ g_signal_connect (toplevel, "drag-leave",
G_CALLBACK (drag_leave_cb), NULL);
- g_signal_connect (toplevel, "drag_drop",
+ g_signal_connect (toplevel, "drag-drop",
G_CALLBACK (drag_drop_cb), NULL);
gtk_drag_dest_set (GTK_WIDGET (toplevel), 0, NULL, 0, 0);
@@ -1508,9 +1501,9 @@ panel_deletion_dialog (PanelToplevel *toplevel)
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (panel_deletion_destroy_dialog),
- toplevel);
+ g_signal_connect (dialog, "destroy",
+ G_CALLBACK (panel_deletion_destroy_dialog),
+ toplevel);
g_object_set_data (G_OBJECT (toplevel), "panel-delete-dialog", dialog);
panel_toplevel_push_autohide_disabler (toplevel);
diff --git a/mate-panel/panel.gresource.xml b/mate-panel/panel.gresource.xml
index bcd2c43c..3f7e46aa 100644
--- a/mate-panel/panel.gresource.xml
+++ b/mate-panel/panel.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/mate/panel">
+ <file compressed="true">panel-ditem-editor-dialog.ui</file>
<file compressed="true">panel-properties-dialog.ui</file>
<file compressed="true">panel-run-dialog.ui</file>
</gresource>
diff --git a/mate-panel/panel.h b/mate-panel/panel.h
index 3cb773a6..bf1517ec 100644
--- a/mate-panel/panel.h
+++ b/mate-panel/panel.h
@@ -28,7 +28,6 @@ GdkScreen *panel_screen_from_panel_widget (PanelWidget *panel);
gboolean panel_is_applet_right_stick (GtkWidget *applet);
-
gboolean panel_check_dnd_target_data (GtkWidget *widget,
GdkDragContext *context,
guint *ret_info,
diff --git a/mate-panel/wayland-backend.c b/mate-panel/wayland-backend.c
index 93e1ea9d..fc1b7484 100644
--- a/mate-panel/wayland-backend.c
+++ b/mate-panel/wayland-backend.c
@@ -2,6 +2,7 @@
* wayland-backend.c: Support for running on Wayland compositors
*
* Copyright (C) 2019 William Wold
+ * Copyright (C) 2019-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/wayland-backend.h b/mate-panel/wayland-backend.h
index 7c4d6a67..0c597127 100644
--- a/mate-panel/wayland-backend.h
+++ b/mate-panel/wayland-backend.h
@@ -2,6 +2,7 @@
* wayland-backend.h: Support for running on Wayland compositors
*
* Copyright (C) 2019 William Wold
+ * Copyright (C) 2019-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/mate-panel/xstuff.c b/mate-panel/xstuff.c
index aebd9854..7108d570 100644
--- a/mate-panel/xstuff.c
+++ b/mate-panel/xstuff.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2000, 2001 Eazel, Inc.
* 2002 Sun Microsystems Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: George Lebl <[email protected]>
* Mark McLoughlin <[email protected]>
@@ -206,8 +207,9 @@ draw_zoom_animation_composited (GdkScreen *gscreen,
gtk_window_move (GTK_WINDOW (win), wx, wy);
- g_signal_connect (G_OBJECT (win), "draw",
- G_CALLBACK (zoom_draw), zoom);
+ g_signal_connect (win, "draw",
+ G_CALLBACK (zoom_draw),
+ zoom);
/* see doc for gtk_widget_set_app_paintable() */
gtk_widget_realize (win);
@@ -232,7 +234,7 @@ draw_zoom_animation (GdkScreen *gscreen,
int i, j;
GC frame_gc;
XGCValues gcv;
- GdkColor color = { 65535, 65535, 65535 };
+ GdkColor color = { .pixel = 0, .red = 65535, .green = 65535, .blue = 65535 };
Display *dpy;
Window root_win;
int screen;