aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-03-20 18:50:29 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-03-20 18:50:29 +0100
commit776d81c41f08617a1d48f5d26f6f1d670c2296b2 (patch)
treeef9532ac2406092877914be0a9d13fc7f8f381bc /src
parent3cbf4224a6aa1c494838c32131c0a7cab49d750a (diff)
parentb36c109193793f388f52b1c557a2016e6599287f (diff)
downloadayatana-indicator-printers-776d81c41f08617a1d48f5d26f6f1d670c2296b2.tar.gz
ayatana-indicator-printers-776d81c41f08617a1d48f5d26f6f1d670c2296b2.tar.bz2
ayatana-indicator-printers-776d81c41f08617a1d48f5d26f6f1d670c2296b2.zip
* New upstream release.
- translate accessible description (LP: #957522) - set lease durations on cups subscriptions (LP: #959195) - draw number of jobs as lozenge
Diffstat (limited to 'src')
-rw-r--r--src/indicator-printers-service.c47
-rw-r--r--src/indicator-printers.c5
2 files changed, 50 insertions, 2 deletions
diff --git a/src/indicator-printers-service.c b/src/indicator-printers-service.c
index 5daf697..ad5ef88 100644
--- a/src/indicator-printers-service.c
+++ b/src/indicator-printers-service.c
@@ -26,6 +26,8 @@
#include "indicator-printers-menu.h"
#include "indicator-printer-state-notifier.h"
+#define NOTIFY_LEASE_DURATION (15 * 60)
+
static int
create_subscription ()
@@ -43,7 +45,7 @@ create_subscription ()
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);
+ "notify-lease-duration", NOTIFY_LEASE_DURATION);
resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/");
if (!resp || cupsLastError() != IPP_OK) {
@@ -64,6 +66,46 @@ create_subscription ()
}
+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)
{
@@ -115,6 +157,9 @@ int main (int argc, char *argv[])
gtk_init (&argc, &argv);
subscription_id = create_subscription ();
+ g_timeout_add_seconds (NOTIFY_LEASE_DURATION - 60,
+ renew_subscription_timeout,
+ &subscription_id);
service = indicator_service_new_version (INDICATOR_PRINTERS_DBUS_NAME,
INDICATOR_PRINTERS_DBUS_VERSION);
diff --git a/src/indicator-printers.c b/src/indicator-printers.c
index 78f36da..7acfdce 100644
--- a/src/indicator-printers.c
+++ b/src/indicator-printers.c
@@ -22,7 +22,7 @@
#include "indicator-menu-item.h"
#include "dbus-names.h"
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <libindicator/indicator.h>
@@ -175,6 +175,9 @@ indicator_prop_change_cb (DbusmenuMenuitem *mi,
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));
}