diff options
Diffstat (limited to 'command/src')
-rw-r--r-- | command/src/Makefile.am | 37 | ||||
-rw-r--r-- | command/src/command.c | 82 |
2 files changed, 66 insertions, 53 deletions
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 ac756eb2..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); @@ -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,10 @@ 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); @@ -469,7 +477,7 @@ command_applet_fill (MatePanelApplet* applet) "visible", G_SETTINGS_BIND_DEFAULT); - atk_widget = gtk_widget_get_accessible (command_applet->applet); + 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")); @@ -502,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) |