~bcurtiswx/ubuntu/precise/empathy/3.4.2.1-0ubuntu1

« back to all changes in this revision

Viewing changes to nothere/src/nothere-applet.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-11-16 23:40:52 UTC
  • mfrom: (1.1.39 upstream)
  • mto: (6.3.7 experimental)
  • mto: This revision was merged to the branch mainline in revision 80.
  • Revision ID: james.westby@ubuntu.com-20091116234052-7hhwrpeln4mwdyw7
Tags: upstream-2.29.2
Import upstream version 2.29.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
 
/* 
3
 
 * Copyright (C) 2007 Raphaël Slinckx <raphael@slinckx.net>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 
 *
19
 
 * Authors: Raphaël Slinckx <raphael@slinckx.net>
20
 
 */
21
 
 
22
 
#include "config.h"
23
 
 
24
 
#include <string.h>
25
 
 
26
 
#include <glib/gi18n.h>
27
 
#include <gtk/gtk.h>
28
 
#include <bonobo/bonobo-ui-component.h>
29
 
 
30
 
#include <libempathy-gtk/empathy-presence-chooser.h>
31
 
#include <libempathy-gtk/empathy-ui-utils.h>
32
 
 
33
 
#include "nothere-applet.h"
34
 
 
35
 
G_DEFINE_TYPE(NotHereApplet, nothere_applet, PANEL_TYPE_APPLET)
36
 
 
37
 
static void nothere_applet_destroy  (GtkObject         *object);
38
 
static void nothere_applet_about_cb (BonoboUIComponent *uic,
39
 
                                     NotHereApplet     *applet, 
40
 
                                     const gchar       *verb_name);
41
 
 
42
 
static const BonoboUIVerb nothere_applet_menu_verbs [] = {
43
 
        BONOBO_UI_UNSAFE_VERB ("about", nothere_applet_about_cb),
44
 
        BONOBO_UI_VERB_END
45
 
};
46
 
 
47
 
static const char* authors[] = {
48
 
        "Raphaël Slinckx <raphael@slinckx.net>", 
49
 
        NULL
50
 
};
51
 
 
52
 
static void
53
 
nothere_applet_class_init (NotHereAppletClass *class)
54
 
{
55
 
        GTK_OBJECT_CLASS (class)->destroy = nothere_applet_destroy;
56
 
 
57
 
        empathy_gtk_init ();
58
 
}
59
 
 
60
 
static gboolean
61
 
do_not_eat_button_press (GtkWidget      *widget,
62
 
                         GdkEventButton *event)
63
 
{
64
 
        if (event->button != 1) {
65
 
                g_signal_stop_emission_by_name (widget, "button_press_event");
66
 
        }
67
 
 
68
 
        return FALSE;
69
 
}
70
 
 
71
 
static void
72
 
nothere_applet_init (NotHereApplet *applet)
73
 
{
74
 
        applet->presence_chooser = empathy_presence_chooser_new ();
75
 
        g_signal_connect (G_OBJECT (applet->presence_chooser), "button_press_event",
76
 
                          G_CALLBACK (do_not_eat_button_press), NULL);
77
 
 
78
 
        gtk_widget_show (applet->presence_chooser);
79
 
 
80
 
        gtk_container_add (GTK_CONTAINER (applet), applet->presence_chooser);
81
 
 
82
 
        panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
83
 
        panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
84
 
}
85
 
 
86
 
static void
87
 
nothere_applet_destroy (GtkObject *object)
88
 
{
89
 
        NotHereApplet *applet = NOTHERE_APPLET (object);
90
 
 
91
 
        applet->presence_chooser = NULL;
92
 
 
93
 
        (* GTK_OBJECT_CLASS (nothere_applet_parent_class)->destroy) (object);
94
 
}
95
 
 
96
 
static void
97
 
nothere_applet_about_cb (BonoboUIComponent *uic, 
98
 
                         NotHereApplet     *applet, 
99
 
                         const gchar       *verb_name)
100
 
{
101
 
        gtk_show_about_dialog (NULL,
102
 
                               "name", "Presence", 
103
 
                               "version", PACKAGE_VERSION,
104
 
                               "copyright", "Copyright \xc2\xa9 2007 Raphaël Slinckx",
105
 
                               "comments", _("Set your own presence"),
106
 
                               "authors", authors,
107
 
                               "logo-icon-name", "stock_people",
108
 
                               NULL);
109
 
}
110
 
 
111
 
static gboolean
112
 
nothere_applet_factory (PanelApplet *applet, 
113
 
                        const gchar *iid, 
114
 
                        gpointer     data)
115
 
{
116
 
        if (strcmp (iid, "OAFIID:GNOME_NotHere_Applet") != 0) {
117
 
                return FALSE;
118
 
        }
119
 
        
120
 
        /* Set up the menu */
121
 
        panel_applet_setup_menu_from_file (applet,
122
 
                                           PKGDATADIR,
123
 
                                           "GNOME_NotHere_Applet.xml",
124
 
                                           NULL,
125
 
                                           nothere_applet_menu_verbs,
126
 
                                           applet);
127
 
 
128
 
        gtk_widget_show (GTK_WIDGET (applet));
129
 
        return TRUE;
130
 
}
131
 
 
132
 
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotHere_Applet_Factory",
133
 
                             NOTHERE_TYPE_APPLET,
134
 
                             "Presence", PACKAGE_VERSION,
135
 
                             nothere_applet_factory,
136
 
                             NULL);