diff options
author | lukefromdc <[email protected]> | 2023-06-19 01:46:33 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2023-07-17 02:47:28 +0200 |
commit | 168de875415d503d2fc66d28f5e6f87b6871f693 (patch) | |
tree | 344cc3ed4f29a6726a2c882fd7aab0ca67f47e02 /command | |
parent | 6363c16faf18cc5780bdcb9d53420a583a6482e7 (diff) | |
download | mate-applets-168de875415d503d2fc66d28f5e6f87b6871f693.tar.bz2 mate-applets-168de875415d503d2fc66d28f5e6f87b6871f693.tar.xz |
command: Port to in-process for wayland compatability
- fix runtime warnings on applet removal
- disconnect signal on shutdown that otherwise throws warnings
- Required moving a function so it would be defined in time
Diffstat (limited to 'command')
-rw-r--r-- | command/data/Makefile.am | 14 | ||||
-rw-r--r-- | command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in | 4 | ||||
-rw-r--r-- | command/data/org.mate.panel.applet.CommandAppletFactory.service.in | 3 | ||||
-rw-r--r-- | command/src/Makefile.am | 24 | ||||
-rw-r--r-- | command/src/command.c | 70 |
5 files changed, 49 insertions, 66 deletions
diff --git a/command/data/Makefile.am b/command/data/Makefile.am index b94e9523..b6c82434 100644 --- a/command/data/Makefile.am +++ b/command/data/Makefile.am @@ -1,4 +1,4 @@ -APPLET_LOCATION = $(libexecdir)/command-applet +APPLET_LOCATION = $(libdir)/mate-applets/libcommand-applet.so appletsdir = $(datadir)/mate-panel/applets applets_in_files = org.mate.applets.CommandApplet.mate-panel-applet.desktop.in @@ -6,20 +6,12 @@ applets_DATA = $(applets_in_files:.mate-panel-applet.desktop.in=.mate-panel- $(applets_in_files): $(applets_in_files).in Makefile $(AM_V_GEN)sed \ - -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ + -e "s|\@APPLET_LOCATION\@|$(APPLET_LOCATION)|" \ $< > $@ $(applets_DATA): $(applets_in_files) Makefile $(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ -servicedir = $(datadir)/dbus-1/services -service_in_files = org.mate.panel.applet.CommandAppletFactory.service.in -service_DATA = $(service_in_files:.service.in=.service) - -org.mate.panel.applet.CommandAppletFactory.service: $(service_in_files) - $(AM_V_GEN)sed \ - -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ - $< > $@ command_gschema_in_files = org.mate.panel.applet.command.gschema.xml.in gsettings_SCHEMAS = $(command_gschema_in_files:.xml.in=.xml) @@ -27,7 +19,6 @@ gsettings_SCHEMAS = $(command_gschema_in_files:.xml.in=.xml) EXTRA_DIST = \ $(applets_in_files).in \ - $(service_in_files) \ $(command_gschema_in_files) \ command-preferences.ui \ command-resources.gresource.xml @@ -35,7 +26,6 @@ EXTRA_DIST = \ CLEANFILES = \ $(applets_DATA) \ $(applets_in_files) \ - $(service_DATA) \ $(gsettings_SCHEMAS) \ *.gschema.valid diff --git a/command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in b/command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in index 04f76f4a..1b2495ee 100644 --- a/command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in +++ b/command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in @@ -1,11 +1,13 @@ [Applet Factory] Id=CommandAppletFactory -Location=@LOCATION@ +Location=@APPLET_LOCATION@ +InProcess=true Name=Command Factory Description=Command Factory [CommandApplet] Name=Command Description=Shows the output of a command +Platforms=X11;Wayland; # Translators: Do NOT translate or transliterate this text (this is an icon file name)! Icon=utilities-terminal diff --git a/command/data/org.mate.panel.applet.CommandAppletFactory.service.in b/command/data/org.mate.panel.applet.CommandAppletFactory.service.in deleted file mode 100644 index a4e04846..00000000 --- a/command/data/org.mate.panel.applet.CommandAppletFactory.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.mate.panel.applet.CommandAppletFactory -Exec=@LOCATION@ diff --git a/command/src/Makefile.am b/command/src/Makefile.am index d0d2065a..3497672d 100644 --- a/command/src/Makefile.am +++ b/command/src/Makefile.am @@ -1,36 +1,27 @@ NULL = +command_applet_libdir= $(pkglibdir) +command_applet_lib_LTLIBRARIES=libcommand-applet.la + AM_CPPFLAGS = \ $(MATE_APPLETS4_CFLAGS) \ -I$(srcdir) \ $(DISABLE_DEPRECATED_CFLAGS) \ $(NULL) -libexec_PROGRAMS = command-applet - -BUILT_SOURCES = \ - command-resources.c \ - command-resources.h \ - $(NULL) -nodist_command_applet_SOURCES = \ - $(BUILT_SOURCES) \ - $(NULL) - -command_applet_SOURCES = \ +libcommand_applet_la_SOURCES = \ command.c \ ma-command.c \ ma-command.h \ + command-resources.c \ + command-resources.h \ $(NULL) -command_applet_LDADD = \ +libcommand_applet_la_LIBADD = \ $(MATE_APPLETS4_LIBS) \ $(NULL) -command_applet_CFLAGS = \ - $(WARN_CFLAGS) \ - $(NULL) - command-resources.c: $(srcdir)/../data/command-resources.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/../data --generate-dependencies $(srcdir)/../data/command-resources.gresource.xml) $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data --generate --c-name command $< @@ -38,7 +29,6 @@ command-resources.h: $(srcdir)/../data/command-resources.gresource.xml $(shell $ $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/../data --generate --c-name command $< CLEANFILES = \ - $(BUILT_SOURCES) \ $(NULL) -include $(top_srcdir)/git.mk diff --git a/command/src/command.c b/command/src/command.c index 2cc44e49..cc751349 100644 --- a/command/src/command.c +++ b/command/src/command.c @@ -90,11 +90,47 @@ static const GtkActionEntry applet_menu_actions [] = { static char *ui = "<menuitem name='Item 1' action='Preferences' />" "<menuitem name='Item 2' action='About' />"; +/* GSettings signal callbacks */ +static void +settings_command_changed (GSettings *settings, gchar *key, CommandApplet *command_applet) +{ + GError *error = NULL; + gchar *cmdline; + gchar **argv; + + cmdline = g_settings_get_string (command_applet->settings, COMMAND_KEY); + if (strlen (cmdline) == 0 || g_strcmp0(command_applet->cmdline, cmdline) == 0) + { + g_free (cmdline); + return; + } + + if (!g_shell_parse_argv (cmdline, NULL, &argv, &error)) + { + gtk_label_set_text (command_applet->label, ERROR_OUTPUT); + g_clear_error (&error); + g_free (cmdline); + return; + } + g_strfreev(argv); + + if (command_applet->cmdline) + g_free (command_applet->cmdline); + command_applet->cmdline = cmdline; + + command_execute (command_applet); +} + static void command_applet_destroy (MatePanelApplet *applet_widget, CommandApplet *command_applet) { g_assert (command_applet); + g_signal_handlers_disconnect_by_func (command_applet->settings, + G_CALLBACK (settings_command_changed), + command_applet); + + if (command_applet->timeout_id != 0) { g_source_remove (command_applet->timeout_id); @@ -215,37 +251,6 @@ command_settings_callback (GtkAction *action, CommandApplet *command_applet) gtk_widget_show_all (GTK_WIDGET (dialog)); } -/* GSettings signal callbacks */ -static void -settings_command_changed (GSettings *settings, gchar *key, CommandApplet *command_applet) -{ - GError *error = NULL; - gchar *cmdline; - gchar **argv; - - cmdline = g_settings_get_string (command_applet->settings, COMMAND_KEY); - if (strlen (cmdline) == 0 || g_strcmp0(command_applet->cmdline, cmdline) == 0) - { - g_free (cmdline); - return; - } - - if (!g_shell_parse_argv (cmdline, NULL, &argv, &error)) - { - gtk_label_set_text (command_applet->label, ERROR_OUTPUT); - g_clear_error (&error); - g_free (cmdline); - return; - } - g_strfreev(argv); - - if (command_applet->cmdline) - g_free (command_applet->cmdline); - command_applet->cmdline = cmdline; - - command_execute (command_applet); -} - static void settings_width_changed (GSettings *settings, gchar *key, CommandApplet *command_applet) { @@ -413,7 +418,6 @@ command_applet_fill (MatePanelApplet* applet) CommandApplet *command_applet; AtkObject *atk_widget; - g_set_application_name (_("Command Applet")); gtk_window_set_default_icon_name (APPLET_ICON); mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); @@ -502,7 +506,7 @@ command_factory (MatePanelApplet* applet, const char* iid, gpointer data) } /* needed by mate-panel applet library */ -MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("CommandAppletFactory", +MATE_PANEL_APPLET_IN_PROCESS_FACTORY("CommandAppletFactory", PANEL_TYPE_APPLET, "Command applet", command_factory, |