~ubuntu-branches/ubuntu/precise/indicator-me/precise

« back to all changes in this revision

Viewing changes to src/indicator-me.c

  • Committer: Package Import Robot
  • Author(s): Evgeni Golov
  • Date: 2011-06-04 22:45:27 UTC
  • mfrom: (12.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20110604224527-jt4zuynua7zuwi2w
Tags: 0.2.19-1
* Merge from Ubuntu.
  Closes: #629249
* Standards-Version: 3.9.2
* Revert "recommends unity rather than indicator-applet-session" as
  Debian does not have Unity yet.
* Improve debian/copyright to match DEP5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <gtk/gtk.h>
29
29
#include <gio/gio.h>
30
30
#include <libdbusmenu-glib/menuitem.h>
31
 
 
32
 
#if GTK_CHECK_VERSION(3, 0, 0)
33
 
#include <libdbusmenu-gtk3/menu.h>
34
 
#else
35
31
#include <libdbusmenu-gtk/menu.h>
36
 
#endif
37
32
 
38
33
#include <libindicator/indicator.h>
39
34
#include <libindicator/indicator-object.h>
41
36
#include <libindicator/indicator-image-helper.h>
42
37
#include <libido/idoentrymenuitem.h>
43
38
 
 
39
#include "about-me-menu-item.h"
 
40
 
44
41
#include "dbus-shared-names.h"
45
42
#include "gen-me-service.xml.h"
46
43
 
99
96
                                DbusmenuMenuitem * parent,
100
97
                                DbusmenuClient   * client,
101
98
                                gpointer user_data);
 
99
static gboolean new_about_me_item (DbusmenuMenuitem * newitem,
 
100
                                DbusmenuMenuitem * parent,
 
101
                                DbusmenuClient   * client,
 
102
                                gpointer user_data);
102
103
static void     entry_activate_cb (GtkEntry *entry, DbusmenuMenuitem *mi);
103
104
static void     entry_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GVariant *value, GtkEntry *entry);
104
105
static gboolean entry_hint_is_shown (GtkWidget *widget);
334
335
}
335
336
 
336
337
static void
337
 
item_destroyed_cb (DbusmenuMenuitem *item,
 
338
item_destroyed_cb (GtkObject *item,
338
339
                   gpointer   user_data)
339
340
{
340
341
  g_signal_handlers_disconnect_by_func (user_data,
478
479
                                         DBUSMENU_ENTRY_MENUITEM_PROP_HINT);
479
480
 
480
481
  /* enforce style when typing a message */
481
 
  if (gtk_widget_has_focus (GTK_WIDGET (entry))) {
 
482
  if (GTK_WIDGET_HAS_FOCUS (entry)) {
482
483
    entry_set_style (entry, GTK_STATE_NORMAL);
483
484
    entry_hint_set_shown (GTK_WIDGET (entry), FALSE);
484
485
 
659
660
        return TRUE;
660
661
}
661
662
 
 
663
/* Whenever we have a property change on a DbusmenuMenuitem
 
664
   we need to be responsive to that. */
 
665
static void
 
666
about_me_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, AboutMeMenuItem *item)
 
667
{
 
668
  g_return_if_fail (ABOUT_IS_ME_MENU_ITEM (item));
 
669
 
 
670
        if (!g_strcmp0(prop, DBUSMENU_ABOUT_ME_MENUITEM_PROP_ICON)) {
 
671
    /* reload the avatar icon */
 
672
    about_me_menu_item_load_avatar (item, g_variant_get_string(value, NULL));
 
673
  } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) {
 
674
    /* normal, ignore */
 
675
        } else {
 
676
                g_warning("Indicator Item property '%s' unknown", prop);
 
677
        }
 
678
 
 
679
        return;
 
680
}
 
681
 
 
682
static gboolean
 
683
new_about_me_item (DbusmenuMenuitem * newitem,
 
684
                   DbusmenuMenuitem * parent,
 
685
                   DbusmenuClient * client,
 
686
                   gpointer user_data)
 
687
{
 
688
        g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
 
689
        g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
 
690
        /* Note: not checking parent, it's reasonable for it to be NULL */
 
691
 
 
692
        const gchar *name = dbusmenu_menuitem_property_get (newitem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_NAME);
 
693
        AboutMeMenuItem *about = ABOUT_ME_MENU_ITEM (about_me_menu_item_new (name));
 
694
  if (about != NULL) {
 
695
    dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(about), parent);
 
696
    const gchar *avatar = dbusmenu_menuitem_property_get (newitem, DBUSMENU_ABOUT_ME_MENUITEM_PROP_ICON);
 
697
    about_me_menu_item_load_avatar (about, avatar);
 
698
    g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(about_me_prop_change_cb), about);
 
699
  }
 
700
 
 
701
        return TRUE;
 
702
}
 
703
 
662
704
/* Builds the dbusmenu for the service. */
663
705
static GtkMenu *
664
706
get_menu (IndicatorObject * io)
667
709
        DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu);
668
710
 
669
711
        dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ENTRY_MENUITEM_TYPE, new_entry_item);
 
712
        dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_ABOUT_ME_MENUITEM_TYPE, new_about_me_item);
670
713
 
671
714
        return GTK_MENU (menu);
672
715
}