Tagged for release 2.26.0.
[empathy-mirror.git] / nothere / src / nothere-applet.c
blob243272e67df10723aeef6f5b208ec67dedd95c4c
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>
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.
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.
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.
19 * Authors: Raphaël Slinckx <raphael@slinckx.net>
22 #include "config.h"
24 #include <string.h>
26 #include <glib/gi18n.h>
27 #include <gtk/gtk.h>
28 #include <bonobo/bonobo-ui-component.h>
30 #include <libmissioncontrol/mission-control.h>
31 #include <libempathy-gtk/empathy-presence-chooser.h>
32 #include <libempathy-gtk/empathy-ui-utils.h>
34 #include "nothere-applet.h"
36 G_DEFINE_TYPE(NotHereApplet, nothere_applet, PANEL_TYPE_APPLET)
38 static void nothere_applet_destroy (GtkObject *object);
39 static void nothere_applet_about_cb (BonoboUIComponent *uic,
40 NotHereApplet *applet,
41 const gchar *verb_name);
43 static const BonoboUIVerb nothere_applet_menu_verbs [] = {
44 BONOBO_UI_UNSAFE_VERB ("about", nothere_applet_about_cb),
45 BONOBO_UI_VERB_END
48 static const char* authors[] = {
49 "Raphaël Slinckx <raphael@slinckx.net>",
50 NULL
53 static void
54 nothere_applet_class_init (NotHereAppletClass *class)
56 GTK_OBJECT_CLASS (class)->destroy = nothere_applet_destroy;
58 empathy_gtk_init ();
61 static gboolean
62 do_not_eat_button_press (GtkWidget *widget,
63 GdkEventButton *event)
65 if (event->button != 1) {
66 g_signal_stop_emission_by_name (widget, "button_press_event");
69 return FALSE;
72 static void
73 nothere_applet_init (NotHereApplet *applet)
75 applet->presence_chooser = empathy_presence_chooser_new ();
76 g_signal_connect (G_OBJECT (applet->presence_chooser), "button_press_event",
77 G_CALLBACK (do_not_eat_button_press), NULL);
79 gtk_widget_show (applet->presence_chooser);
81 gtk_container_add (GTK_CONTAINER (applet), applet->presence_chooser);
83 panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
84 panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
87 static void
88 nothere_applet_destroy (GtkObject *object)
90 NotHereApplet *applet = NOTHERE_APPLET (object);
92 applet->presence_chooser = NULL;
94 (* GTK_OBJECT_CLASS (nothere_applet_parent_class)->destroy) (object);
97 static void
98 nothere_applet_about_cb (BonoboUIComponent *uic,
99 NotHereApplet *applet,
100 const gchar *verb_name)
102 gtk_show_about_dialog (NULL,
103 "name", "Presence",
104 "version", PACKAGE_VERSION,
105 "copyright", "Copyright \xc2\xa9 2007 Raphaël Slinckx",
106 "comments", _("Set your own presence"),
107 "authors", authors,
108 "logo-icon-name", "stock_people",
109 NULL);
112 static gboolean
113 nothere_applet_factory (PanelApplet *applet,
114 const gchar *iid,
115 gpointer data)
117 if (strcmp (iid, "OAFIID:GNOME_NotHere_Applet") != 0) {
118 return FALSE;
121 /* Set up the menu */
122 panel_applet_setup_menu_from_file (applet,
123 PKGDATADIR,
124 "GNOME_NotHere_Applet.xml",
125 NULL,
126 nothere_applet_menu_verbs,
127 applet);
129 gtk_widget_show (GTK_WIDGET (applet));
130 return TRUE;
133 PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotHere_Applet_Factory",
134 NOTHERE_TYPE_APPLET,
135 "Presence", PACKAGE_VERSION,
136 nothere_applet_factory,
137 NULL);