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-gsettings.c | 124 | ||||
| -rw-r--r-- | libmate-panel-applet/mate-panel-applet-gsettings.h | 8 | ||||
| -rw-r--r-- | libmate-panel-applet/mate-panel-applet.c | 20 |
4 files changed, 135 insertions, 19 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-gsettings.c b/libmate-panel-applet/mate-panel-applet-gsettings.c index 1c0ac744..93d0b4ce 100644 --- a/libmate-panel-applet/mate-panel-applet-gsettings.c +++ b/libmate-panel-applet/mate-panel-applet-gsettings.c @@ -29,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) { @@ -41,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); } @@ -52,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); @@ -81,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 0dbbdb01..152a73d2 100644 --- a/libmate-panel-applet/mate-panel-applet-gsettings.h +++ b/libmate-panel-applet/mate-panel-applet-gsettings.h @@ -35,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 026ee941..897f1726 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -45,6 +45,10 @@ #include <X11/Xatom.h> #include "panel-plug-private.h" #endif +#ifndef HAVE_X11 +#include <gdk/gdkwayland.h> +#define GDK_IS_X11_DISPLAY(object) !(G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DISPLAY)) +#endif #include "mate-panel-applet.h" #include "panel-applet-private.h" @@ -603,7 +607,6 @@ mate_panel_applet_request_focus (MatePanelApplet *applet, guint32 timestamp) { #ifdef HAVE_X11 - MatePanelAppletPrivate *priv; GdkScreen *screen; GdkWindow *root; GdkDisplay *display; @@ -617,8 +620,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); @@ -1044,12 +1046,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); } |
