aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/indicator-printers-menu.c36
-rw-r--r--src/show-printer-settings.c55
-rw-r--r--src/show-printer-settings.h8
4 files changed, 30 insertions, 71 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8a29965..7b66b1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,8 +30,6 @@ indicator_printers_service_SOURCES = \
indicator-printers-service.h \
indicator-printers-menu.c \
indicator-printers-menu.h \
- show-printer-settings.c \
- show-printer-settings.h \
$(cups_notifier_sources)
indicator_printers_service_CPPFLAGS = $(SERVICE_CFLAGS)
diff --git a/src/indicator-printers-menu.c b/src/indicator-printers-menu.c
index f9e0e35..1548610 100644
--- a/src/indicator-printers-menu.c
+++ b/src/indicator-printers-menu.c
@@ -1,7 +1,6 @@
#include "indicator-printers-menu.h"
-#include "show-printer-settings.h"
#include <cups/cups.h>
@@ -117,12 +116,37 @@ get_number_of_active_jobs (const gchar *printer)
static void
-show_system_settings (DbusmenuMenuitem *menuitem,
- guint timestamp,
- gpointer user_data)
+spawn_command_line_async_f (const gchar *fmt,
+ ...)
+{
+ va_list args;
+ gchar *cmdline;
+ GError *err = NULL;
+
+ va_start (args, fmt);
+ cmdline = g_strdup_vprintf (fmt, args);
+ va_end (args);
+
+ g_spawn_command_line_async (cmdline, &err);
+ if (err) {
+ g_warning ("Couldn't execute command `%s`: %s",
+ cmdline, err->message);
+ g_error_free (err);
+ }
+
+ g_free (cmdline);
+}
+
+
+static void
+on_printer_item_activated (DbusmenuMenuitem *menuitem,
+ guint timestamp,
+ gpointer user_data)
{
const gchar *printer = user_data;
- show_printer_settings (printer);
+
+ spawn_command_line_async_f ("gnome-control-center printers show-printer %s",
+ printer);
}
@@ -142,7 +166,7 @@ update_printer_menuitem (IndicatorPrintersMenu *self,
dbusmenu_menuitem_property_set (item, "indicator-icon-name", "printer");
dbusmenu_menuitem_property_set (item, "indicator-label", printer);
g_signal_connect_data (item, "item-activated",
- G_CALLBACK (show_system_settings),
+ G_CALLBACK (on_printer_item_activated),
g_strdup (printer), (GClosureNotify) g_free, 0);
dbusmenu_menuitem_child_append(self->priv->root, item);
diff --git a/src/show-printer-settings.c b/src/show-printer-settings.c
deleted file mode 100644
index b213bb2..0000000
--- a/src/show-printer-settings.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2012 Canonical Ltd.
- *
- * Authors: Lars Uebernickel <lars.uebernickel@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gio/gio.h>
-
-
-void
-show_printer_settings (const gchar *printer)
-{
- GAppInfo *appinfo;
- GError *err = NULL;
- gchar *cmdline;
-
- if (printer)
- cmdline = g_strdup_printf ("gnome-control-center printers show-printer %s",
- printer);
- else
- cmdline = g_strdup_printf ("gnome-control-center printers");
-
- appinfo = g_app_info_create_from_commandline (cmdline,
- "gnome-control-center",
- G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION,
- &err);
- g_free (cmdline);
-
- if (err) {
- g_warning ("failed to create application info: %s", err->message);
- g_error_free (err);
- return;
- }
-
- g_app_info_launch (appinfo, NULL, NULL, &err);
- if (err) {
- g_warning ("failed to launch gnome-control-center: %s", err->message);
- g_error_free (err);
- }
-
- g_object_unref (appinfo);
-}
-
diff --git a/src/show-printer-settings.h b/src/show-printer-settings.h
deleted file mode 100644
index 7de5548..0000000
--- a/src/show-printer-settings.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef SHOW_PRINTER_SETTINGS_H
-#define SHOW_PRINTER_SETTINGS_H
-
-void show_printer_settings (const gchar *printer);
-
-#endif
-