diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-02-12 14:11:27 +0100 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-02-12 14:11:27 +0100 |
commit | c3b56f70cd7305b1ddcc052cea808afb7b987856 (patch) | |
tree | 64754406304d4d766be6a6ba087bb85bfc1756fa /src/indicator-printers-menu.c | |
parent | a796e6d7df042dacb147dbf4dc31df1909f0cc41 (diff) | |
download | ayatana-indicator-printers-c3b56f70cd7305b1ddcc052cea808afb7b987856.tar.gz ayatana-indicator-printers-c3b56f70cd7305b1ddcc052cea808afb7b987856.tar.bz2 ayatana-indicator-printers-c3b56f70cd7305b1ddcc052cea808afb7b987856.zip |
Only show print indicator when there are print jobs
Note: this doesn't fully implement the design spec yet, as the menu should stay
visible 5 seconds after the last print job finished.
Diffstat (limited to 'src/indicator-printers-menu.c')
-rw-r--r-- | src/indicator-printers-menu.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/indicator-printers-menu.c b/src/indicator-printers-menu.c index 58bd72a..bc98cf3 100644 --- a/src/indicator-printers-menu.c +++ b/src/indicator-printers-menu.c @@ -138,6 +138,25 @@ on_printer_item_activated (DbusmenuMenuitem *menuitem, 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) @@ -171,9 +190,13 @@ update_printer_menuitem (IndicatorPrintersMenu *self, 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) { @@ -241,6 +264,7 @@ indicator_printers_menu_init (IndicatorPrintersMenu *self) 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, |