summaryrefslogtreecommitdiff
path: root/command
diff options
context:
space:
mode:
Diffstat (limited to 'command')
-rw-r--r--command/data/Makefile.am28
-rw-r--r--command/data/org.mate.applets.CommandApplet.mate-panel-applet.desktop.in.in4
-rw-r--r--command/data/org.mate.panel.applet.CommandAppletFactory.service.in2
-rw-r--r--command/src/Makefile.am37
-rw-r--r--command/src/command.c123
5 files changed, 116 insertions, 78 deletions
diff --git a/command/data/Makefile.am b/command/data/Makefile.am
index b94e9523..47709166 100644
--- a/command/data/Makefile.am
+++ b/command/data/Makefile.am
@@ -1,34 +1,42 @@
+applets_in_files = org.mate.applets.CommandApplet.mate-panel-applet.desktop.in
+service_in_files = org.mate.panel.applet.CommandAppletFactory.service.in
+gschema_in_files = org.mate.panel.applet.command.gschema.xml.in
+
+if ENABLE_IN_PROCESS
+APPLET_LOCATION = $(pkglibdir)/libcommand-applet.so
+else !ENABLE_IN_PROCESS
APPLET_LOCATION = $(libexecdir)/command-applet
+endif !ENABLE_IN_PROCESS
appletsdir = $(datadir)/mate-panel/applets
-applets_in_files = org.mate.applets.CommandApplet.mate-panel-applet.desktop.in
applets_DATA = $(applets_in_files:.mate-panel-applet.desktop.in=.mate-panel-applet)
$(applets_in_files): $(applets_in_files).in Makefile
$(AM_V_GEN)sed \
- -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\@APPLET_LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\@APPLET_IN_PROCESS\@|$(APPLET_IN_PROCESS)|" \
$< > $@
$(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)
+if !ENABLE_IN_PROCESS
+servicedir = $(datadir)/dbus-1/services
+service_DATA = $(service_in_files:.service.in=.service)
-org.mate.panel.applet.CommandAppletFactory.service: $(service_in_files)
+$(service_DATA): $(service_in_files) Makefile
$(AM_V_GEN)sed \
- -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\@APPLET_LOCATION\@|$(APPLET_LOCATION)|" \
$< > $@
+endif !ENABLE_IN_PROCESS
-command_gschema_in_files = org.mate.panel.applet.command.gschema.xml.in
-gsettings_SCHEMAS = $(command_gschema_in_files:.xml.in=.xml)
+gsettings_SCHEMAS = $(gschema_in_files:.xml.in=.xml)
@GSETTINGS_RULES@
EXTRA_DIST = \
$(applets_in_files).in \
$(service_in_files) \
- $(command_gschema_in_files) \
+ $(gschema_in_files) \
command-preferences.ui \
command-resources.gresource.xml
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..6d14aedb 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=@APPLET_IN_PROCESS@
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
index a4e04846..aad043dd 100644
--- a/command/data/org.mate.panel.applet.CommandAppletFactory.service.in
+++ b/command/data/org.mate.panel.applet.CommandAppletFactory.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
Name=org.mate.panel.applet.CommandAppletFactory
-Exec=@LOCATION@
+Exec=@APPLET_LOCATION@
diff --git a/command/src/Makefile.am b/command/src/Makefile.am
index d0d2065a..b8a20cc1 100644
--- a/command/src/Makefile.am
+++ b/command/src/Makefile.am
@@ -1,35 +1,40 @@
NULL =
AM_CPPFLAGS = \
+ $(WARN_FLAGS) \
$(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) \
+APPLET_SOURCES = \
+ command.c \
+ ma-command.c \
+ ma-command.h \
$(NULL)
-command_applet_SOURCES = \
- command.c \
- ma-command.c \
- ma-command.h \
- $(NULL)
-
-command_applet_LDADD = \
+APPLET_LIBS = \
$(MATE_APPLETS4_LIBS) \
$(NULL)
-command_applet_CFLAGS = \
- $(WARN_CFLAGS) \
- $(NULL)
+if ENABLE_IN_PROCESS
+pkglib_LTLIBRARIES = libcommand-applet.la
+nodist_libcommand_applet_la_SOURCES = $(BUILT_SOURCES)
+libcommand_applet_la_SOURCES = $(APPLET_SOURCES)
+libcommand_applet_la_CFLAGS = $(AM_CFLAGS)
+libcommand_applet_la_LDFLAGS = -module -avoid-version
+libcommand_applet_la_LIBADD = $(APPLET_LIBS)
+else !ENABLE_IN_PROCESS
+libexec_PROGRAMS = command-applet
+nodist_command_applet_SOURCES = $(BUILT_SOURCES)
+command_applet_SOURCES = $(APPLET_SOURCES)
+command_applet_CFLAGS = $(AM_CFLAGS)
+command_applet_LDADD = $(APPLET_LIBS)
+endif !ENABLE_IN_PROCESS
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 +43,7 @@ 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) \
+ $(BUILT_SOURCES)
$(NULL)
-include $(top_srcdir)/git.mk
diff --git a/command/src/command.c b/command/src/command.c
index f53bef43..c4ff027a 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);
@@ -125,7 +161,7 @@ command_about_callback (GtkAction *action, CommandApplet *command_applet)
"title", _("About Command Applet"),
"version", VERSION,
"copyright", _("Copyright \xc2\xa9 2013-2014 Stefano Karapetsas\n"
- "Copyright \xc2\xa9 2015-2020 MATE developers"),
+ "Copyright \xc2\xa9 2015-2021 MATE developers"),
"authors", authors,
"comments", _("Shows the output of a command"),
"translator-credits", _("translator-credits"),
@@ -205,40 +241,16 @@ command_settings_callback (GtkAction *action, CommandApplet *command_applet)
"on_width_spinbutton_value_changed", G_CALLBACK (width_value_changed),
NULL);
gtk_builder_connect_signals (builder, command_applet);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
g_object_unref (builder);
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)
- return;
-
- if (!g_shell_parse_argv (cmdline, NULL, &argv, &error))
- {
- gtk_label_set_text (command_applet->label, ERROR_OUTPUT);
- g_clear_error (&error);
- 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)
{
@@ -404,12 +416,15 @@ static gboolean
command_applet_fill (MatePanelApplet* applet)
{
CommandApplet *command_applet;
+ AtkObject *atk_widget;
+#ifndef ENABLE_IN_PROCESS
g_set_application_name (_("Command Applet"));
+#endif
+
gtk_window_set_default_icon_name (APPLET_ICON);
mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
- mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
command_applet = g_malloc0(sizeof(CommandApplet));
command_applet->applet = applet;
@@ -439,29 +454,37 @@ command_applet_fill (MatePanelApplet* applet)
gtk_widget_show_all (GTK_WIDGET (command_applet->applet));
- g_signal_connect(G_OBJECT (command_applet->applet), "destroy",
- G_CALLBACK (command_applet_destroy),
- command_applet);
+ g_signal_connect (command_applet->applet, "destroy",
+ G_CALLBACK (command_applet_destroy),
+ command_applet);
/* GSettings signals */
- g_signal_connect(command_applet->settings,
- "changed::" COMMAND_KEY,
- G_CALLBACK (settings_command_changed),
- command_applet);
- g_signal_connect(command_applet->settings,
- "changed::" INTERVAL_KEY,
- G_CALLBACK (settings_interval_changed),
- command_applet);
- g_signal_connect(command_applet->settings,
- "changed::" WIDTH_KEY,
- G_CALLBACK (settings_width_changed),
- command_applet);
+ g_signal_connect (command_applet->settings, "changed::" COMMAND_KEY,
+ G_CALLBACK (settings_command_changed),
+ command_applet);
+
+ g_signal_connect (command_applet->settings, "changed::" INTERVAL_KEY,
+ G_CALLBACK (settings_interval_changed),
+ command_applet);
+
+ g_signal_connect (command_applet->settings, "changed::" WIDTH_KEY,
+ G_CALLBACK (settings_width_changed),
+ command_applet);
+
g_settings_bind (command_applet->settings,
SHOW_ICON_KEY,
command_applet->image,
"visible",
G_SETTINGS_BIND_DEFAULT);
+ atk_widget = gtk_widget_get_accessible (GTK_WIDGET (command_applet->applet));
+ if (GTK_IS_ACCESSIBLE (atk_widget)) {
+ atk_object_set_name (atk_widget,
+ _("Command applet"));
+ atk_object_set_description (atk_widget,
+ _("Shows the output of a command"));
+ }
+
/* set up context menu */
GtkActionGroup *action_group = gtk_action_group_new ("Command Applet Actions");
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
@@ -487,8 +510,8 @@ command_factory (MatePanelApplet* applet, const char* iid, gpointer data)
}
/* needed by mate-panel applet library */
-MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("CommandAppletFactory",
- PANEL_TYPE_APPLET,
- "Command applet",
- command_factory,
- NULL)
+PANEL_APPLET_FACTORY ("CommandAppletFactory",
+ PANEL_TYPE_APPLET,
+ "Command applet",
+ command_factory,
+ NULL)