From 75df9f6c041c84ea6b01ec1f1937c9804712dbe6 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 3 Feb 2012 16:07:18 +0100 Subject: Move g-c-c invocation out of indicator-printers-menu --- src/Makefile.am | 2 ++ src/indicator-printers-menu.c | 29 ++--------------------- src/show-printer-settings.c | 55 +++++++++++++++++++++++++++++++++++++++++++ src/show-printer-settings.h | 8 +++++++ 4 files changed, 67 insertions(+), 27 deletions(-) create mode 100644 src/show-printer-settings.c create mode 100644 src/show-printer-settings.h diff --git a/src/Makefile.am b/src/Makefile.am index 7b66b1b..8a29965 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,8 @@ 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 d029b75..f9e0e35 100644 --- a/src/indicator-printers-menu.c +++ b/src/indicator-printers-menu.c @@ -1,7 +1,7 @@ #include "indicator-printers-menu.h" -#include +#include "show-printer-settings.h" #include @@ -121,33 +121,8 @@ show_system_settings (DbusmenuMenuitem *menuitem, guint timestamp, gpointer user_data) { - GAppInfo *appinfo; - GError *err = NULL; const gchar *printer = user_data; - gchar *cmdline; - - cmdline = g_strdup_printf ("gnome-control-center printers show-printer %s", - printer); - - 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); + show_printer_settings (printer); } diff --git a/src/show-printer-settings.c b/src/show-printer-settings.c new file mode 100644 index 0000000..b213bb2 --- /dev/null +++ b/src/show-printer-settings.c @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * Authors: Lars Uebernickel + * + * 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 . + */ + +#include + + +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 new file mode 100644 index 0000000..7de5548 --- /dev/null +++ b/src/show-printer-settings.h @@ -0,0 +1,8 @@ + +#ifndef SHOW_PRINTER_SETTINGS_H +#define SHOW_PRINTER_SETTINGS_H + +void show_printer_settings (const gchar *printer); + +#endif + -- cgit v1.2.3