Merge lp:~dbarth/indicator-me/with-about-me into lp:indicator-me

Proposed by David Barth
Status: Merged
Merge reported by: David Barth
Merged at revision: not available
Proposed branch: lp:~dbarth/indicator-me/with-about-me
Merge into: lp:indicator-me
Diff against target: 685 lines (+440/-69)
7 files modified
src/Makefile.am (+2/-0)
src/about-me-menu-item.c (+267/-0)
src/about-me-menu-item.h (+65/-0)
src/dbus-shared-names.h (+5/-2)
src/entry-menu-item.c (+1/-1)
src/indicator-me.c (+53/-31)
src/me-service.c (+47/-35)
To merge this branch: bzr merge lp:~dbarth/indicator-me/with-about-me
Reviewer Review Type Date Requested Status
Cody Russell (community) Needs Fixing
Review via email: mp+19554@code.launchpad.net
To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

Adds the "me item" at the top of the menu. See https://wiki.ubuntu.com/MeMenu#Me item

Doesn't support line wrapping or taking the user avatar yet.

Revision history for this message
David Barth (dbarth) wrote :

The branch implements the proper layout for the entry, tests if gnome-about-me is installed or not, and makes the entry sensitive accordingly, calling the program on activation.

Revision history for this message
Cody Russell (bratsche) wrote :

In get_pixels_per_em(), the g_return_val_if_fail() parameters are reversed, so this needs to be fixed.

Small thing.. but in about_me_menu_item_class_init(), don't create a GtkObjectClass variable. You can do g_type_class_add_private() using gobject_class.

And lastly, is there any chance at all I could convince you to have your text editor use spaces for indenting instead of tabs? The indentation looks really weird in the merge request and also in my emacs. :)

review: Needs Fixing
79. By David Barth

re-indent files properly

80. By David Barth

do g_return_val_if_fail in the right order; don't create a useless GtkObjectClass

Revision history for this message
David Barth (dbarth) wrote :

re-pushed up to revision 80 with the 2 fixes and some re-indentation of the main source files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Makefile.am'
2--- src/Makefile.am 2010-02-04 20:52:03 +0000
3+++ src/Makefile.am 2010-02-18 00:41:11 +0000
4@@ -8,6 +8,8 @@
5 melibdir = $(INDICATORDIR)
6 melib_LTLIBRARIES = libme.la
7 libme_la_SOURCES = \
8+ about-me-menu-item.c \
9+ about-me-menu-item.h \
10 indicator-me.c \
11 dbus-shared-names.h \
12 me-service-client.h
13
14=== added file 'src/about-me-menu-item.c'
15--- src/about-me-menu-item.c 1970-01-01 00:00:00 +0000
16+++ src/about-me-menu-item.c 2010-02-18 00:41:11 +0000
17@@ -0,0 +1,267 @@
18+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
19+/*
20+ * Copyright 2010 Canonical, Ltd.
21+ *
22+ * This program is free software: you can redistribute it and/or modify it
23+ * under the terms of either or both of the following licenses:
24+ *
25+ * 1) the GNU Lesser General Public License version 3, as published by the
26+ * Free Software Foundation; and/or
27+ * 2) the GNU Lesser General Public License version 2.1, as published by
28+ * the Free Software Foundation.
29+ *
30+ * This program is distributed in the hope that it will be useful, but
31+ * WITHOUT ANY WARRANTY; without even the implied warranties of
32+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
33+ * PURPOSE. See the applicable version of the GNU Lesser General Public
34+ * License for more details.
35+ *
36+ * You should have received a copy of both the GNU Lesser General Public
37+ * License version 3 and version 2.1 along with this program. If not, see
38+ * <http://www.gnu.org/licenses/>
39+ *
40+ * Authors:
41+ * David Barth <david.barth@canonical.com>
42+ * Cody Russell <crussell@canonical.com>
43+ */
44+
45+#include <gtk/gtk.h>
46+#include "about-me-menu-item.h"
47+
48+static GObject* about_me_menu_item_constructor (GType type,
49+ guint n_construct_properties,
50+ GObjectConstructParam *construct_params);
51+static void about_me_menu_item_set_property (GObject *object,
52+ guint prop_id,
53+ const GValue *value,
54+ GParamSpec *pspec);
55+static void about_me_menu_item_get_property (GObject *object,
56+ guint prop_id,
57+ GValue *value,
58+ GParamSpec *pspec);
59+
60+struct _AboutMeMenuItemPrivate {
61+ GtkWidget *label;
62+ GtkWidget *image;
63+ GtkWidget *hbox;
64+ gchar *realname;
65+};
66+
67+enum {
68+ PROP_0,
69+ PROP_REALNAME
70+};
71+
72+G_DEFINE_TYPE (AboutMeMenuItem, about_me_menu_item, GTK_TYPE_MENU_ITEM)
73+
74+#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemPrivate))
75+
76+static void
77+about_me_menu_item_class_init (AboutMeMenuItemClass *item_class)
78+{
79+ GObjectClass *gobject_class = G_OBJECT_CLASS (item_class);
80+
81+ gobject_class->constructor = about_me_menu_item_constructor;
82+ gobject_class->set_property = about_me_menu_item_set_property;
83+ gobject_class->get_property = about_me_menu_item_get_property;
84+
85+ g_object_class_install_property (gobject_class,
86+ PROP_REALNAME,
87+ g_param_spec_string ("realname",
88+ "Realname",
89+ "The \"Realname\" for the user",
90+ NULL,
91+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
92+
93+ g_type_class_add_private (gobject_class, sizeof (AboutMeMenuItemPrivate));
94+}
95+
96+static void
97+about_me_menu_item_init (AboutMeMenuItem *self)
98+{
99+ AboutMeMenuItemPrivate *priv = GET_PRIVATE (self);
100+
101+ priv->label = NULL;
102+ priv->image = NULL;
103+ priv->realname = NULL;
104+}
105+
106+static void
107+about_me_menu_item_set_property (GObject *object,
108+ guint prop_id,
109+ const GValue *value,
110+ GParamSpec *pspec)
111+{
112+ AboutMeMenuItem *menu_item = ABOUT_ME_MENU_ITEM (object);
113+ AboutMeMenuItemPrivate *priv = GET_PRIVATE (menu_item);
114+
115+ switch (prop_id)
116+ {
117+ case PROP_REALNAME:
118+ g_assert (priv->realname == NULL);
119+ priv->realname = g_strdup (g_value_get_string (value));
120+ break;
121+
122+ default:
123+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
124+ break;
125+ }
126+}
127+
128+static void
129+about_me_menu_item_get_property (GObject *object,
130+ guint prop_id,
131+ GValue *value,
132+ GParamSpec *pspec)
133+{
134+ AboutMeMenuItem *menu_item = ABOUT_ME_MENU_ITEM (object);
135+ AboutMeMenuItemPrivate *priv = GET_PRIVATE (menu_item);
136+
137+ switch (prop_id)
138+ {
139+ case PROP_REALNAME:
140+ g_value_set_string (value, priv->realname);
141+ break;
142+
143+ default:
144+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
145+ break;
146+ }
147+}
148+
149+#define DEFAULT_PIXELS_PER_EM 10.0f
150+
151+static gdouble
152+get_pixels_per_em (GtkWidget *widget)
153+{
154+ g_return_val_if_fail (GTK_IS_WIDGET (widget), DEFAULT_PIXELS_PER_EM);
155+
156+ /* Note: taken from indicator-session */
157+ GtkStyle * style = gtk_widget_get_style(widget);
158+
159+ PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(widget));
160+ pango_layout_set_text(layout, "M", -1);
161+ pango_layout_set_font_description(layout, style->font_desc);
162+
163+ gint width;
164+ pango_layout_get_pixel_size(layout, &width, NULL);
165+
166+ gint point = pango_font_description_get_size(style->font_desc);
167+ gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default());
168+
169+ return ((point * dpi) / 72.0f) / PANGO_SCALE;
170+}
171+
172+
173+/* from n-osd */
174+static GdkPixbuf*
175+load_icon (const gchar* filename,
176+ gint icon_size)
177+{
178+ GdkPixbuf* buffer = NULL;
179+ GdkPixbuf* pixbuf = NULL;
180+ GtkIconTheme* theme = NULL;
181+ GError* error = NULL;
182+
183+ /* sanity check */
184+ g_return_val_if_fail (filename, NULL);
185+
186+ theme = gtk_icon_theme_get_default ();
187+ buffer = gtk_icon_theme_load_icon (theme,
188+ filename,
189+ icon_size,
190+ GTK_ICON_LOOKUP_FORCE_SVG |
191+ GTK_ICON_LOOKUP_GENERIC_FALLBACK |
192+ GTK_ICON_LOOKUP_FORCE_SIZE,
193+ &error);
194+ if (error)
195+ {
196+ g_print ("loading icon '%s' caused error: '%s'",
197+ filename,
198+ error->message);
199+ g_error_free (error);
200+ error = NULL;
201+ pixbuf = NULL;
202+ }
203+ else
204+ {
205+ /* copy and unref buffer so on an icon-theme change old
206+ ** icons are not kept in memory due to dangling
207+ ** references, this also makes sure we do not need to
208+ ** connect to GtkWidget::style-set signal for the
209+ ** GdkPixbuf we get from gtk_icon_theme_load_icon() */
210+ pixbuf = gdk_pixbuf_copy (buffer);
211+ g_object_unref (buffer);
212+ }
213+
214+ return pixbuf;
215+}
216+
217+static void
218+image_size_allocate (GtkWidget *widget,
219+ GtkAllocation *allocation,
220+ gpointer user_data)
221+{
222+ gint max = MAX (allocation->width, allocation->height);
223+
224+ gtk_widget_set_size_request (widget, max, max);
225+}
226+
227+static GObject*
228+about_me_menu_item_constructor (GType type,
229+ guint n_construct_properties,
230+ GObjectConstructParam *construct_params)
231+{
232+ GObject *object;
233+ GtkWidget *hbox;
234+ GtkWidget *align;
235+ AboutMeMenuItemPrivate *priv;
236+ object = G_OBJECT_CLASS (about_me_menu_item_parent_class)->constructor (type,
237+ n_construct_properties,
238+ construct_params);
239+
240+ priv = GET_PRIVATE (object);
241+
242+ GtkWidget *frame = gtk_frame_new (NULL);
243+ gdouble pixels_per_em = get_pixels_per_em (frame);
244+ GdkPixbuf *pixbuf = load_icon ("stock_person", pixels_per_em * 3);
245+ priv->image = gtk_image_new_from_pixbuf (pixbuf);
246+ g_signal_connect (frame, "size-allocate", G_CALLBACK (image_size_allocate), NULL);
247+ gint height, width;
248+ gtk_widget_get_size_request (GTK_WIDGET (priv->image), &width, &height);
249+ gtk_misc_set_padding (GTK_MISC (priv->image), 2, 2);
250+ gtk_container_add (GTK_CONTAINER (frame), priv->image);
251+
252+ align = gtk_alignment_new (0, 0.3, 0, 0);
253+ priv->label = gtk_label_new (priv->realname);
254+ gtk_misc_set_padding (GTK_MISC (priv->label), 2, 2);
255+ gtk_container_add (GTK_CONTAINER (align), priv->label);
256+
257+ hbox = gtk_hbox_new (FALSE, 0);
258+ gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
259+ gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, DEFAULT_PIXELS_PER_EM);
260+
261+ gtk_container_add (GTK_CONTAINER (object), hbox);
262+ gtk_widget_show_all (GTK_WIDGET(object));
263+
264+ priv->hbox = hbox;
265+
266+ return object;
267+}
268+
269+/**
270+ * about_me_menu_item_new:
271+ * @realname: the name to display in the new menu item.
272+ * @returns: a new #AboutMeMenuItem.
273+ *
274+ * Creates a new #AboutMeMenuItem with a name.
275+ **/
276+GtkWidget*
277+about_me_menu_item_new (const gchar *realname)
278+{
279+ return g_object_new (ABOUT_ME_TYPE_MENU_ITEM,
280+ "realname", realname,
281+ NULL);
282+}
283+
284+#define __ABOUT_ME_MENU_ITEM_C__
285
286=== added file 'src/about-me-menu-item.h'
287--- src/about-me-menu-item.h 1970-01-01 00:00:00 +0000
288+++ src/about-me-menu-item.h 2010-02-18 00:41:11 +0000
289@@ -0,0 +1,65 @@
290+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
291+/*
292+ * Copyright 2010 Canonical, Ltd.
293+ *
294+ * This program is free software: you can redistribute it and/or modify it
295+ * under the terms of either or both of the following licenses:
296+ *
297+ * 1) the GNU Lesser General Public License version 3, as published by the
298+ * Free Software Foundation; and/or
299+ * 2) the GNU Lesser General Public License version 2.1, as published by
300+ * the Free Software Foundation.
301+ *
302+ * This program is distributed in the hope that it will be useful, but
303+ * WITHOUT ANY WARRANTY; without even the implied warranties of
304+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
305+ * PURPOSE. See the applicable version of the GNU Lesser General Public
306+ * License for more details.
307+ *
308+ * You should have received a copy of both the GNU Lesser General Public
309+ * License version 3 and version 2.1 along with this program. If not, see
310+ * <http://www.gnu.org/licenses/>
311+ *
312+ * Authors:
313+ * David Barth <david.barth@canonical.com>
314+ * Cody Russell <crussell@canonical.com>
315+ */
316+
317+#ifndef __ABOUT_ME_MENU_ITEM_H__
318+#define __ABOUT_ME_MENU_ITEM_H__
319+
320+#include <gtk/gtkmenuitem.h>
321+
322+G_BEGIN_DECLS
323+
324+#define ABOUT_ME_TYPE_MENU_ITEM (about_me_menu_item_get_type ())
325+#define ABOUT_ME_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItem))
326+#define ABOUT_ME_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemClass))
327+#define ABOUT_IS_ME_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ABOUT_ME_TYPE_MENU_ITEM))
328+#define ABOUT_IS_ME_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), ABOUT_ME_TYPE_MENU_ITEM))
329+#define ABOUT_ME_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemClass))
330+
331+
332+typedef struct _AboutMeMenuItem AboutMeMenuItem;
333+typedef struct _AboutMeMenuItemClass AboutMeMenuItemClass;
334+typedef struct _AboutMeMenuItemPrivate AboutMeMenuItemPrivate;
335+
336+struct _AboutMeMenuItem
337+{
338+ GtkMenuItem parent_instance;
339+
340+ AboutMeMenuItemPrivate *priv;
341+};
342+
343+struct _AboutMeMenuItemClass
344+{
345+ GtkMenuItemClass parent_class;
346+};
347+
348+
349+GType about_me_menu_item_get_type (void) G_GNUC_CONST;
350+GtkWidget *about_me_menu_item_new (const gchar *name);
351+
352+G_END_DECLS
353+
354+#endif /* __ABOUT_ME_MENU_ITEM_H__ */
355
356=== modified file 'src/dbus-shared-names.h'
357--- src/dbus-shared-names.h 2010-02-04 20:52:03 +0000
358+++ src/dbus-shared-names.h 2010-02-18 00:41:11 +0000
359@@ -30,7 +30,10 @@
360 #define INDICATOR_ME_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/me/service"
361 #define INDICATOR_ME_SERVICE_DBUS_INTERFACE "org.ayatana.indicator.me.service"
362
363-#define ENTRY_MENUITEM_TYPE "x-canonical-entry-item"
364-#define ENTRY_MENUITEM_PROP_TEXT "text"
365+#define DBUSMENU_ENTRY_MENUITEM_TYPE "x-canonical-entry-item"
366+#define DBUSMENU_ENTRY_MENUITEM_PROP_TEXT "text"
367+
368+#define DBUSMENU_ABOUT_ME_MENUITEM_TYPE "x-canonical-about-me-item"
369+#define DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME "name"
370
371 #endif /* __DBUS_SHARED_NAMES_H__ */
372
373=== modified file 'src/entry-menu-item.c'
374--- src/entry-menu-item.c 2010-02-04 20:52:03 +0000
375+++ src/entry-menu-item.c 2010-02-18 00:41:11 +0000
376@@ -113,7 +113,7 @@
377 EntryMenuItem * self = g_object_new(ENTRY_MENU_ITEM_TYPE, NULL);
378 /* EntryMenuItemPrivate * priv = ENTRY_MENU_ITEM_GET_PRIVATE(self); */
379
380- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, ENTRY_MENUITEM_TYPE);
381+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_ENTRY_MENUITEM_TYPE);
382
383 return self;
384 }
385
386=== modified file 'src/indicator-me.c'
387--- src/indicator-me.c 2010-02-05 00:43:12 +0000
388+++ src/indicator-me.c 2010-02-18 00:41:11 +0000
389@@ -1,23 +1,24 @@
390+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
391 /*
392-A menu that should be close to the user, it's the user's status,
393-their friends. All about them. It's a user-focused-menu.
394-
395-Copyright 2009 Canonical Ltd.
396-
397-Authors:
398- Ted Gould <ted@canonical.com>
399-
400-This program is free software: you can redistribute it and/or modify it
401-under the terms of the GNU General Public License version 3, as published
402-by the Free Software Foundation.
403-
404-This program is distributed in the hope that it will be useful, but
405-WITHOUT ANY WARRANTY; without even the implied warranties of
406-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
407-PURPOSE. See the GNU General Public License for more details.
408-
409-You should have received a copy of the GNU General Public License along
410-with this program. If not, see <http://www.gnu.org/licenses/>.
411+ A menu that should be close to the user, it's the user's status,
412+ their friends. All about them. It's a user-focused-menu.
413+
414+ Copyright 2009 Canonical Ltd.
415+
416+ Authors:
417+ Ted Gould <ted@canonical.com>
418+
419+ This program is free software: you can redistribute it and/or modify it
420+ under the terms of the GNU General Public License version 3, as published
421+ by the Free Software Foundation.
422+
423+ This program is distributed in the hope that it will be useful, but
424+ WITHOUT ANY WARRANTY; without even the implied warranties of
425+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
426+ PURPOSE. See the GNU General Public License for more details.
427+
428+ You should have received a copy of the GNU General Public License along
429+ with this program. If not, see <http://www.gnu.org/licenses/>.
430 */
431
432 #include <glib.h>
433@@ -34,6 +35,8 @@
434 #include <libindicator/indicator-service-manager.h>
435 #include <libido/idoentrymenuitem.h>
436
437+#include "about-me-menu-item.h"
438+
439 #include "dbus-shared-names.h"
440 #include "me-service-client.h"
441
442@@ -180,10 +183,10 @@
443 DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
444
445 status_proxy = dbus_g_proxy_new_for_name_owner(sbus,
446- INDICATOR_ME_DBUS_NAME,
447- INDICATOR_ME_SERVICE_DBUS_OBJECT,
448- INDICATOR_ME_SERVICE_DBUS_INTERFACE,
449- &error);
450+ INDICATOR_ME_DBUS_NAME,
451+ INDICATOR_ME_SERVICE_DBUS_OBJECT,
452+ INDICATOR_ME_SERVICE_DBUS_INTERFACE,
453+ &error);
454
455 if (error != NULL) {
456 g_warning("Unable to get status proxy: %s", error->message);
457@@ -206,13 +209,13 @@
458 static void
459 entry_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GValue *value, GtkEntry *entry)
460 {
461- if (g_strcmp0 (prop, ENTRY_MENUITEM_PROP_TEXT) == 0) {
462+ if (g_strcmp0 (prop, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT) == 0) {
463 gtk_entry_set_text (entry, g_value_get_string (value));
464 }
465 }
466
467 static void
468-activate_cb (GtkEntry *entry, DbusmenuMenuitem *gmi)
469+entry_activate_cb (GtkEntry *entry, DbusmenuMenuitem *gmi)
470 {
471 GValue value = { 0 };
472 g_value_init (&value, G_TYPE_STRING);
473@@ -225,8 +228,8 @@
474
475 static gboolean
476 new_entry_item (DbusmenuMenuitem * newitem,
477- DbusmenuMenuitem * parent,
478- DbusmenuClient * client)
479+ DbusmenuMenuitem * parent,
480+ DbusmenuClient * client)
481 {
482 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
483 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
484@@ -234,8 +237,9 @@
485
486 IdoEntryMenuItem *ido = IDO_ENTRY_MENU_ITEM (ido_entry_menu_item_new ());
487 GtkEntry *entry = GTK_ENTRY(ido_entry_menu_item_get_entry (ido));
488- if (dbusmenu_menuitem_property_get (newitem, ENTRY_MENUITEM_PROP_TEXT) != NULL)
489- gtk_entry_set_text(entry, dbusmenu_menuitem_property_get(newitem, ENTRY_MENUITEM_PROP_TEXT));
490+ if (dbusmenu_menuitem_property_get (newitem, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT) != NULL)
491+ gtk_entry_set_text(entry, dbusmenu_menuitem_property_get(newitem, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT));
492+ gtk_entry_set_width_chars (entry, 23); /* set some nice aspect ratio for the menu */
493
494 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
495 /* disconnect the activate signal that newitem_base connected with the wrong
496@@ -244,7 +248,24 @@
497 g_signal_handler_disconnect(GTK_MENU_ITEM (ido), signal_id);
498
499 g_signal_connect (DBUSMENU_MENUITEM (newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK (entry_prop_change_cb), entry);
500- g_signal_connect (GTK_ENTRY (entry), "activate", G_CALLBACK (activate_cb), newitem);
501+ g_signal_connect (GTK_ENTRY (entry), "activate", G_CALLBACK (entry_activate_cb), newitem);
502+
503+ return TRUE;
504+}
505+
506+static gboolean
507+new_about_me_item (DbusmenuMenuitem * newitem,
508+ DbusmenuMenuitem * parent,
509+ DbusmenuClient * client)
510+{
511+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
512+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
513+ /* Note: not checking parent, it's reasonable for it to be NULL */
514+
515+ const gchar *name = dbusmenu_menuitem_property_get (newitem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME);
516+ AboutMeMenuItem *about = ABOUT_ME_MENU_ITEM (about_me_menu_item_new (name));
517+
518+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(about), parent);
519
520 return TRUE;
521 }
522@@ -256,7 +277,8 @@
523 DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_ME_DBUS_NAME, INDICATOR_ME_DBUS_OBJECT);
524 DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu);
525
526- dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), ENTRY_MENUITEM_TYPE, new_entry_item);
527+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ENTRY_MENUITEM_TYPE, new_entry_item);
528+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ABOUT_ME_MENUITEM_TYPE, new_about_me_item);
529
530 return GTK_MENU (menu);
531 }
532
533=== modified file 'src/me-service.c'
534--- src/me-service.c 2010-02-05 20:44:54 +0000
535+++ src/me-service.c 2010-02-18 00:41:11 +0000
536@@ -1,23 +1,24 @@
537+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
538 /*
539-A small wrapper utility to load indicators and put them as menu items
540-into the gnome-panel using it's applet interface.
541-
542-Copyright 2009 Canonical Ltd.
543-
544-Authors:
545- Ted Gould <ted@canonical.com>
546-
547-This program is free software: you can redistribute it and/or modify it
548-under the terms of the GNU General Public License version 3, as published
549-by the Free Software Foundation.
550-
551-This program is distributed in the hope that it will be useful, but
552-WITHOUT ANY WARRANTY; without even the implied warranties of
553-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
554-PURPOSE. See the GNU General Public License for more details.
555-
556-You should have received a copy of the GNU General Public License along
557-with this program. If not, see <http://www.gnu.org/licenses/>.
558+ A small wrapper utility to load indicators and put them as menu items
559+ into the gnome-panel using it's applet interface.
560+
561+ Copyright 2009 Canonical Ltd.
562+
563+ Authors:
564+ Ted Gould <ted@canonical.com>
565+
566+ This program is free software: you can redistribute it and/or modify it
567+ under the terms of the GNU General Public License version 3, as published
568+ by the Free Software Foundation.
569+
570+ This program is distributed in the hope that it will be useful, but
571+ WITHOUT ANY WARRANTY; without even the implied warranties of
572+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
573+ PURPOSE. See the GNU General Public License for more details.
574+
575+ You should have received a copy of the GNU General Public License along
576+ with this program. If not, see <http://www.gnu.org/licenses/>.
577 */
578
579 #include <config.h>
580@@ -142,7 +143,7 @@
581 }
582
583 static void
584-accounts_click (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)
585+spawn_on_activate_cb (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)
586 {
587 GError * error = NULL;
588
589@@ -161,24 +162,24 @@
590 /* FIXME: find cmd line parameters with ken-vandine */
591 DbusmenuMenuitem *im_accounts_mi = dbusmenu_menuitem_new();
592 dbusmenu_menuitem_property_set(im_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
593- _("Chat Accounts..."));
594+ _("Chat Accounts..."));
595 dbusmenu_menuitem_child_append(root, im_accounts_mi);
596 g_signal_connect(G_OBJECT(im_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
597- G_CALLBACK(accounts_click), "empathy -a");
598+ G_CALLBACK(spawn_on_activate_cb), "empathy -a");
599
600 DbusmenuMenuitem *tw_accounts_mi = dbusmenu_menuitem_new();
601 dbusmenu_menuitem_property_set(tw_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
602- _("Broadcast Accounts..."));
603+ _("Broadcast Accounts..."));
604 dbusmenu_menuitem_child_append(root, tw_accounts_mi);
605 g_signal_connect(G_OBJECT(tw_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
606- G_CALLBACK(accounts_click), "gwibber-accounts");
607+ G_CALLBACK(spawn_on_activate_cb), "gwibber-accounts");
608
609 DbusmenuMenuitem *u1_accounts_mi = dbusmenu_menuitem_new();
610 dbusmenu_menuitem_property_set(u1_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
611- _("Ubuntu One..."));
612+ _("Ubuntu One..."));
613 dbusmenu_menuitem_child_append(root, u1_accounts_mi);
614 g_signal_connect(G_OBJECT(u1_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
615- G_CALLBACK(accounts_click), "ubuntuone-client-preferences");
616+ G_CALLBACK(spawn_on_activate_cb), "ubuntuone-client-preferences");
617
618 }
619
620@@ -214,12 +215,23 @@
621
622 if (name[0] != '\0') {
623 DbusmenuMenuitem * useritem = dbusmenu_menuitem_new();
624- dbusmenu_menuitem_property_set(useritem, DBUSMENU_MENUITEM_PROP_LABEL, name);
625+ dbusmenu_menuitem_property_set(useritem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME, name);
626 dbusmenu_menuitem_property_set_bool(useritem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
627+ dbusmenu_menuitem_property_set(useritem, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_ABOUT_ME_MENUITEM_TYPE);
628 dbusmenu_menuitem_child_append(root, useritem);
629+
630+ gchar *gam = g_find_program_in_path("gnome-about-me");
631+ if (gam != NULL) {
632+ dbusmenu_menuitem_property_set_bool(useritem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
633+ g_free(gam);
634+ }
635+
636+ g_signal_connect(G_OBJECT(useritem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
637+ G_CALLBACK(spawn_on_activate_cb), "gnome-about-me");
638 }
639
640 g_free(name);
641+
642 } else {
643 g_debug("PWD: %s", (pwd == NULL ? "(pwd null)" : (pwd->pw_gecos == NULL ? "(gecos null)" : pwd->pw_gecos)));
644 }
645@@ -262,7 +274,7 @@
646
647 DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
648 dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE,
649- DBUSMENU_CLIENT_TYPES_SEPARATOR);
650+ DBUSMENU_CLIENT_TYPES_SEPARATOR);
651 dbusmenu_menuitem_child_append(root, separator);
652
653 build_accounts_menuitems(root);
654@@ -281,7 +293,7 @@
655 int
656 main (int argc, char ** argv)
657 {
658- g_type_init();
659+ g_type_init();
660
661 /* Setting up i18n and gettext. Apparently, we need
662 all of these. */
663@@ -294,17 +306,17 @@
664
665 g_idle_add(build_providers, NULL);
666
667- root_menuitem = dbusmenu_menuitem_new();
668- DbusmenuServer * server = dbusmenu_server_new(INDICATOR_ME_DBUS_OBJECT);
669- dbusmenu_server_set_root(server, root_menuitem);
670+ root_menuitem = dbusmenu_menuitem_new();
671+ DbusmenuServer * server = dbusmenu_server_new(INDICATOR_ME_DBUS_OBJECT);
672+ dbusmenu_server_set_root(server, root_menuitem);
673
674 g_idle_add(build_menu, root_menuitem);
675
676 dbus_interface = g_object_new(STATUS_SERVICE_DBUS_TYPE, NULL);
677
678- mainloop = g_main_loop_new(NULL, FALSE);
679- g_main_loop_run(mainloop);
680+ mainloop = g_main_loop_new(NULL, FALSE);
681+ g_main_loop_run(mainloop);
682
683- return 0;
684+ return 0;
685 }
686

Subscribers

People subscribed via source and target branches