diff options
Diffstat (limited to 'libmate-panel-applet')
-rw-r--r-- | libmate-panel-applet/Makefile.am | 2 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet-factory.c | 10 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet-factory.h | 1 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet-gsettings.c | 125 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet-gsettings.h | 9 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet.c | 74 | ||||
-rw-r--r-- | libmate-panel-applet/mate-panel-applet.h | 2 | ||||
-rw-r--r-- | libmate-panel-applet/panel-applet-private.h | 3 | ||||
-rw-r--r-- | libmate-panel-applet/panel-plug-private.h | 1 | ||||
-rw-r--r-- | libmate-panel-applet/panel-plug.c | 1 | ||||
-rw-r--r-- | libmate-panel-applet/test-dbus-applet.c | 10 |
11 files changed, 168 insertions, 70 deletions
diff --git a/libmate-panel-applet/Makefile.am b/libmate-panel-applet/Makefile.am index 196436e9..dbb640b1 100644 --- a/libmate-panel-applet/Makefile.am +++ b/libmate-panel-applet/Makefile.am @@ -95,7 +95,7 @@ appletdir = $(datadir)/mate-panel/applets applet_in_files = org.mate.panel.TestApplet.mate-panel-applet.desktop.in noinst_DATA = $(applet_in_files:.mate-panel-applet.desktop.in=.mate-panel-applet) $(noinst_DATA): $(applet_in_files) - $(AM_V_GEN) $(MSGFMT) --desktop --keyword Name --keyword Description --template $< -d $(top_srcdir)/po -o $@ + $(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ EXTRA_DIST = \ org.mate.panel.TestApplet.mate-panel-applet.desktop.in \ diff --git a/libmate-panel-applet/mate-panel-applet-factory.c b/libmate-panel-applet/mate-panel-applet-factory.c index 815ad491..521ab4d4 100644 --- a/libmate-panel-applet/mate-panel-applet-factory.c +++ b/libmate-panel-applet/mate-panel-applet-factory.c @@ -2,6 +2,7 @@ * mate-panel-applet-factory.c: panel applet writing API. * * 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 @@ -77,10 +78,7 @@ mate_panel_applet_factory_finalize (GObject *object) factories = NULL; } - if (factory->factory_id) { - g_free (factory->factory_id); - factory->factory_id = NULL; - } + g_clear_pointer (&factory->factory_id, g_free); if (factory->applets) { g_hash_table_unref (factory->applets); @@ -177,7 +175,6 @@ set_applet_constructor_properties (GObject *applet, } } - static void mate_panel_applet_factory_get_applet (MatePanelAppletFactory *factory, GDBusConnection *connection, @@ -272,7 +269,8 @@ static const gchar introspection_xml[] = static const GDBusInterfaceVTable interface_vtable = { method_call_cb, NULL, - NULL + NULL, + { 0 } }; static GDBusNodeInfo *introspection_data = NULL; diff --git a/libmate-panel-applet/mate-panel-applet-factory.h b/libmate-panel-applet/mate-panel-applet-factory.h index 2a8eeb07..a7d2aa53 100644 --- a/libmate-panel-applet/mate-panel-applet-factory.h +++ b/libmate-panel-applet/mate-panel-applet-factory.h @@ -2,6 +2,7 @@ * mate-panel-applet-factory.h: panel applet writing API. * * 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 diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c index dbe0bf7a..93d0b4ce 100644 --- a/libmate-panel-applet/mate-panel-applet-gsettings.c +++ b/libmate-panel-applet/mate-panel-applet-gsettings.c @@ -2,6 +2,7 @@ * mate-panel-applet-gsettings.c: panel applet preferences handling. * * Copyright (C) 2012 Stefano Karapetsas + * 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 @@ -28,6 +29,101 @@ #include "mate-panel-applet.h" #include "mate-panel-applet-gsettings.h" +static GVariant * +add_to_dict (GVariant *dict, const gchar *schema, const gchar *path) +{ + GVariantIter iter; + GVariantBuilder builder; + gboolean is_schema_found; + gboolean is_incorrect_schema; + gint path_counter; + + gchar *key; + gchar *value; + + g_variant_builder_init (&builder, (const GVariantType *) "a{ss}"); + g_variant_iter_init (&iter, dict); + + is_schema_found = FALSE; + is_incorrect_schema = FALSE; + path_counter = 0; + + while (g_variant_iter_next (&iter, "{ss}", &key, &value)) { + gboolean path_is_found = FALSE; + if (g_strcmp0 (value, path) == 0) { + path_is_found = TRUE; + path_counter++; + if (g_strcmp0 (key, schema) == 0) { + is_schema_found = TRUE; + } else { + // skip incoorect schema for path + is_incorrect_schema = TRUE; + g_free (key); + g_free (value); + continue; + } + } + + gboolean need_add_to_dict = !path_is_found || path_counter < 2; + + if (need_add_to_dict) { + g_variant_builder_add (&builder, "{ss}", key, value); + } + + g_free (key); + g_free (value); + } + + if (!is_schema_found) { + g_variant_builder_add (&builder, "{ss}", schema, path); + } + + if (!is_schema_found || is_incorrect_schema || (path_counter > 1)) { + return g_variant_ref_sink (g_variant_builder_end (&builder)); + } else { + g_variant_builder_clear (&builder); + // no changes + return NULL; + } +} + +static void +register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path) +{ + GSettingsSchemaSource *source; + GSettingsSchema *dconf_editor_schema; + GSettings *dconf_editor_settings; + + source = g_settings_schema_source_get_default (); + + if (! source) + return; + + dconf_editor_schema = g_settings_schema_source_lookup (source, "ca.desrt.dconf-editor.Settings", FALSE); + + if (! dconf_editor_schema) + return; + + dconf_editor_settings = g_settings_new_full (dconf_editor_schema, NULL, NULL); + + 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 = add_to_dict (relocatable_schemas, schema, path); + if (new_relocatable_schemas) { + 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); + g_settings_schema_unref (dconf_editor_schema); +} + GSettings * mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema) { @@ -40,6 +136,7 @@ mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema) if (path) { settings = g_settings_new_with_path (schema, path); + register_dconf_editor_relocatable_schema (schema, path); g_free (path); } @@ -51,24 +148,24 @@ mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key) { gchar **array; GList *list = NULL; - gint i; + array = g_settings_get_strv (settings, key); if (array != NULL) { - for (i = 0; array[i]; i++) { - list = g_list_append (list, g_strdup (array[i])); + for (gint i = 0; array[i]; i++) { + list = g_list_prepend (list, array[i]); } + g_free (array); } - g_strfreev (array); - return list; + return g_list_reverse (list); } void mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list) { GArray *array; - GList *l; + array = g_array_new (TRUE, TRUE, sizeof (gchar *)); - for (l = list; l; l = l->next) { + for (GList *l = list; l; l = l->next) { array = g_array_append_val (array, l->data); } g_settings_set_strv (settings, key, (const gchar **) array->data); @@ -80,24 +177,24 @@ mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key) { gchar **array; GSList *list = NULL; - gint i; + array = g_settings_get_strv (settings, key); if (array != NULL) { - for (i = 0; array[i]; i++) { - list = g_slist_append (list, g_strdup (array[i])); + for (gint i = 0; array[i]; i++) { + list = g_slist_prepend (list, array[i]); } + g_free (array); } - g_strfreev (array); - return list; + return g_slist_reverse (list); } void mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list) { GArray *array; - GSList *l; + array = g_array_new (TRUE, TRUE, sizeof (gchar *)); - for (l = list; l; l = l->next) { + for (GSList *l = list; l; l = l->next) { array = g_array_append_val (array, l->data); } g_settings_set_strv (settings, key, (const gchar **) array->data); diff --git a/libmate-panel-applet/mate-panel-applet-gsettings.h b/libmate-panel-applet/mate-panel-applet-gsettings.h index 43b2de8c..152a73d2 100644 --- a/libmate-panel-applet/mate-panel-applet-gsettings.h +++ b/libmate-panel-applet/mate-panel-applet-gsettings.h @@ -2,6 +2,7 @@ * mate-panel-applet-gsettings.h: panel applet preferences handling. * * Copyright (C) 2012 Stefano Karapetsas + * 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 @@ -34,7 +35,15 @@ G_BEGIN_DECLS +/** + * mate_panel_applet_settings_new: + * @applet A #MatePanelApplet + * @schema applet's schema id + * + * Returns: (transfer full): a #GSettings. free when you used it + */ GSettings* mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema); + GList* mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key); void mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list); GSList* mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key); diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 3d6a4ac1..48e12622 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -3,6 +3,7 @@ * * Copyright (c) 2010 Carlos Garcia Campos <[email protected]> * Copyright (C) 2001 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 @@ -147,7 +148,8 @@ static const GtkActionEntry menu_entries[] = { static const GtkToggleActionEntry menu_toggle_entries[] = { { "Lock", NULL, N_("Loc_k To Panel"), NULL, NULL, - G_CALLBACK (mate_panel_applet_menu_cmd_lock) } + G_CALLBACK (mate_panel_applet_menu_cmd_lock), + FALSE } }; G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX) @@ -601,7 +603,6 @@ mate_panel_applet_request_focus (MatePanelApplet *applet, guint32 timestamp) { #ifdef HAVE_X11 - MatePanelAppletPrivate *priv; GdkScreen *screen; GdkWindow *root; GdkDisplay *display; @@ -615,8 +616,7 @@ mate_panel_applet_request_focus (MatePanelApplet *applet, g_return_if_fail (MATE_PANEL_IS_APPLET (applet)); - priv = mate_panel_applet_get_instance_private (applet); - screen = gtk_window_get_screen (GTK_WINDOW (priv->plug)); + screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/ root = gdk_screen_get_root_window (screen); display = gdk_screen_get_display (screen); @@ -843,36 +843,21 @@ mate_panel_applet_finalize (GObject *object) g_dbus_connection_unregister_object (priv->connection, priv->object_id); priv->object_id = 0; - g_object_unref (priv->connection); - priv->connection = NULL; + g_clear_object (&priv->connection); } - if (priv->object_path) { - g_free (priv->object_path); - priv->object_path = NULL; - } + g_clear_pointer (&priv->object_path, g_free); mate_panel_applet_set_preferences_path (applet, NULL); - if (priv->applet_action_group) { - g_object_unref (priv->applet_action_group); - priv->applet_action_group = NULL; - } - - if (priv->panel_action_group) { - g_object_unref (priv->panel_action_group); - priv->panel_action_group = NULL; - } - - if (priv->ui_manager) { - g_object_unref (priv->ui_manager); - priv->ui_manager = NULL; - } + g_clear_object (&priv->applet_action_group); + g_clear_object (&priv->panel_action_group); + g_clear_object (&priv->ui_manager); - g_free (priv->size_hints); - g_free (priv->prefs_path); - g_free (priv->background); - g_free (priv->id); + g_clear_pointer (&priv->size_hints, g_free); + g_clear_pointer (&priv->prefs_path, g_free); + g_clear_pointer (&priv->background, g_free); + g_clear_pointer (&priv->id, g_free); /* closure is owned by the factory */ priv->closure = NULL; @@ -1057,12 +1042,22 @@ mate_panel_applet_button_press (GtkWidget *widget, } } +#ifdef HAVE_WAYLAND + /*Limit the window list's applet menu to the handle area*/ + if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ()))) + { + MatePanelAppletFlags flags; + flags = mate_panel_applet_get_flags (applet); + if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR) + return FALSE; + } +#endif + if (event->button == 3) { mate_panel_applet_menu_popup (applet, (GdkEvent *) event); return TRUE; } - return mate_panel_applet_button_event (applet, event); } @@ -1560,7 +1555,6 @@ mate_panel_applet_handle_background (MatePanelApplet *applet) 0, PANEL_PIXMAP_BACKGROUND, NULL, pattern); - cairo_pattern_destroy (pattern); break; @@ -1624,8 +1618,9 @@ mate_panel_applet_change_background(MatePanelApplet *applet, switch (type) { case PANEL_NO_BACKGROUND: if (priv->out_of_process){ - pattern = cairo_pattern_create_rgba (0,0,0,0); /* Using NULL here breaks transparent */ - gdk_window_set_background_pattern(window,pattern); /* backgrounds set by GTK theme */ + cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */ + gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */ + cairo_pattern_destroy (transparent); } break; case PANEL_COLOR_BACKGROUND: @@ -1804,7 +1799,7 @@ mate_panel_applet_setup (MatePanelApplet *applet) MatePanelAppletPrivate *priv; GValue value = {0, }; GArray *params; - gint i; + guint i; gboolean ret; priv = mate_panel_applet_get_instance_private (applet); @@ -1956,7 +1951,7 @@ mate_panel_applet_constructor (GType type, gtk_widget_set_name (widget, "PanelPlug"); _mate_panel_applet_prepare_css (context); - g_signal_connect_swapped (G_OBJECT (priv->plug), "embedded", + g_signal_connect_swapped (priv->plug, "embedded", G_CALLBACK (mate_panel_applet_setup), applet); @@ -2007,7 +2002,6 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) widget_class->realize = mate_panel_applet_realize; widget_class->key_press_event = mate_panel_applet_key_press_event; - gobject_class->finalize = mate_panel_applet_finalize; g_object_class_install_property (gobject_class, @@ -2103,7 +2097,7 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) G_PARAM_READWRITE)); mate_panel_applet_signals [CHANGE_ORIENT] = - g_signal_new ("change_orient", + g_signal_new ("change-orient", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (MatePanelAppletClass, change_orient), @@ -2115,7 +2109,7 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) G_TYPE_UINT); mate_panel_applet_signals [CHANGE_SIZE] = - g_signal_new ("change_size", + g_signal_new ("change-size", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (MatePanelAppletClass, change_size), @@ -2127,7 +2121,7 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) G_TYPE_INT); mate_panel_applet_signals [CHANGE_BACKGROUND] = - g_signal_new ("change_background", + g_signal_new ("change-background", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (MatePanelAppletClass, change_background), @@ -2323,7 +2317,8 @@ static const gchar introspection_xml[] = static const GDBusInterfaceVTable interface_vtable = { method_call_cb, get_property_cb, - set_property_cb + set_property_cb, + { 0 } }; static GDBusNodeInfo *introspection_data = NULL; @@ -2429,7 +2424,6 @@ _mate_panel_applet_factory_main_internal (const gchar *factory_id, g_return_val_if_fail(callback != NULL, 1); g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET)); - #ifdef HAVE_X11 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { /*Use this both in and out of process as the tray applet always uses GtkSocket diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index fb869879..9cc48ae8 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -2,6 +2,7 @@ * mate-panel-applet.h: panel applet writing API. * * Copyright (C) 2001 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 @@ -133,7 +134,6 @@ int mate_panel_applet_factory_setup_in_process (const gchar MatePanelAppletFactoryCallback callback, gpointer data); - /* * These macros are getting a bit unwieldy. * diff --git a/libmate-panel-applet/panel-applet-private.h b/libmate-panel-applet/panel-applet-private.h index ea1dd6c2..904a94a6 100644 --- a/libmate-panel-applet/panel-applet-private.h +++ b/libmate-panel-applet/panel-applet-private.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2010 Carlos Garcia Campos + * 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 @@ -19,7 +20,7 @@ */ #ifndef PANEL_APPLET_PRIVATE_H -#define PANEL_APPLET_RPIVATE_H +#define PANEL_APPLET_PRIVATE_H #include "mate-panel-applet.h" diff --git a/libmate-panel-applet/panel-plug-private.h b/libmate-panel-applet/panel-plug-private.h index 5d5f1265..ae906fc7 100644 --- a/libmate-panel-applet/panel-plug-private.h +++ b/libmate-panel-applet/panel-plug-private.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 Alberts Muktupāvels + * Copyright (C) 2016-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/libmate-panel-applet/panel-plug.c b/libmate-panel-applet/panel-plug.c index 3bf3def0..ec24a85a 100644 --- a/libmate-panel-applet/panel-plug.c +++ b/libmate-panel-applet/panel-plug.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 Alberts Muktupāvels + * Copyright (C) 2016-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/libmate-panel-applet/test-dbus-applet.c b/libmate-panel-applet/test-dbus-applet.c index bfd00e5e..cb520680 100644 --- a/libmate-panel-applet/test-dbus-applet.c +++ b/libmate-panel-applet/test-dbus-applet.c @@ -171,18 +171,15 @@ test_applet_fill (TestApplet *applet) mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_HAS_HANDLE); - g_signal_connect (G_OBJECT (applet), - "change_orient", + g_signal_connect (applet, "change-orient", G_CALLBACK (test_applet_handle_orient_change), NULL); - g_signal_connect (G_OBJECT (applet), - "change_size", + g_signal_connect (applet, "change-size", G_CALLBACK (test_applet_handle_size_change), NULL); - g_signal_connect (G_OBJECT (applet), - "change_background", + g_signal_connect (applet, "change-background", G_CALLBACK (test_applet_handle_background_change), NULL); @@ -202,7 +199,6 @@ test_applet_factory (TestApplet *applet, return retval; } - MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("TestAppletFactory", test_applet_get_type (), "A Test Applet for the MATE-3.0 Panel", |