diff options
author | Ted Gould <ted@gould.cx> | 2010-02-18 09:46:44 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-18 09:46:44 -0600 |
commit | 18e23b393832c3c1b9147be8443f0d92773d8065 (patch) | |
tree | 5e3fa53bddc01260449f9522212d110bde77fc7e | |
parent | 414afb961106144fa9339550e8654c59c1e734a0 (diff) | |
parent | e07cdb88407dc186d7cdb236e410b6ae9c4fc3f8 (diff) | |
download | ayatana-indicator-session-18e23b393832c3c1b9147be8443f0d92773d8065.tar.gz ayatana-indicator-session-18e23b393832c3c1b9147be8443f0d92773d8065.tar.bz2 ayatana-indicator-session-18e23b393832c3c1b9147be8443f0d92773d8065.zip |
* Upstream release 0.2.3
* Switch menu ordering to match design spec
* Change switch menu item to "Switch from..."
* Move from Devkit-Power to upower
* Adding in user logged in icon and menu item
23 files changed, 542 insertions, 62 deletions
diff --git a/Makefile.am b/Makefile.am index 0233fbf..3d97874 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = \ data \ po -EXTRA_DIST = COPYING.LGPL +EXTRA_DIST = COPYING.LGPL autogen.sh DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index 1b4ecfa..221da2c 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.2.2) +AM_INIT_AUTOMAKE(indicator-session, 0.2.3) AM_MAINTAINER_MODE @@ -132,14 +132,19 @@ data/Makefile data/icons/Makefile data/icons/16x16/Makefile data/icons/16x16/actions/Makefile +data/icons/16x16/status/Makefile data/icons/22x22/Makefile data/icons/22x22/actions/Makefile +data/icons/22x22/status/Makefile data/icons/24x24/Makefile data/icons/24x24/actions/Makefile +data/icons/24x24/status/Makefile data/icons/32x32/Makefile data/icons/32x32/actions/Makefile +data/icons/32x32/status/Makefile data/icons/scalable/Makefile data/icons/scalable/actions/Makefile +data/icons/scalable/status/Makefile po/Makefile.in ]) diff --git a/data/icons/16x16/Makefile.am b/data/icons/16x16/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/16x16/Makefile.am +++ b/data/icons/16x16/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am new file mode 100644 index 0000000..c0af60e --- /dev/null +++ b/data/icons/16x16/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/16x16/status/account-logged-in.png b/data/icons/16x16/status/account-logged-in.png Binary files differnew file mode 100644 index 0000000..fb4362c --- /dev/null +++ b/data/icons/16x16/status/account-logged-in.png diff --git a/data/icons/22x22/Makefile.am b/data/icons/22x22/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/22x22/Makefile.am +++ b/data/icons/22x22/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/22x22/status/Makefile.am b/data/icons/22x22/status/Makefile.am new file mode 100644 index 0000000..1ce0fa1 --- /dev/null +++ b/data/icons/22x22/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/22x22/status/account-logged-in.png b/data/icons/22x22/status/account-logged-in.png Binary files differnew file mode 100644 index 0000000..e27d75f --- /dev/null +++ b/data/icons/22x22/status/account-logged-in.png diff --git a/data/icons/24x24/Makefile.am b/data/icons/24x24/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/24x24/Makefile.am +++ b/data/icons/24x24/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am new file mode 100644 index 0000000..4fa065a --- /dev/null +++ b/data/icons/24x24/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/24x24/status/account-logged-in.png b/data/icons/24x24/status/account-logged-in.png Binary files differnew file mode 100644 index 0000000..db4f548 --- /dev/null +++ b/data/icons/24x24/status/account-logged-in.png diff --git a/data/icons/32x32/Makefile.am b/data/icons/32x32/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/32x32/Makefile.am +++ b/data/icons/32x32/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/32x32/status/Makefile.am b/data/icons/32x32/status/Makefile.am new file mode 100644 index 0000000..b852725 --- /dev/null +++ b/data/icons/32x32/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/32x32/status/account-logged-in.png b/data/icons/32x32/status/account-logged-in.png Binary files differnew file mode 100644 index 0000000..05bff57 --- /dev/null +++ b/data/icons/32x32/status/account-logged-in.png diff --git a/data/icons/scalable/Makefile.am b/data/icons/scalable/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/scalable/Makefile.am +++ b/data/icons/scalable/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/scalable/status/Makefile.am b/data/icons/scalable/status/Makefile.am new file mode 100644 index 0000000..cb006e2 --- /dev/null +++ b/data/icons/scalable/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/status + +icons_DATA = \ + account-logged-in.svg + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/scalable/status/account-logged-in.svg b/data/icons/scalable/status/account-logged-in.svg new file mode 100644 index 0000000..c3ef44f --- /dev/null +++ b/data/icons/scalable/status/account-logged-in.svg @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg1" + sodipodi:version="0.32" + inkscape:version="0.45" + width="48" + height="48" + sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/emblems" + sodipodi:docname="emblem-default.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + version="1.0"> + <defs + id="defs3"> + <linearGradient + id="linearGradient5237"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop5239" /> + <stop + id="stop5247" + offset="0.5" + style="stop-color:#ffffff;stop-opacity:1;" /> + <stop + style="stop-color:#9c9c9c;stop-opacity:1" + offset="1" + id="stop5241" /> + </linearGradient> + <linearGradient + id="linearGradient5226"> + <stop + style="stop-color:#63b512;stop-opacity:1;" + offset="0" + id="stop5229" /> + <stop + id="stop5245" + offset="0.16030352" + style="stop-color:#58a30e;stop-opacity:1;" /> + <stop + id="stop5235" + offset="0.66008514" + style="stop-color:#366b04;stop-opacity:1" /> + <stop + style="stop-color:#87ea25;stop-opacity:1" + offset="1" + id="stop5231" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + id="linearGradient5300"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop5302" /> + <stop + style="stop-color:#ffffff;stop-opacity:0;" + offset="1" + id="stop5304" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + id="linearGradient5224"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop5226" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop5228" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5224" + id="radialGradient5230" + cx="14.5" + cy="26.6875" + fx="14.5" + fy="26.6875" + r="10" + gradientTransform="matrix(1,0,0,0.29375,0,18.848047)" + gradientUnits="userSpaceOnUse" /> + <filter + inkscape:collect="always" + id="filter5296" + x="-0.09814655" + width="1.1962931" + y="-0.33411592" + height="1.6682318"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.81788793" + id="feGaussianBlur5298" /> + </filter> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5300" + id="radialGradient5306" + cx="29.77438" + cy="7.0922189" + fx="29.77438" + fy="7.0922189" + r="25.380436" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(2.2469896,0,0,2.2469896,-37.128341,-8.8439229)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5224" + id="radialGradient5330" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1,0,0,0.29375,0,18.848047)" + cx="14.5" + cy="26.6875" + fx="14.5" + fy="26.6875" + r="10" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5226" + id="radialGradient5233" + cx="29.392656" + cy="18.898249" + fx="29.392656" + fy="18.898249" + r="29.699959" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5354369,0,0,1.5485894,-15.737913,-10.36738)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5237" + id="radialGradient5243" + cx="22.9375" + cy="16.305218" + fx="22.9375" + fy="16.305218" + r="15.5625" + gradientTransform="matrix(1.5301205,0,0,1.6745294,-12.159639,-11.709817)" + gradientUnits="userSpaceOnUse" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#ededed" + borderopacity="1" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1" + inkscape:cx="39.269655" + inkscape:cy="17.441445" + inkscape:window-width="826" + inkscape:window-height="790" + gridspacingx="0.50000000mm" + gridspacingy="0.50000000mm" + showgrid="false" + inkscape:grid-bbox="false" + inkscape:window-x="461" + inkscape:window-y="278" + inkscape:current-layer="svg1" + borderlayer="true" + inkscape:showpageshadow="false" + width="744.09449px" + height="1052.3622px"> + <inkscape:grid + type="xygrid" + id="grid5308" /> + </sodipodi:namedview> + <metadata + id="metadata4"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Emblem Urgent</dc:title> + <dc:creator> + <cc:Agent> + <dc:title>Jakub Steiner</dc:title> + </cc:Agent> + </dc:creator> + <dc:contributor> + <cc:Agent> + <dc:title>Andreas Nilsson</dc:title> + </cc:Agent> + </dc:contributor> + <cc:license + rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" /> + <dc:subject> + <rdf:Bag> + <rdf:li>generic</rdf:li> + </rdf:Bag> + </dc:subject> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/GPL/2.0/"> + <cc:permits + rdf:resource="http://web.resource.org/cc/Reproduction" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/Distribution" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/Notice" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/ShareAlike" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/SourceCode" /> + </cc:License> + </rdf:RDF> + </metadata> + <path + sodipodi:type="arc" + style="opacity:0.53012048;color:#000000;fill:url(#radialGradient5230);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;filter:url(#filter5296);enable-background:accumulate" + id="path4645" + sodipodi:cx="14.5" + sodipodi:cy="26.6875" + sodipodi:rx="10" + sodipodi:ry="2.9375" + d="M 24.5,26.6875 A 10,2.9375 0 1 1 4.5,26.6875 A 10,2.9375 0 1 1 24.5,26.6875 z" + transform="matrix(2.1570145,0,0,2.155398,-7.8468552,-16.33814)" /> + <path + transform="matrix(1.3478975,0,0,1.3468874,3.8853414,6.4889877)" + d="M 24.5,26.6875 A 10,2.9375 0 1 1 4.5,26.6875 A 10,2.9375 0 1 1 24.5,26.6875 z" + sodipodi:ry="2.9375" + sodipodi:rx="10" + sodipodi:cy="26.6875" + sodipodi:cx="14.5" + id="path5328" + style="opacity:0.80120482;color:#000000;fill:url(#radialGradient5330);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;filter:url(#filter5296);enable-background:accumulate" + sodipodi:type="arc" /> + <path + sodipodi:type="arc" + style="fill:url(#radialGradient5233);fill-opacity:1;fill-rule:evenodd;stroke:#316203;stroke-width:1.37804781999999992;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path907" + sodipodi:cx="29.392656" + sodipodi:cy="29.207693" + sodipodi:rx="29.010935" + sodipodi:ry="29.010935" + d="M 58.403591,29.207693 A 29.010935,29.010935 0 1 1 0.3817215,29.207693 A 29.010935,29.010935 0 1 1 58.403591,29.207693 z" + transform="matrix(0.7238447,0,0,0.7274883,2.1828126,2.3568607)" /> + <path + sodipodi:type="arc" + style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#radialGradient5306);stroke-width:1.21160841;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path1552" + sodipodi:cx="29.77438" + sodipodi:cy="30.352861" + sodipodi:rx="24.175779" + sodipodi:ry="24.175779" + d="M 53.950159,30.352861 A 24.175779,24.175779 0 1 1 5.5986004,30.352861 A 24.175779,24.175779 0 1 1 53.950159,30.352861 z" + transform="matrix(0.8254302,0,0,0.8252681,-1.1457884,-1.4441229)" /> + <path + style="opacity:1;color:#000000;fill:url(#radialGradient5243);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 12.875,24.625 L 25.375,36.625 L 44,20.625 C 43.253602,16.729371 41.57038,13.679873 39.8125,11.0625 L 25.125,23.75 L 20.375,18.5 L 12.875,24.625 z" + id="path5222" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;color:#000000;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#549910;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 40.21875,10.8125 C 41.930961,13.346411 43.59334,15.979986 44.40625,20.3125" + id="path5224" + sodipodi:nodetypes="cc" /> +</svg> diff --git a/debian/changelog b/debian/changelog index f28b6c5..739b729 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +indicator-session (0.2.3-0ubuntu1~ppa1) UNRELEASED; urgency=low + + * Upstream release 0.2.3 + * Switch menu ordering to match design spec + * Change switch menu item to "Switch from..." + * Move from Devkit-Power to upower + * Adding in user logged in icon and menu item + + -- Ted Gould <ted@ubuntu.com> Thu, 18 Feb 2010 09:42:50 -0600 + indicator-session (0.2.2-0ubuntu2) lucid; urgency=low * debian/control: Update devicekit-power dependency to upower. diff --git a/src/Makefile.am b/src/Makefile.am index 2c607f5..fdbf466 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ sessionlib_LTLIBRARIES = libsession.la libsession_la_SOURCES = \ indicator-session.c \ dbus-shared-names.h \ + dbusmenu-shared.h \ users-service-client.h libsession_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror libsession_la_LIBADD = $(APPLET_LIBS) @@ -42,6 +43,7 @@ indicator_session_service_SOURCES = \ lock-helper.c \ lock-helper.h \ session-service.c \ + dbusmenu-shared.h \ gtk-dialog/gconf-helper.c \ users-service-dbus.h \ users-service-dbus.c \ diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 1fd256f..253cba8 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -38,4 +38,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session/menu" #define INDICATOR_SESSION_DBUS_VERSION 0 +#define USER_ITEM_TYPE "x-canonical-user-item" +#define USER_ITEM_PROP_NAME "user-item-name" +#define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" + #endif /* __DBUS_SHARED_NAMES_H__ */ diff --git a/src/dbusmenu-shared.h b/src/dbusmenu-shared.h new file mode 100644 index 0000000..1ef179b --- /dev/null +++ b/src/dbusmenu-shared.h @@ -0,0 +1,4 @@ + +#define MENU_SWITCH_TYPE "x-canonical-switch-from" +#define MENU_SWITCH_USER "x-canonical-switch-username" + diff --git a/src/indicator-session.c b/src/indicator-session.c index dda8c76..a97eb95 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -22,6 +22,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <glib-object.h> +#include <glib/gi18n.h> #include <gtk/gtk.h> #include <libdbusmenu-gtk/menu.h> @@ -33,6 +34,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-service-manager.h> #include "dbus-shared-names.h" +#include "dbusmenu-shared.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -51,6 +53,8 @@ struct _IndicatorSessionClass { struct _IndicatorSession { IndicatorObject parent; IndicatorServiceManager * service; + GtkImage * status_image; + DbusmenuGtkMenu * menu; }; GType indicator_session_get_type (void); @@ -63,6 +67,8 @@ INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); +static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -96,6 +102,13 @@ indicator_session_init (IndicatorSession *self) /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); + self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); + self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); + + DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); + dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); + dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + return; } @@ -130,9 +143,37 @@ get_label (IndicatorObject * io) static GtkImage * get_icon (IndicatorObject * io) { - GtkImage * status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); - gtk_widget_show(GTK_WIDGET(status_image)); - return status_image; + gtk_widget_show(GTK_WIDGET(INDICATOR_SESSION(io)->status_image)); + return INDICATOR_SESSION(io)->status_image; +} + +/* Builds an item with a hip little logged in icon. */ +static gboolean +new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + + GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME)); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + gtk_widget_show(label); + + GtkWidget * icon = gtk_image_new_from_icon_name("account-logged-in", GTK_ICON_SIZE_MENU); + gtk_misc_set_alignment(GTK_MISC(icon), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); + if (dbusmenu_menuitem_property_get_bool(newitem, USER_ITEM_PROP_LOGGED_IN)) { + gtk_widget_show(icon); + } else { + gtk_widget_hide(icon); + } + + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + return TRUE; } /* Indicator based function to get the menu for the whole @@ -141,7 +182,106 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + return GTK_MENU(INDICATOR_SESSION(io)->menu); } +static void +switch_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { + return; + } + + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); + gchar * finalstring = NULL; + gboolean set_ellipsize = FALSE; + + /* If there's a NULL string of some type, then we want to + go back to our old 'Switch User' which isn't great but + eh, this error condition should never happen. */ + if (value == NULL || g_value_get_string(value) == NULL || g_value_get_string(value)[0] == '\0') { + finalstring = _("Switch User..."); + set_ellipsize = FALSE; + } + + if (finalstring == NULL) { + const gchar * username = g_value_get_string(value); + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); + + PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); + pango_layout_set_text(layout, username, -1); + pango_layout_set_font_description(layout, style->font_desc); + + gint width; + pango_layout_get_pixel_size(layout, &width, NULL); + g_debug("Username width %dpx", width); + + gint point = pango_font_description_get_size(style->font_desc); + g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); + + gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); + g_debug("Screen DPI %f", dpi); + + gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; + gdouble ems = width / pixels_per_em; + g_debug("Username width %fem", ems); + + /* TODO: We need some way to remove the elipsis from appearing + twice in the label. Not sure how to do that yet. */ + finalstring = g_strdup_printf(_("Switch from %s..."), username); + if (ems >= 20.0f) { + set_ellipsize = TRUE; + } else { + set_ellipsize = FALSE; + } + } + gtk_menu_item_set_label(gmi, finalstring); + + GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); + if (label != NULL) { + if (set_ellipsize) { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + } else { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); + } + } + + return; +} + +static const gchar * dbusmenu_item_data = "dbusmenu-item"; + +/* Callback for when the style changes so we can reevaluate the + size of the user name with the potentially new font. */ +static void +switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) +{ + DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), dbusmenu_item_data)); + + switch_property_change(mi, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(mi, MENU_SWITCH_USER), client); + return; +} + + +/* This function checks to see if the user name is short enough + to not need ellipsing itself, or if, it will get ellipsed by + the standard label processor. */ +static gboolean +build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + if (gmi == NULL) { + return FALSE; + } + g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(switch_property_change), client); + g_signal_connect(G_OBJECT(gmi), "style-set", G_CALLBACK(switch_style_set), client); + switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(newitem, MENU_SWITCH_USER), client); + + return TRUE; +} diff --git a/src/session-service.c b/src/session-service.c index e89a9a0..9fb9ee7 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -38,15 +38,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-service.h> #include "dbus-shared-names.h" +#include "dbusmenu-shared.h" #include "gtk-dialog/gconf-helper.h" #include "users-service-dbus.h" #include "lock-helper.h" -#define DKP_ADDRESS "org.freedesktop.DeviceKit.Power" -#define DKP_OBJECT "/org/freedesktop/DeviceKit/Power" -#define DKP_INTERFACE "org.freedesktop.DeviceKit.Power" +#define UP_ADDRESS "org.freedesktop.UPower" +#define UP_OBJECT "/org/freedesktop/UPower" +#define UP_INTERFACE "org.freedesktop.UPower" #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" @@ -72,8 +73,8 @@ static GList *users; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; -static DBusGProxy * dkp_main_proxy = NULL; -static DBusGProxy * dkp_prop_proxy = NULL; +static DBusGProxy * up_main_proxy = NULL; +static DBusGProxy * up_prop_proxy = NULL; static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -147,14 +148,14 @@ machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { gchar * type = (gchar *)userdata; - if (dkp_main_proxy == NULL) { - g_warning("Can not %s as no DeviceKit Power Proxy", type); + if (up_main_proxy == NULL) { + g_warning("Can not %s as no upower proxy", type); } screensaver_throttle(type); lock_screen(NULL, 0, NULL); - dbus_g_proxy_begin_call(dkp_main_proxy, + dbus_g_proxy_begin_call(up_main_proxy, type, sleep_response, NULL, @@ -213,17 +214,17 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) /* A signal that we need to recheck to ensure we can still hibernate and/or suspend */ static void -dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) +up_changed_cb (DBusGProxy * proxy, gpointer user_data) { /* Start Async call to see if we can hibernate */ if (suspend_call == NULL) { - suspend_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", suspend_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-suspend", G_TYPE_INVALID, @@ -233,13 +234,13 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) /* Start Async call to see if we can suspend */ if (hibernate_call == NULL) { - hibernate_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", hibernate_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-hibernate", G_TYPE_INVALID, @@ -254,39 +255,39 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) DKp checking. We're even setting up the calls for the props we need */ static void -setup_dkp (void) { +setup_up (void) { DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); g_return_if_fail(bus != NULL); - if (dkp_main_proxy == NULL) { - dkp_main_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, - DKP_INTERFACE); + if (up_main_proxy == NULL) { + up_main_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, + UP_INTERFACE); } - g_return_if_fail(dkp_main_proxy != NULL); + g_return_if_fail(up_main_proxy != NULL); - if (dkp_prop_proxy == NULL) { - dkp_prop_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, + if (up_prop_proxy == NULL) { + up_prop_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, DBUS_INTERFACE_PROPERTIES); } - g_return_if_fail(dkp_prop_proxy != NULL); + g_return_if_fail(up_prop_proxy != NULL); /* Connect to changed signal */ - dbus_g_proxy_add_signal(dkp_main_proxy, + dbus_g_proxy_add_signal(up_main_proxy, "Changed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal(dkp_main_proxy, + dbus_g_proxy_connect_signal(up_main_proxy, "Changed", - G_CALLBACK(dpk_changed_cb), + G_CALLBACK(up_changed_cb), NULL, NULL); /* Force an original "changed" event */ - dpk_changed_cb(dkp_main_proxy, NULL); + up_changed_cb(up_main_proxy, NULL); return; } @@ -437,14 +438,40 @@ rebuild_items (DbusmenuMenuitem *root, if (can_activate == TRUE) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator1); + if (check_guest_session ()) { mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Guest Session")); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, _("Guest Session")); + dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, FALSE); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); } + if (check_new_session ()) + { + ensure_gconf_client (); + + switch_menuitem = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); + dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); + dbusmenu_menuitem_child_append (root, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); + + if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } + else + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + if (count > MINIMUM_USERS && count < MAXIMUM_USERS) { if (users != NULL) @@ -470,30 +497,13 @@ rebuild_items (DbusmenuMenuitem *root, user->service = service; mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); + dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); } } - - if (check_new_session ()) - { - ensure_gconf_client (); - - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User...")); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } } DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); @@ -639,7 +649,7 @@ main (int argc, char ** argv) G_CALLBACK (user_removed), root_menuitem); - setup_dkp(); + setup_up(); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, root_menuitem); |