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
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-02-04 20:52:03 +0000
+++ src/Makefile.am 2010-02-18 00:41:11 +0000
@@ -8,6 +8,8 @@
8melibdir = $(INDICATORDIR)8melibdir = $(INDICATORDIR)
9melib_LTLIBRARIES = libme.la9melib_LTLIBRARIES = libme.la
10libme_la_SOURCES = \10libme_la_SOURCES = \
11 about-me-menu-item.c \
12 about-me-menu-item.h \
11 indicator-me.c \13 indicator-me.c \
12 dbus-shared-names.h \14 dbus-shared-names.h \
13 me-service-client.h15 me-service-client.h
1416
=== added file 'src/about-me-menu-item.c'
--- src/about-me-menu-item.c 1970-01-01 00:00:00 +0000
+++ src/about-me-menu-item.c 2010-02-18 00:41:11 +0000
@@ -0,0 +1,267 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
2/*
3 * Copyright 2010 Canonical, Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of either or both of the following licenses:
7 *
8 * 1) the GNU Lesser General Public License version 3, as published by the
9 * Free Software Foundation; and/or
10 * 2) the GNU Lesser General Public License version 2.1, as published by
11 * the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranties of
15 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the applicable version of the GNU Lesser General Public
17 * License for more details.
18 *
19 * You should have received a copy of both the GNU Lesser General Public
20 * License version 3 and version 2.1 along with this program. If not, see
21 * <http://www.gnu.org/licenses/>
22 *
23 * Authors:
24 * David Barth <david.barth@canonical.com>
25 * Cody Russell <crussell@canonical.com>
26 */
27
28#include <gtk/gtk.h>
29#include "about-me-menu-item.h"
30
31static GObject* about_me_menu_item_constructor (GType type,
32 guint n_construct_properties,
33 GObjectConstructParam *construct_params);
34static void about_me_menu_item_set_property (GObject *object,
35 guint prop_id,
36 const GValue *value,
37 GParamSpec *pspec);
38static void about_me_menu_item_get_property (GObject *object,
39 guint prop_id,
40 GValue *value,
41 GParamSpec *pspec);
42
43struct _AboutMeMenuItemPrivate {
44 GtkWidget *label;
45 GtkWidget *image;
46 GtkWidget *hbox;
47 gchar *realname;
48};
49
50enum {
51 PROP_0,
52 PROP_REALNAME
53};
54
55G_DEFINE_TYPE (AboutMeMenuItem, about_me_menu_item, GTK_TYPE_MENU_ITEM)
56
57#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemPrivate))
58
59static void
60about_me_menu_item_class_init (AboutMeMenuItemClass *item_class)
61{
62 GObjectClass *gobject_class = G_OBJECT_CLASS (item_class);
63
64 gobject_class->constructor = about_me_menu_item_constructor;
65 gobject_class->set_property = about_me_menu_item_set_property;
66 gobject_class->get_property = about_me_menu_item_get_property;
67
68 g_object_class_install_property (gobject_class,
69 PROP_REALNAME,
70 g_param_spec_string ("realname",
71 "Realname",
72 "The \"Realname\" for the user",
73 NULL,
74 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
75
76 g_type_class_add_private (gobject_class, sizeof (AboutMeMenuItemPrivate));
77}
78
79static void
80about_me_menu_item_init (AboutMeMenuItem *self)
81{
82 AboutMeMenuItemPrivate *priv = GET_PRIVATE (self);
83
84 priv->label = NULL;
85 priv->image = NULL;
86 priv->realname = NULL;
87}
88
89static void
90about_me_menu_item_set_property (GObject *object,
91 guint prop_id,
92 const GValue *value,
93 GParamSpec *pspec)
94{
95 AboutMeMenuItem *menu_item = ABOUT_ME_MENU_ITEM (object);
96 AboutMeMenuItemPrivate *priv = GET_PRIVATE (menu_item);
97
98 switch (prop_id)
99 {
100 case PROP_REALNAME:
101 g_assert (priv->realname == NULL);
102 priv->realname = g_strdup (g_value_get_string (value));
103 break;
104
105 default:
106 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
107 break;
108 }
109}
110
111static void
112about_me_menu_item_get_property (GObject *object,
113 guint prop_id,
114 GValue *value,
115 GParamSpec *pspec)
116{
117 AboutMeMenuItem *menu_item = ABOUT_ME_MENU_ITEM (object);
118 AboutMeMenuItemPrivate *priv = GET_PRIVATE (menu_item);
119
120 switch (prop_id)
121 {
122 case PROP_REALNAME:
123 g_value_set_string (value, priv->realname);
124 break;
125
126 default:
127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
128 break;
129 }
130}
131
132#define DEFAULT_PIXELS_PER_EM 10.0f
133
134static gdouble
135get_pixels_per_em (GtkWidget *widget)
136{
137 g_return_val_if_fail (GTK_IS_WIDGET (widget), DEFAULT_PIXELS_PER_EM);
138
139 /* Note: taken from indicator-session */
140 GtkStyle * style = gtk_widget_get_style(widget);
141
142 PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(widget));
143 pango_layout_set_text(layout, "M", -1);
144 pango_layout_set_font_description(layout, style->font_desc);
145
146 gint width;
147 pango_layout_get_pixel_size(layout, &width, NULL);
148
149 gint point = pango_font_description_get_size(style->font_desc);
150 gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default());
151
152 return ((point * dpi) / 72.0f) / PANGO_SCALE;
153}
154
155
156/* from n-osd */
157static GdkPixbuf*
158load_icon (const gchar* filename,
159 gint icon_size)
160{
161 GdkPixbuf* buffer = NULL;
162 GdkPixbuf* pixbuf = NULL;
163 GtkIconTheme* theme = NULL;
164 GError* error = NULL;
165
166 /* sanity check */
167 g_return_val_if_fail (filename, NULL);
168
169 theme = gtk_icon_theme_get_default ();
170 buffer = gtk_icon_theme_load_icon (theme,
171 filename,
172 icon_size,
173 GTK_ICON_LOOKUP_FORCE_SVG |
174 GTK_ICON_LOOKUP_GENERIC_FALLBACK |
175 GTK_ICON_LOOKUP_FORCE_SIZE,
176 &error);
177 if (error)
178 {
179 g_print ("loading icon '%s' caused error: '%s'",
180 filename,
181 error->message);
182 g_error_free (error);
183 error = NULL;
184 pixbuf = NULL;
185 }
186 else
187 {
188 /* copy and unref buffer so on an icon-theme change old
189 ** icons are not kept in memory due to dangling
190 ** references, this also makes sure we do not need to
191 ** connect to GtkWidget::style-set signal for the
192 ** GdkPixbuf we get from gtk_icon_theme_load_icon() */
193 pixbuf = gdk_pixbuf_copy (buffer);
194 g_object_unref (buffer);
195 }
196
197 return pixbuf;
198}
199
200static void
201image_size_allocate (GtkWidget *widget,
202 GtkAllocation *allocation,
203 gpointer user_data)
204{
205 gint max = MAX (allocation->width, allocation->height);
206
207 gtk_widget_set_size_request (widget, max, max);
208}
209
210static GObject*
211about_me_menu_item_constructor (GType type,
212 guint n_construct_properties,
213 GObjectConstructParam *construct_params)
214{
215 GObject *object;
216 GtkWidget *hbox;
217 GtkWidget *align;
218 AboutMeMenuItemPrivate *priv;
219 object = G_OBJECT_CLASS (about_me_menu_item_parent_class)->constructor (type,
220 n_construct_properties,
221 construct_params);
222
223 priv = GET_PRIVATE (object);
224
225 GtkWidget *frame = gtk_frame_new (NULL);
226 gdouble pixels_per_em = get_pixels_per_em (frame);
227 GdkPixbuf *pixbuf = load_icon ("stock_person", pixels_per_em * 3);
228 priv->image = gtk_image_new_from_pixbuf (pixbuf);
229 g_signal_connect (frame, "size-allocate", G_CALLBACK (image_size_allocate), NULL);
230 gint height, width;
231 gtk_widget_get_size_request (GTK_WIDGET (priv->image), &width, &height);
232 gtk_misc_set_padding (GTK_MISC (priv->image), 2, 2);
233 gtk_container_add (GTK_CONTAINER (frame), priv->image);
234
235 align = gtk_alignment_new (0, 0.3, 0, 0);
236 priv->label = gtk_label_new (priv->realname);
237 gtk_misc_set_padding (GTK_MISC (priv->label), 2, 2);
238 gtk_container_add (GTK_CONTAINER (align), priv->label);
239
240 hbox = gtk_hbox_new (FALSE, 0);
241 gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
242 gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, DEFAULT_PIXELS_PER_EM);
243
244 gtk_container_add (GTK_CONTAINER (object), hbox);
245 gtk_widget_show_all (GTK_WIDGET(object));
246
247 priv->hbox = hbox;
248
249 return object;
250}
251
252/**
253 * about_me_menu_item_new:
254 * @realname: the name to display in the new menu item.
255 * @returns: a new #AboutMeMenuItem.
256 *
257 * Creates a new #AboutMeMenuItem with a name.
258 **/
259GtkWidget*
260about_me_menu_item_new (const gchar *realname)
261{
262 return g_object_new (ABOUT_ME_TYPE_MENU_ITEM,
263 "realname", realname,
264 NULL);
265}
266
267#define __ABOUT_ME_MENU_ITEM_C__
0268
=== added file 'src/about-me-menu-item.h'
--- src/about-me-menu-item.h 1970-01-01 00:00:00 +0000
+++ src/about-me-menu-item.h 2010-02-18 00:41:11 +0000
@@ -0,0 +1,65 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
2/*
3 * Copyright 2010 Canonical, Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of either or both of the following licenses:
7 *
8 * 1) the GNU Lesser General Public License version 3, as published by the
9 * Free Software Foundation; and/or
10 * 2) the GNU Lesser General Public License version 2.1, as published by
11 * the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranties of
15 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the applicable version of the GNU Lesser General Public
17 * License for more details.
18 *
19 * You should have received a copy of both the GNU Lesser General Public
20 * License version 3 and version 2.1 along with this program. If not, see
21 * <http://www.gnu.org/licenses/>
22 *
23 * Authors:
24 * David Barth <david.barth@canonical.com>
25 * Cody Russell <crussell@canonical.com>
26 */
27
28#ifndef __ABOUT_ME_MENU_ITEM_H__
29#define __ABOUT_ME_MENU_ITEM_H__
30
31#include <gtk/gtkmenuitem.h>
32
33G_BEGIN_DECLS
34
35#define ABOUT_ME_TYPE_MENU_ITEM (about_me_menu_item_get_type ())
36#define ABOUT_ME_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItem))
37#define ABOUT_ME_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemClass))
38#define ABOUT_IS_ME_MENU_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ABOUT_ME_TYPE_MENU_ITEM))
39#define ABOUT_IS_ME_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), ABOUT_ME_TYPE_MENU_ITEM))
40#define ABOUT_ME_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ABOUT_ME_TYPE_MENU_ITEM, AboutMeMenuItemClass))
41
42
43typedef struct _AboutMeMenuItem AboutMeMenuItem;
44typedef struct _AboutMeMenuItemClass AboutMeMenuItemClass;
45typedef struct _AboutMeMenuItemPrivate AboutMeMenuItemPrivate;
46
47struct _AboutMeMenuItem
48{
49 GtkMenuItem parent_instance;
50
51 AboutMeMenuItemPrivate *priv;
52};
53
54struct _AboutMeMenuItemClass
55{
56 GtkMenuItemClass parent_class;
57};
58
59
60GType about_me_menu_item_get_type (void) G_GNUC_CONST;
61GtkWidget *about_me_menu_item_new (const gchar *name);
62
63G_END_DECLS
64
65#endif /* __ABOUT_ME_MENU_ITEM_H__ */
066
=== modified file 'src/dbus-shared-names.h'
--- src/dbus-shared-names.h 2010-02-04 20:52:03 +0000
+++ src/dbus-shared-names.h 2010-02-18 00:41:11 +0000
@@ -30,7 +30,10 @@
30#define INDICATOR_ME_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/me/service"30#define INDICATOR_ME_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/me/service"
31#define INDICATOR_ME_SERVICE_DBUS_INTERFACE "org.ayatana.indicator.me.service"31#define INDICATOR_ME_SERVICE_DBUS_INTERFACE "org.ayatana.indicator.me.service"
3232
33#define ENTRY_MENUITEM_TYPE "x-canonical-entry-item"33#define DBUSMENU_ENTRY_MENUITEM_TYPE "x-canonical-entry-item"
34#define ENTRY_MENUITEM_PROP_TEXT "text"34#define DBUSMENU_ENTRY_MENUITEM_PROP_TEXT "text"
35
36#define DBUSMENU_ABOUT_ME_MENUITEM_TYPE "x-canonical-about-me-item"
37#define DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME "name"
3538
36#endif /* __DBUS_SHARED_NAMES_H__ */39#endif /* __DBUS_SHARED_NAMES_H__ */
3740
=== modified file 'src/entry-menu-item.c'
--- src/entry-menu-item.c 2010-02-04 20:52:03 +0000
+++ src/entry-menu-item.c 2010-02-18 00:41:11 +0000
@@ -113,7 +113,7 @@
113 EntryMenuItem * self = g_object_new(ENTRY_MENU_ITEM_TYPE, NULL);113 EntryMenuItem * self = g_object_new(ENTRY_MENU_ITEM_TYPE, NULL);
114 /* EntryMenuItemPrivate * priv = ENTRY_MENU_ITEM_GET_PRIVATE(self); */114 /* EntryMenuItemPrivate * priv = ENTRY_MENU_ITEM_GET_PRIVATE(self); */
115115
116 dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, ENTRY_MENUITEM_TYPE);116 dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_ENTRY_MENUITEM_TYPE);
117117
118 return self;118 return self;
119}119}
120120
=== modified file 'src/indicator-me.c'
--- src/indicator-me.c 2010-02-05 00:43:12 +0000
+++ src/indicator-me.c 2010-02-18 00:41:11 +0000
@@ -1,23 +1,24 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
1/*2/*
2A menu that should be close to the user, it's the user's status,3 A menu that should be close to the user, it's the user's status,
3their friends. All about them. It's a user-focused-menu.4 their friends. All about them. It's a user-focused-menu.
45
5Copyright 2009 Canonical Ltd.6 Copyright 2009 Canonical Ltd.
67
7Authors:8 Authors:
8 Ted Gould <ted@canonical.com>9 Ted Gould <ted@canonical.com>
910
10This program is free software: you can redistribute it and/or modify it 11 This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published 12 under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.13 by the Free Software Foundation.
1314
14This program is distributed in the hope that it will be useful, but 15 This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of 16 WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 17 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.18 PURPOSE. See the GNU General Public License for more details.
1819
19You should have received a copy of the GNU General Public License along 20 You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.21 with this program. If not, see <http://www.gnu.org/licenses/>.
21*/22*/
2223
23#include <glib.h>24#include <glib.h>
@@ -34,6 +35,8 @@
34#include <libindicator/indicator-service-manager.h>35#include <libindicator/indicator-service-manager.h>
35#include <libido/idoentrymenuitem.h>36#include <libido/idoentrymenuitem.h>
3637
38#include "about-me-menu-item.h"
39
37#include "dbus-shared-names.h"40#include "dbus-shared-names.h"
38#include "me-service-client.h"41#include "me-service-client.h"
3942
@@ -180,10 +183,10 @@
180 DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);183 DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
181184
182 status_proxy = dbus_g_proxy_new_for_name_owner(sbus,185 status_proxy = dbus_g_proxy_new_for_name_owner(sbus,
183 INDICATOR_ME_DBUS_NAME,186 INDICATOR_ME_DBUS_NAME,
184 INDICATOR_ME_SERVICE_DBUS_OBJECT,187 INDICATOR_ME_SERVICE_DBUS_OBJECT,
185 INDICATOR_ME_SERVICE_DBUS_INTERFACE,188 INDICATOR_ME_SERVICE_DBUS_INTERFACE,
186 &error);189 &error);
187190
188 if (error != NULL) {191 if (error != NULL) {
189 g_warning("Unable to get status proxy: %s", error->message);192 g_warning("Unable to get status proxy: %s", error->message);
@@ -206,13 +209,13 @@
206static void209static void
207entry_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GValue *value, GtkEntry *entry)210entry_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GValue *value, GtkEntry *entry)
208{211{
209 if (g_strcmp0 (prop, ENTRY_MENUITEM_PROP_TEXT) == 0) {212 if (g_strcmp0 (prop, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT) == 0) {
210 gtk_entry_set_text (entry, g_value_get_string (value));213 gtk_entry_set_text (entry, g_value_get_string (value));
211 }214 }
212}215}
213216
214static void217static void
215activate_cb (GtkEntry *entry, DbusmenuMenuitem *gmi)218entry_activate_cb (GtkEntry *entry, DbusmenuMenuitem *gmi)
216{219{
217 GValue value = { 0 };220 GValue value = { 0 };
218 g_value_init (&value, G_TYPE_STRING);221 g_value_init (&value, G_TYPE_STRING);
@@ -225,8 +228,8 @@
225228
226static gboolean229static gboolean
227new_entry_item (DbusmenuMenuitem * newitem,230new_entry_item (DbusmenuMenuitem * newitem,
228 DbusmenuMenuitem * parent,231 DbusmenuMenuitem * parent,
229 DbusmenuClient * client)232 DbusmenuClient * client)
230{233{
231 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);234 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
232 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);235 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
@@ -234,8 +237,9 @@
234237
235 IdoEntryMenuItem *ido = IDO_ENTRY_MENU_ITEM (ido_entry_menu_item_new ());238 IdoEntryMenuItem *ido = IDO_ENTRY_MENU_ITEM (ido_entry_menu_item_new ());
236 GtkEntry *entry = GTK_ENTRY(ido_entry_menu_item_get_entry (ido));239 GtkEntry *entry = GTK_ENTRY(ido_entry_menu_item_get_entry (ido));
237 if (dbusmenu_menuitem_property_get (newitem, ENTRY_MENUITEM_PROP_TEXT) != NULL)240 if (dbusmenu_menuitem_property_get (newitem, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT) != NULL)
238 gtk_entry_set_text(entry, dbusmenu_menuitem_property_get(newitem, ENTRY_MENUITEM_PROP_TEXT));241 gtk_entry_set_text(entry, dbusmenu_menuitem_property_get(newitem, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT));
242 gtk_entry_set_width_chars (entry, 23); /* set some nice aspect ratio for the menu */
239243
240 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);244 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
241 /* disconnect the activate signal that newitem_base connected with the wrong245 /* disconnect the activate signal that newitem_base connected with the wrong
@@ -244,7 +248,24 @@
244 g_signal_handler_disconnect(GTK_MENU_ITEM (ido), signal_id);248 g_signal_handler_disconnect(GTK_MENU_ITEM (ido), signal_id);
245249
246 g_signal_connect (DBUSMENU_MENUITEM (newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK (entry_prop_change_cb), entry);250 g_signal_connect (DBUSMENU_MENUITEM (newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK (entry_prop_change_cb), entry);
247 g_signal_connect (GTK_ENTRY (entry), "activate", G_CALLBACK (activate_cb), newitem);251 g_signal_connect (GTK_ENTRY (entry), "activate", G_CALLBACK (entry_activate_cb), newitem);
252
253 return TRUE;
254}
255
256static gboolean
257new_about_me_item (DbusmenuMenuitem * newitem,
258 DbusmenuMenuitem * parent,
259 DbusmenuClient * client)
260{
261 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
262 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
263 /* Note: not checking parent, it's reasonable for it to be NULL */
264
265 const gchar *name = dbusmenu_menuitem_property_get (newitem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME);
266 AboutMeMenuItem *about = ABOUT_ME_MENU_ITEM (about_me_menu_item_new (name));
267
268 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(about), parent);
248269
249 return TRUE;270 return TRUE;
250}271}
@@ -256,7 +277,8 @@
256 DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_ME_DBUS_NAME, INDICATOR_ME_DBUS_OBJECT);277 DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_ME_DBUS_NAME, INDICATOR_ME_DBUS_OBJECT);
257 DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu);278 DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu);
258279
259 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), ENTRY_MENUITEM_TYPE, new_entry_item);280 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ENTRY_MENUITEM_TYPE, new_entry_item);
281 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ABOUT_ME_MENUITEM_TYPE, new_about_me_item);
260282
261 return GTK_MENU (menu);283 return GTK_MENU (menu);
262}284}
263285
=== modified file 'src/me-service.c'
--- src/me-service.c 2010-02-05 20:44:54 +0000
+++ src/me-service.c 2010-02-18 00:41:11 +0000
@@ -1,23 +1,24 @@
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
1/*2/*
2A small wrapper utility to load indicators and put them as menu items3 A small wrapper utility to load indicators and put them as menu items
3into the gnome-panel using it's applet interface.4 into the gnome-panel using it's applet interface.
45
5Copyright 2009 Canonical Ltd.6 Copyright 2009 Canonical Ltd.
67
7Authors:8 Authors:
8 Ted Gould <ted@canonical.com>9 Ted Gould <ted@canonical.com>
910
10This program is free software: you can redistribute it and/or modify it11 This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published12 under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.13 by the Free Software Foundation.
1314
14This program is distributed in the hope that it will be useful, but15 This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of16 WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR17 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.18 PURPOSE. See the GNU General Public License for more details.
1819
19You should have received a copy of the GNU General Public License along20 You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.21 with this program. If not, see <http://www.gnu.org/licenses/>.
21*/22*/
2223
23#include <config.h>24#include <config.h>
@@ -142,7 +143,7 @@
142}143}
143144
144static void145static void
145accounts_click (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)146spawn_on_activate_cb (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data)
146{147{
147 GError * error = NULL;148 GError * error = NULL;
148149
@@ -161,24 +162,24 @@
161 /* FIXME: find cmd line parameters with ken-vandine */162 /* FIXME: find cmd line parameters with ken-vandine */
162 DbusmenuMenuitem *im_accounts_mi = dbusmenu_menuitem_new();163 DbusmenuMenuitem *im_accounts_mi = dbusmenu_menuitem_new();
163 dbusmenu_menuitem_property_set(im_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,164 dbusmenu_menuitem_property_set(im_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
164 _("Chat Accounts..."));165 _("Chat Accounts..."));
165 dbusmenu_menuitem_child_append(root, im_accounts_mi);166 dbusmenu_menuitem_child_append(root, im_accounts_mi);
166 g_signal_connect(G_OBJECT(im_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,167 g_signal_connect(G_OBJECT(im_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
167 G_CALLBACK(accounts_click), "empathy -a");168 G_CALLBACK(spawn_on_activate_cb), "empathy -a");
168169
169 DbusmenuMenuitem *tw_accounts_mi = dbusmenu_menuitem_new();170 DbusmenuMenuitem *tw_accounts_mi = dbusmenu_menuitem_new();
170 dbusmenu_menuitem_property_set(tw_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,171 dbusmenu_menuitem_property_set(tw_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
171 _("Broadcast Accounts..."));172 _("Broadcast Accounts..."));
172 dbusmenu_menuitem_child_append(root, tw_accounts_mi);173 dbusmenu_menuitem_child_append(root, tw_accounts_mi);
173 g_signal_connect(G_OBJECT(tw_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,174 g_signal_connect(G_OBJECT(tw_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
174 G_CALLBACK(accounts_click), "gwibber-accounts");175 G_CALLBACK(spawn_on_activate_cb), "gwibber-accounts");
175176
176 DbusmenuMenuitem *u1_accounts_mi = dbusmenu_menuitem_new();177 DbusmenuMenuitem *u1_accounts_mi = dbusmenu_menuitem_new();
177 dbusmenu_menuitem_property_set(u1_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,178 dbusmenu_menuitem_property_set(u1_accounts_mi, DBUSMENU_MENUITEM_PROP_LABEL,
178 _("Ubuntu One..."));179 _("Ubuntu One..."));
179 dbusmenu_menuitem_child_append(root, u1_accounts_mi);180 dbusmenu_menuitem_child_append(root, u1_accounts_mi);
180 g_signal_connect(G_OBJECT(u1_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,181 g_signal_connect(G_OBJECT(u1_accounts_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
181 G_CALLBACK(accounts_click), "ubuntuone-client-preferences");182 G_CALLBACK(spawn_on_activate_cb), "ubuntuone-client-preferences");
182183
183}184}
184185
@@ -214,12 +215,23 @@
214215
215 if (name[0] != '\0') {216 if (name[0] != '\0') {
216 DbusmenuMenuitem * useritem = dbusmenu_menuitem_new();217 DbusmenuMenuitem * useritem = dbusmenu_menuitem_new();
217 dbusmenu_menuitem_property_set(useritem, DBUSMENU_MENUITEM_PROP_LABEL, name);218 dbusmenu_menuitem_property_set(useritem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME, name);
218 dbusmenu_menuitem_property_set_bool(useritem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);219 dbusmenu_menuitem_property_set_bool(useritem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
220 dbusmenu_menuitem_property_set(useritem, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_ABOUT_ME_MENUITEM_TYPE);
219 dbusmenu_menuitem_child_append(root, useritem);221 dbusmenu_menuitem_child_append(root, useritem);
222
223 gchar *gam = g_find_program_in_path("gnome-about-me");
224 if (gam != NULL) {
225 dbusmenu_menuitem_property_set_bool(useritem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
226 g_free(gam);
227 }
228
229 g_signal_connect(G_OBJECT(useritem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
230 G_CALLBACK(spawn_on_activate_cb), "gnome-about-me");
220 }231 }
221232
222 g_free(name);233 g_free(name);
234
223 } else {235 } else {
224 g_debug("PWD: %s", (pwd == NULL ? "(pwd null)" : (pwd->pw_gecos == NULL ? "(gecos null)" : pwd->pw_gecos)));236 g_debug("PWD: %s", (pwd == NULL ? "(pwd null)" : (pwd->pw_gecos == NULL ? "(gecos null)" : pwd->pw_gecos)));
225 }237 }
@@ -262,7 +274,7 @@
262274
263 DbusmenuMenuitem *separator = dbusmenu_menuitem_new();275 DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
264 dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE,276 dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE,
265 DBUSMENU_CLIENT_TYPES_SEPARATOR);277 DBUSMENU_CLIENT_TYPES_SEPARATOR);
266 dbusmenu_menuitem_child_append(root, separator);278 dbusmenu_menuitem_child_append(root, separator);
267279
268 build_accounts_menuitems(root);280 build_accounts_menuitems(root);
@@ -281,7 +293,7 @@
281int293int
282main (int argc, char ** argv)294main (int argc, char ** argv)
283{295{
284 g_type_init();296 g_type_init();
285297
286 /* Setting up i18n and gettext. Apparently, we need298 /* Setting up i18n and gettext. Apparently, we need
287 all of these. */299 all of these. */
@@ -294,17 +306,17 @@
294306
295 g_idle_add(build_providers, NULL);307 g_idle_add(build_providers, NULL);
296308
297 root_menuitem = dbusmenu_menuitem_new();309 root_menuitem = dbusmenu_menuitem_new();
298 DbusmenuServer * server = dbusmenu_server_new(INDICATOR_ME_DBUS_OBJECT);310 DbusmenuServer * server = dbusmenu_server_new(INDICATOR_ME_DBUS_OBJECT);
299 dbusmenu_server_set_root(server, root_menuitem);311 dbusmenu_server_set_root(server, root_menuitem);
300312
301 g_idle_add(build_menu, root_menuitem);313 g_idle_add(build_menu, root_menuitem);
302314
303 dbus_interface = g_object_new(STATUS_SERVICE_DBUS_TYPE, NULL);315 dbus_interface = g_object_new(STATUS_SERVICE_DBUS_TYPE, NULL);
304316
305 mainloop = g_main_loop_new(NULL, FALSE);317 mainloop = g_main_loop_new(NULL, FALSE);
306 g_main_loop_run(mainloop);318 g_main_loop_run(mainloop);
307319
308 return 0;320 return 0;
309}321}
310322

Subscribers

People subscribed via source and target branches