aboutsummaryrefslogtreecommitdiffstats
path: root/nothere/src/nothere-applet.c
blob: 5d225698babfd51ad53b83de23737adb4c339443 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* 
 * Copyright (C) 2007 Raphaël Slinckx <raphael@slinckx.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Authors: Raphaël Slinckx <raphael@slinckx.net>
 */

#include "config.h"

#include <string.h>

#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <bonobo/bonobo-ui-component.h>

#include <libmissioncontrol/mission-control.h>
#include <libempathy-gtk/empathy-presence-chooser.h>

#include "nothere-applet.h"

G_DEFINE_TYPE(NotHereApplet, nothere_applet, PANEL_TYPE_APPLET)

static void nothere_applet_destroy  (GtkObject         *object);
static void nothere_applet_about_cb (BonoboUIComponent *uic,
                     NotHereApplet     *applet, 
                     const gchar       *verb_name);

static const BonoboUIVerb nothere_applet_menu_verbs [] = {
    BONOBO_UI_UNSAFE_VERB ("about", nothere_applet_about_cb),
    BONOBO_UI_VERB_END
};

static const char* authors[] = {
    "Raphaël Slinckx <raphael@slinckx.net>", 
    NULL
};

static void
nothere_applet_class_init (NotHereAppletClass *class)
{
    GTK_OBJECT_CLASS (class)->destroy = nothere_applet_destroy;
}

static void
nothere_applet_init (NotHereApplet *applet)
{
    applet->presence_chooser = empathy_presence_chooser_new ();
    gtk_widget_show (applet->presence_chooser);

    gtk_container_add (GTK_CONTAINER (applet), applet->presence_chooser);

    panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
    panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
}

static void
nothere_applet_destroy (GtkObject *object)
{
    NotHereApplet *applet = NOTHERE_APPLET (object);

    applet->presence_chooser = NULL;

    (* GTK_OBJECT_CLASS (nothere_applet_parent_class)->destroy) (object);
}

static void
nothere_applet_about_cb (BonoboUIComponent *uic, 
             NotHereApplet     *applet, 
             const gchar       *verb_name)
{
    gtk_show_about_dialog (NULL,
                   "name", "Presence", 
                   "version", PACKAGE_VERSION,
                   "copyright", "Copyright \xc2\xa9 2007 Raphaël Slinckx",
                   "comments", _("Set your own presence"),
                   "authors", authors,
                   "logo-icon-name", "stock_people",
                   NULL);
}

static gboolean
nothere_applet_factory (PanelApplet *applet, 
            const gchar *iid, 
            gpointer     data)
{
    if (strcmp (iid, "OAFIID:GNOME_NotHere_Applet") != 0) {
        return FALSE;
    }
    
    /* Set up the menu */
    panel_applet_setup_menu_from_file (applet,
                       PKGDATADIR,
                       "GNOME_NotHere_Applet.xml",
                       NULL,
                       nothere_applet_menu_verbs,
                       applet);

    gtk_widget_show (GTK_WIDGET (applet));
    return TRUE;
}

PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotHere_Applet_Factory",
                 NOTHERE_TYPE_APPLET,
                 "Presence", PACKAGE_VERSION,
                 nothere_applet_factory,
                 NULL);