From b18f3f865cb641a07b429543b2bb98305f6308aa Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 17:25:33 +0100 Subject: Prepare for i18n --- Makefile.am | 2 +- configure.ac | 7 +++++++ po/POTFILES.in | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 po/POTFILES.in diff --git a/Makefile.am b/Makefile.am index 753bde1..2c4f34b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = src data test +SUBDIRS = src data test po diff --git a/configure.ac b/configure.ac index d19933a..3e4b909 100644 --- a/configure.ac +++ b/configure.ac @@ -10,12 +10,19 @@ AC_PROG_LIBTOOL AM_PROG_CC_C_O AM_SILENT_RULES([yes]) +IT_PROG_INTLTOOL([0.35.0]) +GETTEXT_PACKAGE=indicator-printers +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [gettext package]) +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 diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..f865141 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,6 @@ +[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 -- cgit v1.2.3 From da8f22976088f5272d72dc0383bb36b2f88a1f9c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 17:36:05 +0100 Subject: Mark strings translatable --- src/indicator-printer-state-notifier.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/indicator-printer-state-notifier.c b/src/indicator-printer-state-notifier.c index d3668a2..8261274 100644 --- a/src/indicator-printer-state-notifier.c +++ b/src/indicator-printer-state-notifier.c @@ -18,6 +18,7 @@ #include "indicator-printer-state-notifier.h" +#include #include #include #include @@ -125,13 +126,13 @@ show_alert_box (const gchar *printer, primary_text = g_strdup_printf (reason, printer); if (njobs == 1) - fmt = "You have %d job queued to print on this printer."; + fmt = _("You have %d job queued to print on this printer."); else - fmt = "You have %d jobs queued to print on this printer."; + fmt = _("You have %d jobs queued to print on this printer."); secondary_text = g_strdup_printf (fmt, njobs); dialog = g_object_new (GTK_TYPE_MESSAGE_DIALOG, - "title", "Printing Problem", + "title", _("Printing Problem"), "icon-name", "printer", "image", image, "text", primary_text, @@ -147,7 +148,7 @@ show_alert_box (const gchar *printer, g_free (secondary_text); gtk_dialog_add_buttons (GTK_DIALOG (dialog), - "_Settings…", RESPONSE_SHOW_SYSTEM_SETTINGS, + _("_Settings…"), RESPONSE_SHOW_SYSTEM_SETTINGS, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), @@ -313,14 +314,14 @@ indicator_printer_state_notifier_init (IndicatorPrinterStateNotifier *self) 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.", + "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); } -- cgit v1.2.3 From e76730160da068ce4a358297ac171f0dd656f69c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 18:33:05 +0100 Subject: Make sure CUPS' dbus notification is on while the service is running --- src/indicator-printers-service.c | 73 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/src/indicator-printers-service.c b/src/indicator-printers-service.c index 58644ab..5daf697 100644 --- a/src/indicator-printers-service.c +++ b/src/indicator-printers-service.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "dbus-names.h" #include "cups-notifier.h" @@ -26,10 +27,77 @@ #include "indicator-printer-state-notifier.h" +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", 0); + + 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 = attr->values[0].integer; + else + g_warning ("ipp-create-printer-subscription response doesn't contain " + "subscription id.\n"); + + ippDelete (resp); + return id; +} + + +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 service_shutdown (IndicatorService *service, gpointer user_data) { + int subscription_id = GPOINTER_TO_INT (user_data); + g_debug("Shutting down indicator-printers-service"); + + cancel_subscription (subscription_id); gtk_main_quit (); } @@ -42,15 +110,18 @@ int main (int argc, char *argv[]) IndicatorPrintersMenu *menu; IndicatorPrinterStateNotifier *state_notifier; GError *error = NULL; + int subscription_id; gtk_init (&argc, &argv); + subscription_id = create_subscription (); + service = indicator_service_new_version (INDICATOR_PRINTERS_DBUS_NAME, INDICATOR_PRINTERS_DBUS_VERSION); g_signal_connect (service, "shutdown", G_CALLBACK (service_shutdown), - NULL); + GINT_TO_POINTER (subscription_id)); cups_notifier = cups_notifier_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, 0, -- cgit v1.2.3 From 5f29b2a3e4b1744596defea708a7f717d737be53 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 19:28:10 +0100 Subject: Also generate cups-notifier in the text directory --- src/Makefile.am | 2 +- test/Makefile.am | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index bedc091..2c87ad0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,7 +17,7 @@ cups_notifier_sources = \ cups-notifier.c \ cups-notifier.h -$(cups_notifier_sources): $(top_srcdir)/src/org.cups.cupsd.Notifier.xml +$(cups_notifier_sources): org.cups.cupsd.Notifier.xml gdbus-codegen \ --interface-prefix org.cups.cupsd \ --c-namespace Cups \ diff --git a/test/Makefile.am b/test/Makefile.am index d3e10bb..4b0439d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,10 +2,20 @@ 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 \ - $(top_builddir)/src/cups-notifier.c \ - $(top_builddir)/src/cups-notifier.h + $(cups_notifier_sources) mock_cups_notifier_CPPFLAGS = \ $(SERVICE_CFLAGS) \ @@ -13,3 +23,5 @@ mock_cups_notifier_CPPFLAGS = \ mock_cups_notifier_LDADD = $(SERVICE_LIBS) +BUILT_SOURCES = $(cups_notifier_sources) + -- cgit v1.2.3 From 5b0b1ba9bc75e2a3a653c78889d67c705f617849 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 19:45:24 +0100 Subject: Don't distribute generated sources and delete them on `make clean` --- src/Makefile.am | 6 ++++-- test/Makefile.am | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2c87ad0..6e10cb9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,13 +34,15 @@ indicator_printers_service_SOURCES = \ indicator-printer-state-notifier.h \ spawn-printer-settings.c \ spawn-printer-settings.h \ - dbus-names.h \ - $(cups_notifier_sources) + dbus-names.h + +nodist_indicator_printers_service_SOURCES = $(cups_notifier_sources) indicator_printers_service_CPPFLAGS = $(SERVICE_CFLAGS) indicator_printers_service_LDADD = $(SERVICE_LIBS) BUILT_SOURCES = $(cups_notifier_sources) +CLEANFILES= $(BUILT_SOURCES) EXTRA_DIST = org.cups.cupsd.Notifier.xml diff --git a/test/Makefile.am b/test/Makefile.am index 4b0439d..4084cba 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -14,8 +14,9 @@ $(cups_notifier_sources): $(top_srcdir)/src/org.cups.cupsd.Notifier.xml $^ mock_cups_notifier_SOURCES = \ - mock-cups-notifier.c \ - $(cups_notifier_sources) + mock-cups-notifier.c + +nodist_mock_cups_notifier_SOURCES = $(cups_notifier_sources) mock_cups_notifier_CPPFLAGS = \ $(SERVICE_CFLAGS) \ @@ -24,4 +25,5 @@ mock_cups_notifier_CPPFLAGS = \ mock_cups_notifier_LDADD = $(SERVICE_LIBS) BUILT_SOURCES = $(cups_notifier_sources) +CLEANFILES = $(BUILT_SOURCES) -- cgit v1.2.3 From eab1b7ac49dbead52eb471ad8370bdf39d09bb39 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 19:54:07 +0100 Subject: Add --enable-localinstall to make `make distcheck` work (lifted from indicator-messages) --- Makefile.am | 1 + configure.ac | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2c4f34b..f90feae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ SUBDIRS = src data test po +DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index 3e4b909..7c1c44c 100644 --- a/configure.ac +++ b/configure.ac @@ -40,15 +40,35 @@ AC_CHECK_HEADER(cups/cups.h,,AC_MSG_ERROR([could not find cups.h])) SERVICE_CFLAGS+=`$CUPS_CONFIG --cflags` SERVICE_LIBS+=`$CUPS_CONFIG --libs` -INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3-0.4` -INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3-0.4` -DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1` +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(INDICATORICONDIR) +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) + AC_SUBST(AM_CFLAGS, "-Wall") AC_OUTPUT -- cgit v1.2.3 From 9a0e424593438088458b6b207bb1e53f48673fea Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 16 Feb 2012 20:53:23 +0100 Subject: 0.1.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7c1c44c..a5b0c54 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT(indicator-printers, 0.1) +AC_INIT(indicator-printers, 0.1.1) AC_PREREQ(2.53) AM_INIT_AUTOMAKE([]) -- cgit v1.2.3