indicator-printers-0.1.7+17.10.20171101/0000775000175000017500000000000013203576753016743 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/Makefile.am0000664000175000017500000000017313203575646021000 0ustar seb128seb12800000000000000 SUBDIRS = src data test po DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall include $(top_srcdir)/Makefile.am.coverage indicator-printers-0.1.7+17.10.20171101/po/0000775000175000017500000000000013203576753017361 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/po/POTFILES.in0000664000175000017500000000025313203575646021136 0ustar seb128seb12800000000000000[encoding: UTF-8] src/indicator-menu-item.c src/indicator-printers.c src/indicator-printers-menu.c src/indicator-printers-service.c src/indicator-printer-state-notifier.c indicator-printers-0.1.7+17.10.20171101/autogen.sh0000775000175000017500000000022113203575646020737 0ustar seb128seb12800000000000000#!/bin/sh which gnome-autogen.sh || { echo "Could not find 'gnome-autgen.sh'. Is gnome-common installed?" exit 1 } . gnome-autogen.sh indicator-printers-0.1.7+17.10.20171101/test/0000775000175000017500000000000013203576753017722 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/test/Makefile.am0000664000175000017500000000121313203575646021753 0ustar seb128seb12800000000000000 noinst_PROGRAMS = mock-cups-notifier DISTCLEANFILES = mock-cups-notifier cups_notifier_sources = \ cups-notifier.c \ cups-notifier.h $(cups_notifier_sources): $(top_srcdir)/src/org.cups.cupsd.Notifier.xml gdbus-codegen \ --interface-prefix org.cups.cupsd \ --c-namespace Cups \ --generate-c-code cups-notifier \ $^ mock_cups_notifier_SOURCES = \ mock-cups-notifier.c nodist_mock_cups_notifier_SOURCES = $(cups_notifier_sources) mock_cups_notifier_CPPFLAGS = \ $(SERVICE_CFLAGS) \ -I$(top_builddir)/src mock_cups_notifier_LDADD = $(SERVICE_LIBS) BUILT_SOURCES = $(cups_notifier_sources) CLEANFILES = $(BUILT_SOURCES) indicator-printers-0.1.7+17.10.20171101/test/mock-cups-notifier.c0000664000175000017500000000267213203575646023613 0ustar seb128seb12800000000000000 #include #include int main (int argc, char **argv) { GMainLoop *loop; CupsNotifier *notifier; GDBusConnection *con; GError *error = NULL; g_type_init (); loop = g_main_loop_new (NULL, FALSE); con = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (error) { g_printerr ("Error getting system bus: %s\n", error->message); g_error_free (error); goto out; } notifier = cups_notifier_skeleton_new (); g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (notifier), con, "/org/cups/cupsd/Notifier", &error); if (error) { g_printerr ("Error exporting cups Notifier object: %s\n", error->message); g_error_free (error); goto out; } cups_notifier_emit_printer_state_changed (notifier, "Printer state changed!", "file:///tmp/print", "hp-LaserJet-1012", 5, "toner-low", FALSE); g_main_context_iteration (NULL, FALSE); out: g_clear_object (¬ifier); g_clear_object (&con); g_main_loop_unref (loop); return 0; } indicator-printers-0.1.7+17.10.20171101/Makefile.am.coverage0000664000175000017500000000250513203575646022573 0ustar seb128seb12800000000000000 # Coverage targets .PHONY: clean-gcno clean-gcda \ coverage-html generate-coverage-html clean-coverage-html \ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr if HAVE_GCOV clean-gcno: @echo Removing old coverage instrumentation -find -name '*.gcno' -print | xargs -r rm clean-gcda: @echo Removing old coverage results -find -name '*.gcda' -print | xargs -r rm coverage-html: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html generate-coverage-html: @echo Collecting coverage data $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info clean-coverage-html: clean-gcda -$(LCOV) --directory $(top_builddir) -z -rm -rf coverage.info coveragereport if HAVE_GCOVR coverage-gcovr: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr generate-coverage-gcovr: @echo Generating coverage GCOVR report $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml clean-coverage-gcovr: clean-gcda -rm -rf $(top_builddir)/coverage.xml endif # HAVE_GCOVR endif # HAVE_GCOV indicator-printers-0.1.7+17.10.20171101/src/0000775000175000017500000000000013203576753017532 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/src/Makefile.am0000664000175000017500000000262613203575646021574 0ustar seb128seb12800000000000000 printersmenulibdir = $(INDICATORDIR) printersmenulib_LTLIBRARIES = libprintersmenu.la libprintersmenu_la_SOURCES = \ indicator-printers.c \ indicator-printers.h \ indicator-menu-item.c \ indicator-menu-item.h \ dbus-names.h libprintersmenu_la_CPPFLAGS = $(APPLET_CFLAGS) libprintersmenu_la_CFLAGS = $(COVERAGE_CFLAGS) libprintersmenu_la_LIBADD = $(APPLET_LIBS) -lm libprintersmenu_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) \ -module -avoid-version cups_notifier_sources = \ cups-notifier.c \ cups-notifier.h $(cups_notifier_sources): org.cups.cupsd.Notifier.xml gdbus-codegen \ --interface-prefix org.cups.cupsd \ --c-namespace Cups \ --generate-c-code cups-notifier \ $^ pkglibexec_PROGRAMS = indicator-printers-service indicator_printers_service_SOURCES = \ indicator-printers-service.c \ indicator-printers-menu.c \ indicator-printers-menu.h \ indicator-printer-state-notifier.c \ indicator-printer-state-notifier.h \ spawn-printer-settings.c \ spawn-printer-settings.h \ dbus-names.h nodist_indicator_printers_service_SOURCES = $(cups_notifier_sources) indicator_printers_service_CPPFLAGS = $(SERVICE_CFLAGS) indicator_printers_service_CFLAGS = $(COVERAGE_CFLAGS) indicator_printers_service_LDADD = $(SERVICE_LIBS) indicator_printers_service_LDFLAGS = $(COVERAGE_LDFLAGS) BUILT_SOURCES = $(cups_notifier_sources) CLEANFILES= $(BUILT_SOURCES) EXTRA_DIST = org.cups.cupsd.Notifier.xml indicator-printers-0.1.7+17.10.20171101/src/indicator-menu-item.h0000664000175000017500000000531113203575646023555 0ustar seb128seb12800000000000000/* * 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 . */ #ifndef INDICATOR_MENU_ITEM_H #define INDICATOR_MENU_ITEM_H #include G_BEGIN_DECLS #define INDICATOR_TYPE_MENU_ITEM indicator_menu_item_get_type() #define INDICATOR_MENU_ITEM(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ INDICATOR_TYPE_MENU_ITEM, IndicatorMenuItem)) #define INDICATOR_MENU_ITEM_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ INDICATOR_TYPE_MENU_ITEM, IndicatorMenuItemClass)) #define INDICATOR_IS_MENU_ITEM(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ INDICATOR_TYPE_MENU_ITEM)) #define INDICATOR_IS_MENU_ITEM_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), \ INDICATOR_TYPE_MENU_ITEM)) #define INDICATOR_MENU_ITEM_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ INDICATOR_TYPE_MENU_ITEM, IndicatorMenuItemClass)) typedef struct _IndicatorMenuItem IndicatorMenuItem; typedef struct _IndicatorMenuItemClass IndicatorMenuItemClass; typedef struct _IndicatorMenuItemPrivate IndicatorMenuItemPrivate; struct _IndicatorMenuItem { GtkMenuItem parent; IndicatorMenuItemPrivate *priv; }; struct _IndicatorMenuItemClass { GtkMenuItemClass parent_class; }; GType indicator_menu_item_get_type (void) G_GNUC_CONST; IndicatorMenuItem *indicator_menu_item_new (void); const gchar * indicator_menu_item_get_label (IndicatorMenuItem *self); void indicator_menu_item_set_label (IndicatorMenuItem *self, const gchar *text); const gchar * indicator_menu_item_get_right (IndicatorMenuItem *self); void indicator_menu_item_set_right (IndicatorMenuItem *self, const gchar *text); gboolean indicator_menu_item_get_right_is_lozenge (IndicatorMenuItem *self); void indicator_menu_item_set_right_is_lozenge (IndicatorMenuItem *self, gboolean is_lozenge); const gchar * indicator_menu_item_get_icon_name (IndicatorMenuItem *self); void indicator_menu_item_set_icon (IndicatorMenuItem *self, GdkPixbuf *icon); GdkPixbuf * indicator_menu_item_get_icon (IndicatorMenuItem *self); void indicator_menu_item_set_icon_name (IndicatorMenuItem *self, const gchar *name); G_END_DECLS #endif indicator-printers-0.1.7+17.10.20171101/src/indicator-printers-menu.c0000664000175000017500000002446613203575661024471 0ustar seb128seb12800000000000000/* * 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 "indicator-printers-menu.h" #include #include #include "spawn-printer-settings.h" G_DEFINE_TYPE (IndicatorPrintersMenu, indicator_printers_menu, G_TYPE_OBJECT) struct _IndicatorPrintersMenuPrivate { DbusmenuMenuitem *root; GHashTable *printers; /* printer name -> dbusmenuitem */ CupsNotifier *cups_notifier; }; enum { PROP_0, PROP_CUPS_NOTIFIER, NUM_PROPERTIES }; GParamSpec *properties[NUM_PROPERTIES]; static void dispose (GObject *object) { IndicatorPrintersMenu *self = INDICATOR_PRINTERS_MENU (object); if (self->priv->printers) { g_hash_table_unref (self->priv->printers); self->priv->printers = NULL; } g_clear_object (&self->priv->root); g_clear_object (&self->priv->cups_notifier); G_OBJECT_CLASS (indicator_printers_menu_parent_class)->dispose (object); } void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { IndicatorPrintersMenu *self = INDICATOR_PRINTERS_MENU (object); switch (property_id) { case PROP_CUPS_NOTIFIER: indicator_printers_menu_set_cups_notifier (self, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { IndicatorPrintersMenu *self = INDICATOR_PRINTERS_MENU (object); switch (property_id) { case PROP_CUPS_NOTIFIER: g_value_set_object (value, indicator_printers_menu_get_cups_notifier (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void indicator_printers_menu_class_init (IndicatorPrintersMenuClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (IndicatorPrintersMenuPrivate)); object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; properties[PROP_CUPS_NOTIFIER] = g_param_spec_object ("cups-notifier", "Cups Notifier", "A cups notifier object", CUPS_TYPE_NOTIFIER, G_PARAM_READWRITE); g_object_class_install_properties (object_class, NUM_PROPERTIES, properties); } static void on_printer_item_activated (DbusmenuMenuitem *menuitem, guint timestamp, gpointer user_data) { const gchar *printer = user_data; spawn_printer_settings_with_args ("--show-jobs %s", printer); } static void update_indicator_visibility (IndicatorPrintersMenu *self) { GList *it; gboolean is_visible = FALSE; for (it = dbusmenu_menuitem_get_children (self->priv->root); it; it = g_list_next (it)) { DbusmenuMenuitem *child = it->data; if ((is_visible = dbusmenu_menuitem_property_get_bool (child, "visible"))) break; } dbusmenu_menuitem_property_set_bool (self->priv->root, "visible", is_visible); } static void update_printer_menuitem (IndicatorPrintersMenu *self, const char *printer, int state) { DbusmenuMenuitem *item; int njobs; cups_job_t *jobs; njobs = cupsGetJobs (&jobs, printer, 1, CUPS_WHICHJOBS_ACTIVE); cupsFreeJobs (njobs, jobs); if (njobs < 0) { g_warning ("printer '%s' does not exist\n", printer); return; } item = g_hash_table_lookup (self->priv->printers, printer); if (!item) { item = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (item, "type", "indicator-item"); 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 (on_printer_item_activated), g_strdup (printer), (GClosureNotify) g_free, 0); dbusmenu_menuitem_child_append(self->priv->root, item); g_hash_table_insert (self->priv->printers, g_strdup (printer), item); } if (njobs == 0) { dbusmenu_menuitem_property_set_bool (item, "visible", FALSE); update_indicator_visibility (self); return; } /* there are jobs for this printer. Make sure the indicator and the menu * item for that printer are shown */ dbusmenu_menuitem_property_set_bool (self->priv->root, "visible", TRUE); dbusmenu_menuitem_property_set_bool (item, "visible", TRUE); switch (state) { case IPP_PRINTER_STOPPED: dbusmenu_menuitem_property_set (item, "indicator-right", _("Paused")); dbusmenu_menuitem_property_set_bool (item, "indicator-right-is-lozenge", FALSE); break; case IPP_PRINTER_PROCESSING: { gchar *jobstr = g_strdup_printf ("%d", njobs); dbusmenu_menuitem_property_set (item, "indicator-right", jobstr); dbusmenu_menuitem_property_set_bool (item, "indicator-right-is-lozenge", TRUE); g_free (jobstr); break; } } } static void update_all_printer_menuitems (IndicatorPrintersMenu *self) { int ndests, i; cups_dest_t *dests; ndests = cupsGetDests (&dests); for (i = 0; i < ndests; i++) { const char *val = cupsGetOption ("printer-state", dests[i].num_options, dests[i].options); if (val != NULL) { int state = atoi (val); update_printer_menuitem (self, dests[i].name, state); } } cupsFreeDests (ndests, dests); } static void update_job (CupsNotifier *cups_notifier, const gchar *text, const gchar *printer_uri, const gchar *printer_name, guint printer_state, const gchar *printer_state_reasons, gboolean printer_is_accepting_jobs, guint job_id, guint job_state, const gchar *job_state_reasons, const gchar *job_name, guint job_impressions_completed, gpointer user_data) { IndicatorPrintersMenu *self = INDICATOR_PRINTERS_MENU (user_data); /* CUPS doesn't send the printer's name for these events. Update all menu * items as a temporary workaround */ if (job_state == IPP_JOB_CANCELLED || job_state == IPP_JOB_ABORTED || job_state == IPP_JOB_COMPLETED) update_all_printer_menuitems (self); else update_printer_menuitem (self, printer_name, printer_state); } static void on_printer_state_changed (CupsNotifier *object, const gchar *text, const gchar *printer_uri, const gchar *printer_name, guint printer_state, const gchar *printer_state_reasons, gboolean printer_is_accepting_jobs, gpointer user_data) { IndicatorPrintersMenu *self = INDICATOR_PRINTERS_MENU (user_data); update_printer_menuitem (self, printer_name, printer_state); } static void indicator_printers_menu_init (IndicatorPrintersMenu *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, INDICATOR_TYPE_PRINTERS_MENU, IndicatorPrintersMenuPrivate); self->priv->root = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set_bool (self->priv->root, "visible", FALSE); self->priv->printers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); /* create initial menu items */ update_all_printer_menuitems (self); } IndicatorPrintersMenu * indicator_printers_menu_new (void) { return g_object_new (INDICATOR_TYPE_PRINTERS_MENU, NULL); } DbusmenuMenuitem * indicator_printers_menu_get_root (IndicatorPrintersMenu *self) { return self->priv->root; } CupsNotifier * indicator_printers_menu_get_cups_notifier (IndicatorPrintersMenu *self) { return self->priv->cups_notifier; } void indicator_printers_menu_set_cups_notifier (IndicatorPrintersMenu *self, CupsNotifier *cups_notifier) { if (self->priv->cups_notifier) { g_object_disconnect (self->priv->cups_notifier, "any-signal", update_job, self, "any-signal", on_printer_state_changed, self, NULL); g_clear_object (&self->priv->cups_notifier); } if (cups_notifier) { self->priv->cups_notifier = g_object_ref (cups_notifier); g_object_connect (self->priv->cups_notifier, "signal::job-created", update_job, self, "signal::job-state", update_job, self, "signal::job-completed", update_job, self, "signal::printer-state-changed", on_printer_state_changed, self, NULL); } } indicator-printers-0.1.7+17.10.20171101/src/indicator-printer-state-notifier.c0000664000175000017500000002527313203575646026277 0ustar seb128seb12800000000000000/* * 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 "indicator-printer-state-notifier.h" #include #include #include #include #include #include "cups-notifier.h" #include "spawn-printer-settings.h" #define RESPONSE_SHOW_SYSTEM_SETTINGS 1 G_DEFINE_TYPE (IndicatorPrinterStateNotifier, indicator_printer_state_notifier, G_TYPE_OBJECT) struct _IndicatorPrinterStateNotifierPrivate { CupsNotifier *cups_notifier; /* printer states that were already notified about in this session */ GHashTable *notified_printer_states; /* state-reason -> user visible string with a %s for printer name */ GHashTable *printer_alerts; }; enum { PROP_0, PROP_CUPS_NOTIFIER, NUM_PROPERTIES }; GParamSpec *properties[NUM_PROPERTIES]; static void g_hash_table_insert_many (GHashTable *hash_table, gpointer key, ...) { va_list args; va_start (args, key); while (key) { gpointer value = va_arg (args, gpointer); g_hash_table_insert (hash_table, key, value); key = va_arg (args, gpointer); } va_end (args); } /* returns a list of strings that are in a but not in b; does not copy the * strings */ static GList * g_strv_diff (gchar **a, gchar **b) { GList *result = NULL; gchar **p; if (!a) return NULL; for (p = a; *p; p++) { if (!g_strv_contains ((const gchar * const *) b, *p)) result = g_list_prepend (result, *p); } return g_list_reverse (result); } void show_alert_box (const gchar *printer, const gchar *reason, int njobs) { GtkWidget *dialog; GtkWidget *image; gchar *primary_text; gchar *secondary_text; image = gtk_image_new_from_icon_name ("printer", GTK_ICON_SIZE_DIALOG); primary_text = g_strdup_printf (reason, printer); secondary_text = g_strdup_printf (ngettext( "You have %d job queued to print on this printer.", "You have %d jobs queued to print on this printer.", njobs), njobs); dialog = g_object_new (GTK_TYPE_MESSAGE_DIALOG, "title", _("Printing Problem"), "icon-name", "printer", "image", image, "text", primary_text, "secondary-text", secondary_text, "urgency-hint", TRUE, "focus-on-map", FALSE, "window-position", GTK_WIN_POS_CENTER, "skip-taskbar-hint", FALSE, "deletable", FALSE, NULL); g_free (primary_text); g_free (secondary_text); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("_Settings…"), RESPONSE_SHOW_SYSTEM_SETTINGS, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_widget_show_all (dialog); if (gtk_dialog_run (GTK_DIALOG (dialog)) == RESPONSE_SHOW_SYSTEM_SETTINGS) spawn_printer_settings (); gtk_widget_destroy (dialog); } static void on_printer_state_changed (CupsNotifier *object, const gchar *text, const gchar *printer_uri, const gchar *printer, guint printer_state, const gchar *printer_state_reasons, gboolean printer_is_accepting_jobs, gpointer user_data) { IndicatorPrinterStateNotifierPrivate *priv = INDICATOR_PRINTER_STATE_NOTIFIER (user_data)->priv; int njobs; cups_job_t *jobs; gchar **state_reasons, **already_notified; GList *new_state_reasons, *it; njobs = cupsGetJobs (&jobs, printer, 1, CUPS_WHICHJOBS_ACTIVE); cupsFreeJobs (njobs, jobs); /* don't show any events if the current user does not have jobs queued on * that printer or this printer is unknown to CUPS */ if (njobs <= 0) return; state_reasons = g_strsplit (printer_state_reasons, " ", 0); already_notified = g_hash_table_lookup (priv->notified_printer_states, printer); new_state_reasons = g_strv_diff (state_reasons, already_notified); for (it = new_state_reasons; it; it = g_list_next (new_state_reasons)) { const gchar *reason_text = g_hash_table_lookup (priv->printer_alerts, it->data); if (reason_text) show_alert_box (printer, reason_text, njobs); } g_list_free (new_state_reasons); g_hash_table_replace (priv->notified_printer_states, g_strdup (printer), state_reasons); } static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { IndicatorPrinterStateNotifier *self = INDICATOR_PRINTER_STATE_NOTIFIER (object); switch (property_id) { case PROP_CUPS_NOTIFIER: g_value_set_object (value, indicator_printer_state_notifier_get_cups_notifier (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { IndicatorPrinterStateNotifier *self = INDICATOR_PRINTER_STATE_NOTIFIER (object); switch (property_id) { case PROP_CUPS_NOTIFIER: indicator_printer_state_notifier_set_cups_notifier (self, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void dispose (GObject *object) { IndicatorPrinterStateNotifier *self = INDICATOR_PRINTER_STATE_NOTIFIER (object); if (self->priv->notified_printer_states) { g_hash_table_unref (self->priv->notified_printer_states); self->priv->notified_printer_states = NULL; } if (self->priv->printer_alerts) { g_hash_table_unref (self->priv->printer_alerts); self->priv->printer_alerts = NULL; } g_clear_object (&self->priv->cups_notifier); G_OBJECT_CLASS (indicator_printer_state_notifier_parent_class)->dispose (object); } static void finalize (GObject *object) { G_OBJECT_CLASS (indicator_printer_state_notifier_parent_class)->finalize (object); } static void indicator_printer_state_notifier_class_init (IndicatorPrinterStateNotifierClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (IndicatorPrinterStateNotifierPrivate)); object_class->get_property = get_property; object_class->set_property = set_property; object_class->dispose = dispose; object_class->finalize = finalize; properties[PROP_CUPS_NOTIFIER] = g_param_spec_object ("cups-notifier", "Cups Notifier", "A cups notifier object", CUPS_TYPE_NOTIFIER, G_PARAM_READWRITE); g_object_class_install_properties (object_class, NUM_PROPERTIES, properties); } static void indicator_printer_state_notifier_init (IndicatorPrinterStateNotifier *self) { IndicatorPrinterStateNotifierPrivate *priv; priv = G_TYPE_INSTANCE_GET_PRIVATE (self, INDICATOR_TYPE_PRINTER_STATE_NOTIFIER, IndicatorPrinterStateNotifierPrivate); self->priv = priv; priv->notified_printer_states = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_strfreev); priv->printer_alerts = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert_many ( priv->printer_alerts, "media-low", _("The printer “%s” is low on paper."), "media-empty", _("The printer “%s” is out of paper."), "toner-low", _("The printer “%s” is low on toner."), "toner-empty", _("The printer “%s” is out of toner."), "cover-open", _("A cover is open on the printer “%s”."), "door-open", _("A door is open on the printer “%s”."), "cups-missing-filter", _("The printer “%s” can’t be used, because required software is missing."), "offline", _("The printer “%s” is currently off-line."), NULL); } CupsNotifier * indicator_printer_state_notifier_get_cups_notifier (IndicatorPrinterStateNotifier *self) { return self->priv->cups_notifier; } void indicator_printer_state_notifier_set_cups_notifier (IndicatorPrinterStateNotifier *self, CupsNotifier *cups_notifier) { if (self->priv->cups_notifier) { g_signal_handlers_disconnect_by_func (self->priv->cups_notifier, on_printer_state_changed, self); g_clear_object (&self->priv->cups_notifier); } if (cups_notifier) { self->priv->cups_notifier = g_object_ref (cups_notifier); g_signal_connect (cups_notifier, "printer-state-changed", G_CALLBACK (on_printer_state_changed), self); } } indicator-printers-0.1.7+17.10.20171101/src/dbus-names.h0000664000175000017500000000225113203575646021741 0ustar seb128seb12800000000000000/* * 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 . */ #ifndef DBUS_NAMES_H #define DBUS_NAMES_H #define INDICATOR_PRINTERS_DBUS_NAME "com.canonical.indicator.printers" #define INDICATOR_PRINTERS_DBUS_OBJECT_PATH "/com/canonical/indicator/printers" #define INDICATOR_PRINTERS_DBUS_INTERFACE "com.canonical.indicator.printers" #define INDICATOR_PRINTERS_DBUS_VERSION 1 #define CUPS_DBUS_NAME "org.cups.cupsd.Notifier" #define CUPS_DBUS_PATH "/org/cups/cupsd/Notifier" #define CUPS_DBUS_INTERFACE "org.cups.cupsd.Notifier" #endif indicator-printers-0.1.7+17.10.20171101/src/indicator-printers-service.c0000664000175000017500000001435713203575646025166 0ustar seb128seb12800000000000000/* * 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 #include #include #include #include "dbus-names.h" #include "config.h" #include "cups-notifier.h" #include "indicator-printers-menu.h" #include "indicator-printer-state-notifier.h" #define NOTIFY_LEASE_DURATION (24 * 60 * 60) static int create_subscription () { ipp_t *req; ipp_t *resp; ipp_attribute_t *attr; int id = 0; req = ippNewRequest (IPP_CREATE_PRINTER_SUBSCRIPTION); ippAddString (req, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "/"); ippAddString (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD, "notify-events", NULL, "all"); ippAddString (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI, "notify-recipient-uri", NULL, "dbus://"); ippAddInteger (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER, "notify-lease-duration", NOTIFY_LEASE_DURATION); resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/"); if (!resp || cupsLastError() != IPP_OK) { g_warning ("Error subscribing to CUPS notifications: %s\n", cupsLastErrorString ()); return 0; } attr = ippFindAttribute (resp, "notify-subscription-id", IPP_TAG_INTEGER); if (attr) id = ippGetInteger (attr, 0); else g_warning ("ipp-create-printer-subscription response doesn't contain " "subscription id.\n"); ippDelete (resp); return id; } static gboolean renew_subscription (int id) { ipp_t *req; ipp_t *resp; req = ippNewRequest (IPP_RENEW_SUBSCRIPTION); ippAddInteger (req, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "notify-subscription-id", id); ippAddString (req, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "/"); ippAddString (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI, "notify-recipient-uri", NULL, "dbus://"); ippAddInteger (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER, "notify-lease-duration", NOTIFY_LEASE_DURATION); resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/"); if (!resp || cupsLastError() != IPP_OK) { g_warning ("Error renewing CUPS subscription %d: %s\n", id, cupsLastErrorString ()); return FALSE; } ippDelete (resp); return TRUE; } static gboolean renew_subscription_timeout (gpointer userdata) { int *subscription_id = userdata; if (*subscription_id <= 0 || !renew_subscription (*subscription_id)) *subscription_id = create_subscription (); return TRUE; } void cancel_subscription (int id) { ipp_t *req; ipp_t *resp; if (id <= 0) return; req = ippNewRequest (IPP_CANCEL_SUBSCRIPTION); ippAddString (req, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "/"); ippAddInteger (req, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "notify-subscription-id", id); resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/"); if (!resp || cupsLastError() != IPP_OK) { g_warning ("Error subscribing to CUPS notifications: %s\n", cupsLastErrorString ()); return; } ippDelete (resp); } static void name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { int subscription_id = GPOINTER_TO_INT (user_data); cancel_subscription (subscription_id); gtk_main_quit (); } int main (int argc, char *argv[]) { /* Init i18n */ setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); DbusmenuServer *menuserver; CupsNotifier *cups_notifier; IndicatorPrintersMenu *menu; IndicatorPrinterStateNotifier *state_notifier; GError *error = NULL; int subscription_id; gtk_init (&argc, &argv); subscription_id = create_subscription (); g_timeout_add_seconds (NOTIFY_LEASE_DURATION - 60, renew_subscription_timeout, &subscription_id); g_bus_own_name (G_BUS_TYPE_SESSION, INDICATOR_PRINTERS_DBUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, name_lost, GINT_TO_POINTER (subscription_id), NULL); cups_notifier = cups_notifier_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, 0, NULL, CUPS_DBUS_PATH, NULL, &error); if (error) { g_warning ("Error creating cups notify handler: %s", error->message); g_error_free (error); return 1; } menu = g_object_new (INDICATOR_TYPE_PRINTERS_MENU, "cups-notifier", cups_notifier, NULL); menuserver = dbusmenu_server_new (INDICATOR_PRINTERS_DBUS_OBJECT_PATH); dbusmenu_server_set_root (menuserver, indicator_printers_menu_get_root (menu)); state_notifier = g_object_new (INDICATOR_TYPE_PRINTER_STATE_NOTIFIER, "cups-notifier", cups_notifier, NULL); gtk_main (); g_object_unref (menu); g_object_unref (menuserver); g_object_unref (state_notifier); g_object_unref (cups_notifier); return 0; } indicator-printers-0.1.7+17.10.20171101/src/spawn-printer-settings.h0000664000175000017500000000030013203575646024343 0ustar seb128seb12800000000000000 #ifndef SPAWN_PRINTER_SETTINGS_H #define SPAWN_PRINTER_SETTINGS_H #include void spawn_printer_settings (); void spawn_printer_settings_with_args (const gchar *args, ...); #endif indicator-printers-0.1.7+17.10.20171101/src/indicator-menu-item.c0000664000175000017500000003072113203575646023553 0ustar seb128seb12800000000000000/* * 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 "indicator-menu-item.h" #include G_DEFINE_TYPE (IndicatorMenuItem, indicator_menu_item, GTK_TYPE_MENU_ITEM) struct _IndicatorMenuItemPrivate { GtkImage *image; GtkWidget *label; GtkWidget *right_label; gboolean right_is_lozenge; }; enum { PROP_0, PROP_ICON, PROP_ICON_NAME, PROP_LABEL, PROP_RIGHT, PROP_RIGHT_IS_LOZENGE, N_PROPERTIES }; static GParamSpec *properties[N_PROPERTIES]; static gint gtk_widget_get_font_size (GtkWidget *widget) { const PangoFontDescription *font; font = gtk_style_context_get_font (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget)); return pango_font_description_get_size (font) / PANGO_SCALE; } static void cairo_lozenge (cairo_t *cr, double x, double y, double w, double h) { double radius = MIN (w / 2.0, h / 2.0); double x1 = x + w - radius; double x2 = x + radius; double y1 = y + radius; double y2 = y + h - radius; cairo_move_to (cr, x+radius, y); cairo_arc (cr, x1, y1, radius, M_PI * 1.5, M_PI * 2); cairo_arc (cr, x1, y2, radius, 0, M_PI * 0.5); cairo_arc (cr, x2, y2, radius, M_PI * 0.5, M_PI); cairo_arc (cr, x2, y1, radius, M_PI, M_PI * 1.5); } static gboolean detail_label_draw (GtkWidget *widget, cairo_t *cr, gpointer data) { GtkAllocation allocation; double x, y, w, h; GdkRGBA color; PangoLayout *layout; PangoRectangle layout_extents; gboolean is_lozenge = *(gboolean *)data; gint font_size = gtk_widget_get_font_size (widget); /* let the label handle the drawing if it's not a lozenge */ if (!is_lozenge) return FALSE; layout = gtk_label_get_layout (GTK_LABEL(widget)); pango_layout_get_extents (layout, NULL, &layout_extents); pango_extents_to_pixels (&layout_extents, NULL); gtk_widget_get_allocation (widget, &allocation); x = -font_size / 2.0; y = 1; w = allocation.width; h = MIN (allocation.height, layout_extents.height + 4); if (layout_extents.width == 0) return TRUE; gtk_style_context_get_color (gtk_widget_get_style_context (widget), gtk_widget_get_state_flags (widget), &color); gdk_cairo_set_source_rgba (cr, &color); cairo_set_line_width (cr, 1.0); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_lozenge (cr, x - font_size / 2.0, y, w + font_size, h); x += (w - layout_extents.width) / 2.0; y += (h - layout_extents.height) / 2.0; cairo_move_to (cr, floor (x), floor (y)); pango_cairo_layout_path (cr, layout); cairo_fill (cr); return TRUE; } static void indicator_menu_item_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { IndicatorMenuItem *self = INDICATOR_MENU_ITEM (object); switch (property_id) { case PROP_ICON: g_value_set_object (value, indicator_menu_item_get_icon (self)); break; case PROP_ICON_NAME: g_value_set_string (value, indicator_menu_item_get_icon_name (self)); break; case PROP_LABEL: g_value_set_string (value, gtk_label_get_label (GTK_LABEL (self->priv->label))); break; case PROP_RIGHT: g_value_set_string (value, gtk_label_get_label (GTK_LABEL (self->priv->right_label))); break; case PROP_RIGHT_IS_LOZENGE: g_value_set_boolean (value, self->priv->right_is_lozenge); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void indicator_menu_item_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_ICON: indicator_menu_item_set_icon (INDICATOR_MENU_ITEM (object), g_value_get_object (value)); break; case PROP_ICON_NAME: indicator_menu_item_set_icon_name (INDICATOR_MENU_ITEM (object), g_value_get_string (value)); break; case PROP_LABEL: indicator_menu_item_set_label (INDICATOR_MENU_ITEM (object), g_value_get_string (value)); break; case PROP_RIGHT: indicator_menu_item_set_right (INDICATOR_MENU_ITEM (object), g_value_get_string (value)); break; case PROP_RIGHT_IS_LOZENGE: indicator_menu_item_set_right_is_lozenge (INDICATOR_MENU_ITEM (object), g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void indicator_menu_item_dispose (GObject *object) { IndicatorMenuItem *self = INDICATOR_MENU_ITEM (object); g_clear_object (&self->priv->image); g_clear_object (&self->priv->label); g_clear_object (&self->priv->right_label); G_OBJECT_CLASS (indicator_menu_item_parent_class)->dispose (object); } static void indicator_menu_item_class_init (IndicatorMenuItemClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (IndicatorMenuItemPrivate)); object_class->get_property = indicator_menu_item_get_property; object_class->set_property = indicator_menu_item_set_property; object_class->dispose = indicator_menu_item_dispose; properties[PROP_ICON] = g_param_spec_object ("icon", "Icon", "Icon for this menu item", GDK_TYPE_PIXBUF, G_PARAM_READWRITE); properties[PROP_ICON_NAME] = g_param_spec_string ("icon-name", "Icon name", "Name of the themed icon", "", G_PARAM_READWRITE); properties[PROP_LABEL] = g_param_spec_string ("label", "Label", "The text for the main label", "", G_PARAM_READWRITE); properties[PROP_RIGHT] = g_param_spec_string ("right", "Right", "The text on the right side of the menu item", "", G_PARAM_READWRITE); properties[PROP_RIGHT_IS_LOZENGE] = g_param_spec_boolean ("right-is-lozenge", "Right is a lozenge", "Whether the right label is displayed as a lonzenge", FALSE, G_PARAM_READWRITE); g_object_class_install_properties (object_class, N_PROPERTIES, properties); } static void indicator_menu_item_init (IndicatorMenuItem *self) { IndicatorMenuItemPrivate *priv; gint spacing; GtkWidget *hbox; priv = G_TYPE_INSTANCE_GET_PRIVATE (self, INDICATOR_TYPE_MENU_ITEM, IndicatorMenuItemPrivate); self->priv = priv; gtk_widget_style_get (GTK_WIDGET (self), "toggle-spacing", &spacing, NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, spacing); priv->image = g_object_new (GTK_TYPE_IMAGE, NULL); g_object_ref_sink (priv->image); gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0); priv->label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0, NULL); g_object_ref_sink (priv->label); gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 0); priv->right_label = g_object_new (GTK_TYPE_LABEL, "xalign", 1.0, "width-chars", 2, NULL); gtk_style_context_add_class (gtk_widget_get_style_context (priv->right_label), "accelerator"); g_signal_connect (priv->right_label, "draw", G_CALLBACK (detail_label_draw), &priv->right_is_lozenge); g_object_ref_sink (priv->right_label); gtk_box_pack_start (GTK_BOX (hbox), priv->right_label, FALSE, FALSE, gtk_widget_get_font_size (priv->right_label) / 2.0 + 1); gtk_container_add (GTK_CONTAINER (self), hbox); priv->right_is_lozenge = FALSE; } IndicatorMenuItem * indicator_menu_item_new (void) { return g_object_new (INDICATOR_TYPE_MENU_ITEM, NULL); } const gchar * indicator_menu_item_get_label (IndicatorMenuItem *self) { return gtk_label_get_label (GTK_LABEL (self->priv->label)); } void indicator_menu_item_set_label (IndicatorMenuItem *self, const gchar *text) { gtk_label_set_label (GTK_LABEL (self->priv->label), text); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LABEL]); } const gchar * indicator_menu_item_get_right (IndicatorMenuItem *self) { return gtk_label_get_label (GTK_LABEL (self->priv->right_label)); } void indicator_menu_item_set_right (IndicatorMenuItem *self, const gchar *text) { gtk_label_set_label (GTK_LABEL (self->priv->right_label), text); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RIGHT]); } gboolean indicator_menu_item_get_right_is_lozenge (IndicatorMenuItem *self) { return self->priv->right_is_lozenge; } void indicator_menu_item_set_right_is_lozenge (IndicatorMenuItem *self, gboolean is_lozenge) { self->priv->right_is_lozenge = is_lozenge; gtk_widget_queue_draw (self->priv->right_label); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RIGHT_IS_LOZENGE]); } GdkPixbuf * indicator_menu_item_get_icon (IndicatorMenuItem *self) { if (gtk_image_get_storage_type (self->priv->image) == GTK_IMAGE_PIXBUF) return gtk_image_get_pixbuf (self->priv->image); else return NULL; } void indicator_menu_item_set_icon (IndicatorMenuItem *self, GdkPixbuf *icon) { gtk_image_set_from_pixbuf (self->priv->image, icon); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]); } const gchar * indicator_menu_item_get_icon_name (IndicatorMenuItem *self) { const gchar *name = NULL; if (gtk_image_get_storage_type (self->priv->image) == GTK_IMAGE_ICON_NAME) gtk_image_get_icon_name (self->priv->image, &name, NULL); return name; } void indicator_menu_item_set_icon_name (IndicatorMenuItem *self, const gchar *name) { gtk_image_set_from_icon_name (self->priv->image, name, GTK_ICON_SIZE_MENU); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]); } indicator-printers-0.1.7+17.10.20171101/src/indicator-printer-state-notifier.h0000664000175000017500000000501313203575646026272 0ustar seb128seb12800000000000000/* * 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 . */ #ifndef INDICATOR_PRINTER_STATE_NOTIFIER_H #define INDICATOR_PRINTER_STATE_NOTIFIER_H #include #include "cups-notifier.h" G_BEGIN_DECLS #define INDICATOR_TYPE_PRINTER_STATE_NOTIFIER indicator_printer_state_notifier_get_type() #define INDICATOR_PRINTER_STATE_NOTIFIER(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ INDICATOR_TYPE_PRINTER_STATE_NOTIFIER, IndicatorPrinterStateNotifier)) #define INDICATOR_PRINTER_STATE_NOTIFIER_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ INDICATOR_TYPE_PRINTER_STATE_NOTIFIER, IndicatorPrinterStateNotifierClass)) #define INDICATOR_IS_PRINTER_STATE_NOTIFIER(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ INDICATOR_TYPE_PRINTER_STATE_NOTIFIER)) #define INDICATOR_IS_PRINTER_STATE_NOTIFIER_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), \ INDICATOR_TYPE_PRINTER_STATE_NOTIFIER)) #define INDICATOR_PRINTER_STATE_NOTIFIER_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ INDICATOR_TYPE_PRINTER_STATE_NOTIFIER, IndicatorPrinterStateNotifierClass)) typedef struct _IndicatorPrinterStateNotifier IndicatorPrinterStateNotifier; typedef struct _IndicatorPrinterStateNotifierClass IndicatorPrinterStateNotifierClass; typedef struct _IndicatorPrinterStateNotifierPrivate IndicatorPrinterStateNotifierPrivate; struct _IndicatorPrinterStateNotifier { GObject parent; IndicatorPrinterStateNotifierPrivate *priv; }; struct _IndicatorPrinterStateNotifierClass { GObjectClass parent_class; }; GType indicator_printer_state_notifier_get_type (void) G_GNUC_CONST; CupsNotifier * indicator_printer_state_notifier_get_cups_notifier (IndicatorPrinterStateNotifier *self); void indicator_printer_state_notifier_set_cups_notifier (IndicatorPrinterStateNotifier *self, CupsNotifier *cups_notifier); G_END_DECLS #endif indicator-printers-0.1.7+17.10.20171101/src/indicator-printers.c0000664000175000017500000002251713203575646023525 0ustar seb128seb12800000000000000/* * 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 "config.h" #include "indicator-printers.h" #include "indicator-menu-item.h" #include "dbus-names.h" #include #include #include #include #include #include #include INDICATOR_SET_VERSION INDICATOR_SET_TYPE(INDICATOR_PRINTERS_TYPE) G_DEFINE_TYPE (IndicatorPrinters, indicator_printers, INDICATOR_OBJECT_TYPE) struct _IndicatorPrintersPrivate { IndicatorObjectEntry entry; guint name_watch; }; static void dispose (GObject *object) { IndicatorPrinters *self = INDICATOR_PRINTERS (object); if (self->priv->name_watch != 0) { g_bus_unwatch_name(self->priv->name_watch); self->priv->name_watch = 0; } g_clear_object (&self->priv->entry.menu); g_clear_object (&self->priv->entry.image); G_OBJECT_CLASS (indicator_printers_parent_class)->dispose (object); } static GList * get_entries (IndicatorObject *io) { IndicatorPrinters *self = INDICATOR_PRINTERS (io); return g_list_append (NULL, &self->priv->entry); } static void indicator_printers_class_init (IndicatorPrintersClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (IndicatorPrintersPrivate)); object_class->dispose = dispose; io_class->get_entries = get_entries; } static void name_vanished (GDBusConnection * con, const gchar * name, gpointer user_data) { IndicatorPrinters *self = INDICATOR_PRINTERS (user_data); indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE); } static GdkPixbuf * gdk_pixbuf_new_from_encoded_data (guchar *data, gsize length) { GInputStream * input; GError *err = NULL; GdkPixbuf *img; input = g_memory_input_stream_new_from_data(data, length, NULL); if (input == NULL) return NULL; img = gdk_pixbuf_new_from_stream(input, NULL, &err); if (err) { g_warning("%s", err->message); g_error_free(err); } g_object_unref(input); return img; } static GdkPixbuf * g_variant_get_image (GVariant *value) { const gchar *strvalue = NULL; gsize length = 0; guchar *icondata; GdkPixbuf *img; if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) strvalue = g_variant_get_string(value, NULL); if (!strvalue || !*strvalue) { g_warning ("%s: value does not contain a base64 encoded image", __func__); return NULL; } icondata = g_base64_decode(strvalue, &length); img = gdk_pixbuf_new_from_encoded_data (icondata, length); g_free(icondata); return img; } static gboolean properties_match (const gchar *name, const gchar *prop, GVariant *value, const GVariantType *type) { return !g_strcmp0 (name, prop) && g_variant_is_of_type (value, type); } static void indicator_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GVariant *value, gpointer user_data) { IndicatorMenuItem *menuitem = user_data; if (properties_match (prop, "indicator-label", value, G_VARIANT_TYPE_STRING)) indicator_menu_item_set_label (menuitem, g_variant_get_string (value, NULL)); else if (properties_match (prop, "indicator-right", value, G_VARIANT_TYPE_STRING)) indicator_menu_item_set_right (menuitem, g_variant_get_string (value, NULL)); else if (properties_match (prop, "indicator-icon-name", value, G_VARIANT_TYPE_STRING)) indicator_menu_item_set_icon_name (menuitem, g_variant_get_string (value, NULL)); else if (properties_match (prop, "indicator-icon", value, G_VARIANT_TYPE_STRING)) { GdkPixbuf *pb = g_variant_get_image (value); indicator_menu_item_set_icon (menuitem, pb); g_object_unref (pb); } else if (properties_match (prop, "visible", value, G_VARIANT_TYPE_BOOLEAN)) gtk_widget_set_visible (GTK_WIDGET (menuitem), g_variant_get_boolean (value)); else if (properties_match (prop, "indicator-right-is-lozenge", value, G_VARIANT_TYPE_BOOLEAN)) indicator_menu_item_set_right_is_lozenge (menuitem, g_variant_get_boolean (value)); } static void root_property_changed (DbusmenuMenuitem *mi, gchar *prop, GVariant *value, gpointer user_data) { IndicatorObject *io = user_data; if (properties_match (prop, "visible", value, G_VARIANT_TYPE_BOOLEAN)) indicator_object_set_visible (io, g_variant_get_boolean (value)); } static gboolean new_indicator_item (DbusmenuMenuitem *newitem, DbusmenuMenuitem *parent, DbusmenuClient *client, gpointer user_data) { GtkWidget *menuitem; const gchar *icon_name, *text, *right_text; GVariant *icon; gboolean is_lozenge, visible; icon_name = dbusmenu_menuitem_property_get (newitem, "indicator-icon-name"); icon = dbusmenu_menuitem_property_get_variant (newitem, "indicator-icon"); text = dbusmenu_menuitem_property_get (newitem, "indicator-label"); right_text = dbusmenu_menuitem_property_get (newitem, "indicator-right"); is_lozenge = dbusmenu_menuitem_property_get_bool (newitem, "indicator-right-is-lozenge"); visible = dbusmenu_menuitem_property_get_bool (newitem, "visible"); menuitem = g_object_new (INDICATOR_TYPE_MENU_ITEM, "icon-name", icon_name, "label", text, "right", right_text, "right-is-lozenge", is_lozenge, "visible", visible, NULL); if (icon) { GdkPixbuf *pb = g_variant_get_image (icon); indicator_menu_item_set_icon (INDICATOR_MENU_ITEM (menuitem), pb); g_object_unref (pb); } gtk_widget_show_all (menuitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM (menuitem), parent); g_signal_connect(G_OBJECT(newitem), "property-changed", G_CALLBACK(indicator_prop_change_cb), menuitem); return TRUE; } static void root_changed (DbusmenuClient *client, DbusmenuMenuitem *newroot, gpointer user_data) { IndicatorPrinters *indicator = user_data; gboolean is_visible; if (newroot) { is_visible = dbusmenu_menuitem_property_get_bool (newroot, "visible"); g_signal_connect (newroot, "property-changed", G_CALLBACK (root_property_changed), indicator); } else is_visible = FALSE; indicator_object_set_visible (INDICATOR_OBJECT (indicator), is_visible); } static void indicator_printers_init (IndicatorPrinters *self) { IndicatorPrintersPrivate *priv; DbusmenuGtkMenu *menu; DbusmenuClient *client; GtkImage *image; priv = G_TYPE_INSTANCE_GET_PRIVATE (self, INDICATOR_PRINTERS_TYPE, IndicatorPrintersPrivate); self->priv = priv; priv->name_watch = g_bus_watch_name(G_BUS_TYPE_SESSION, INDICATOR_PRINTERS_DBUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE, NULL, /* appeared */ name_vanished, self, NULL); menu = dbusmenu_gtkmenu_new(INDICATOR_PRINTERS_DBUS_NAME, INDICATOR_PRINTERS_DBUS_OBJECT_PATH); client = DBUSMENU_CLIENT (dbusmenu_gtkmenu_get_client (menu)); dbusmenu_client_add_type_handler(client, "indicator-item", new_indicator_item); g_signal_connect (client, "root-changed", G_CALLBACK (root_changed), self); image = indicator_image_helper ("printer-symbolic"); gtk_widget_show (GTK_WIDGET (image)); priv->entry.name_hint = PACKAGE_NAME; priv->entry.accessible_desc = _("Printers"); priv->entry.menu = GTK_MENU (g_object_ref_sink (menu)); priv->entry.image = g_object_ref_sink (image); indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE); } IndicatorPrinters * indicator_printers_new (void) { return g_object_new (INDICATOR_PRINTERS_TYPE, NULL); } indicator-printers-0.1.7+17.10.20171101/src/org.cups.cupsd.Notifier.xml0000664000175000017500000001277313203575646024721 0ustar seb128seb12800000000000000 indicator-printers-0.1.7+17.10.20171101/src/spawn-printer-settings.c0000664000175000017500000000125713203575646024352 0ustar seb128seb12800000000000000 #include "spawn-printer-settings.h" void spawn_printer_settings () { spawn_printer_settings_with_args (NULL); } void spawn_printer_settings_with_args (const gchar *fmt, ...) { GString *cmdline; GError *err = NULL; cmdline = g_string_new ("system-config-printer "); if (fmt) { va_list args; va_start (args, fmt); g_string_append_vprintf (cmdline, fmt, args); va_end (args); } g_spawn_command_line_async (cmdline->str, &err); if (err) { g_warning ("Could not spawn printer settings: %s", err->message); g_error_free (err); } g_string_free (cmdline, TRUE); } indicator-printers-0.1.7+17.10.20171101/src/indicator-printers.h0000664000175000017500000000370213203575646023525 0ustar seb128seb12800000000000000/* * 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 . */ #ifndef INDICATOR_PRINTERS_H #define INDICATOR_PRINTERS_H #include G_BEGIN_DECLS #define INDICATOR_PRINTERS_TYPE indicator_printers_get_type() #define INDICATOR_PRINTERS(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ INDICATOR_PRINTERS_TYPE, IndicatorPrinters)) #define INDICATOR_PRINTERS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ INDICATOR_PRINTERS_TYPE, IndicatorPrintersClass)) #define INDICATOR_IS_PRINTERS(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ INDICATOR_PRINTERS_TYPE)) #define INDICATOR_IS_PRINTERS_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), \ INDICATOR_PRINTERS_TYPE)) #define INDICATOR_PRINTERS_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ INDICATOR_PRINTERS_TYPE, IndicatorPrintersClass)) typedef struct _IndicatorPrinters IndicatorPrinters; typedef struct _IndicatorPrintersClass IndicatorPrintersClass; typedef struct _IndicatorPrintersPrivate IndicatorPrintersPrivate; struct _IndicatorPrinters { IndicatorObject parent; IndicatorPrintersPrivate *priv; }; struct _IndicatorPrintersClass { IndicatorObjectClass parent_class; }; GType indicator_printers_get_type (void) G_GNUC_CONST; IndicatorPrinters *indicator_printers_new (void); G_END_DECLS #endif indicator-printers-0.1.7+17.10.20171101/src/indicator-printers-menu.h0000664000175000017500000000466213203575646024475 0ustar seb128seb12800000000000000/* * 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 . */ #ifndef INDICATOR_PRINTERS_MENU_H #define INDICATOR_PRINTERS_MENU_H #include #include #include "cups-notifier.h" G_BEGIN_DECLS #define INDICATOR_TYPE_PRINTERS_MENU indicator_printers_menu_get_type() #define INDICATOR_PRINTERS_MENU(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ INDICATOR_TYPE_PRINTERS_MENU, IndicatorPrintersMenu)) #define INDICATOR_PRINTERS_MENU_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), \ INDICATOR_TYPE_PRINTERS_MENU, IndicatorPrintersMenuClass)) #define INDICATOR_IS_PRINTERS_MENU(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ INDICATOR_TYPE_PRINTERS_MENU)) #define INDICATOR_IS_PRINTERS_MENU_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), \ INDICATOR_TYPE_PRINTERS_MENU)) #define INDICATOR_PRINTERS_MENU_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \ INDICATOR_TYPE_PRINTERS_MENU, IndicatorPrintersMenuClass)) typedef struct _IndicatorPrintersMenu IndicatorPrintersMenu; typedef struct _IndicatorPrintersMenuClass IndicatorPrintersMenuClass; typedef struct _IndicatorPrintersMenuPrivate IndicatorPrintersMenuPrivate; struct _IndicatorPrintersMenu { GObject parent; IndicatorPrintersMenuPrivate *priv; }; struct _IndicatorPrintersMenuClass { GObjectClass parent_class; }; GType indicator_printers_menu_get_type (void) G_GNUC_CONST; IndicatorPrintersMenu *indicator_printers_menu_new (void); DbusmenuMenuitem * indicator_printers_menu_get_root (IndicatorPrintersMenu *menu); CupsNotifier * indicator_printers_menu_get_cups_notifier (IndicatorPrintersMenu *self); void indicator_printers_menu_set_cups_notifier (IndicatorPrintersMenu *self, CupsNotifier *cups_notifier); G_END_DECLS #endif indicator-printers-0.1.7+17.10.20171101/data/0000775000175000017500000000000013203576753017654 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/data/Makefile.am0000664000175000017500000000171313203575646021712 0ustar seb128seb12800000000000000 BUILT_SOURCES= CLEANFILES= EXTRA_DIST= # # the systemd unit file # systemddir = $(SYSTEMD_USERDIR) systemd_DATA = indicator-printers.service systemd_in = $(systemd_DATA:.service=.service.in) $(systemd_DATA): $(systemd_in) $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ BUILT_SOURCES += $(systemd_DATA) EXTRA_DIST += $(systemd_in) CLEANFILES += $(systemd_DATA) # # the systemd upstart override # upstart_overridedir = $(datadir)/upstart/systemd-session/upstart upstart_override_DATA = indicator-printers.override EXTRA_DIST += $(upstart_override_DATA) # # the upstart job file # upstart_jobsdir = $(datadir)/upstart/sessions upstart_jobs_DATA = indicator-printers.conf upstart_jobs_in = $(upstart_jobs_DATA:.conf=.conf.in) $(upstart_jobs_DATA): $(upstart_jobs_in) $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ BUILT_SOURCES += $(upstart_jobs_DATA) CLEANFILES += $(upstart_jobs_DATA) EXTRA_DIST += $(upstart_jobs_in) indicator-printers-0.1.7+17.10.20171101/data/indicator-printers.conf.in0000664000175000017500000000054413203575646024753 0ustar seb128seb12800000000000000description "Indicator Printers Service" # NOTE: Limiting only to Unity 7 right now as it's still using # dbusmenu. That can be lifted after it is ported to GMenu start on indicator-services-start and xsession SESSION=ubuntu stop on desktop-end or indicator-services-end respawn respawn limit 2 10 exec $SNAP@pkglibexecdir@/indicator-printers-service indicator-printers-0.1.7+17.10.20171101/data/indicator-printers.override0000664000175000017500000000000713203575646025232 0ustar seb128seb12800000000000000manual indicator-printers-0.1.7+17.10.20171101/data/indicator-printers.service.in0000664000175000017500000000027513203575646025467 0ustar seb128seb12800000000000000[Unit] Description=Indicator Printers Service PartOf=graphical-session.target After=indicators-pre.target [Service] ExecStart=@pkglibexecdir@/indicator-printers-service Restart=on-failure indicator-printers-0.1.7+17.10.20171101/m4/0000775000175000017500000000000013203576753017263 5ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/m4/gcov.m40000664000175000017500000000470513203575646020471 0ustar seb128seb12800000000000000# Checks for existence of coverage tools: # * gcov # * lcov # * genhtml # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present # and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], [ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) if test "x$use_gcov" = "xyes"; then # we need gcc: if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-gcov]) fi # Check if ccache is being used AC_CHECK_PROG(SHTOOL, shtool, shtool) case `$SHTOOL path $CC` in *ccache*[)] gcc_ccache=yes;; *[)] gcc_ccache=no;; esac if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ glib_cv_lcov_version=invalid lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` for lcov_check_version in $lcov_version_list; do if test "$lcov_version" = "$lcov_check_version"; then glib_cv_lcov_version="$lcov_check_version (ok)" fi done ]) else lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi case $glib_cv_lcov_version in ""|invalid[)] lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." AC_MSG_ERROR([$lcov_msg]) LCOV="exit 0;" ;; esac if test -z "$GENHTML"; then AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi ac_cv_check_gcov=yes ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` changequote([,]) # Add the special gcc flags COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" # Check availability of gcovr AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test -z "$GCOVR"; then ac_cv_check_gcovr=no else ac_cv_check_gcovr=yes fi fi ]) # AC_TDD_GCOV indicator-printers-0.1.7+17.10.20171101/AUTHORS0000664000175000017500000000006313203575646020012 0ustar seb128seb12800000000000000Lars Uebernickel indicator-printers-0.1.7+17.10.20171101/README0000664000175000017500000000000013203575646017611 0ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/NEWS0000664000175000017500000000000013203575646017430 0ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/ChangeLog0000664000175000017500000000000013203575646020503 0ustar seb128seb12800000000000000indicator-printers-0.1.7+17.10.20171101/configure.ac0000664000175000017500000000561613203575646021241 0ustar seb128seb12800000000000000 AC_INIT(indicator-printers, 0.1.6) AC_PREREQ(2.53) AM_INIT_AUTOMAKE([]) AC_PROG_CC AC_PROG_INSTALL AC_PROG_LIBTOOL AM_PROG_CC_C_O AM_SILENT_RULES([yes]) AC_CONFIG_MACRO_DIR([m4]) AC_DEFUN([AC_DEFINE_PATH], [ test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' ac_define_path=`eval echo [$]$2` ac_define_path=`eval echo [$]ac_define_path` $1="$ac_define_path" AC_SUBST($1) ifelse($3, , AC_DEFINE_UNQUOTED($1, "$ac_define_path"), AC_DEFINE_UNQUOTED($1, "$ac_define_path", $3)) ]) IT_PROG_INTLTOOL([0.35.0]) GETTEXT_PACKAGE=indicator-printers AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [gettext package]) AC_DEFINE_PATH(GNOMELOCALEDIR, "${datadir}/locale", [locale directory]) AM_GLIB_GNU_GETTEXT AC_CONFIG_HEADER(config.h) AC_CONFIG_FILES([ Makefile src/Makefile data/Makefile test/Makefile po/Makefile.in ]) PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= 3.0 indicator3-0.4 >= 0.2 dbusmenu-gtk3-0.4 >= 0.2) PKG_CHECK_MODULES(SERVICE, gtk+-3.0 >= 3.0 indicator3-0.4 >= 0.2 dbusmenu-glib-0.4 >= 0.2) AC_PATH_PROG(CUPS_CONFIG, cups-config, no) if test "x$CUPS_CONFIG" = "xno"; then AC_MSG_ERROR([could not find cups-config]) fi AC_CHECK_HEADER(cups/cups.h,,AC_MSG_ERROR([could not find cups.h])) CUPS_CFLAGS+=`$CUPS_CONFIG --cflags` CUPS_LIBS+=`$CUPS_CONFIG --libs` SERVICE_CFLAGS="$SERVICE_CFLAGS $CUPS_CFLAGS" SERVICE_LIBS="$SERVICE_LIBS $CUPS_LIBS" SYSTEMD_USERDIR=`$PKG_CONFIG --variable=systemduserunitdir systemd` AC_SUBST(SYSTEMD_USERDIR) with_localinstall="no" AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all files locally (for distcheck)]), with_localinstall=$enableval, with_localinstall=no) if test "x$with_localinstall" = "xyes"; then INDICATORDIR="${libdir}/indicators/2/" INDICATORICONSDIR="${datadir}/libindicate/icons/" else INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3-0.4` INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3-0.4` fi AC_SUBST(INDICATORDIR) AC_SUBST(INDICATORICONSDIR) ########################### # DBus Service Info ########################### if test "x$with_localinstall" = "xyes"; then DBUSSERVICEDIR="${datadir}/dbus-1/services/" else DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1` fi AC_SUBST(DBUSSERVICEDIR) ########################### # gcov coverage reporting ########################### m4_include([m4/gcov.m4]) AC_TDD_GCOV AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes]) AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes]) AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_LDFLAGS) AC_SUBST(AM_CFLAGS, "-Wall") AC_OUTPUT