1
/***************************************************************************
2
applet.c - Applet code for linphone's gnome
5
begin : Sat Dec 14 2002
6
copyright : (C) 2001 by Simon Morlat
7
email : simon.morlat@linphone.org
8
***************************************************************************/
10
/***************************************************************************
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
17
***************************************************************************/
21
#include <panel-applet.h>
23
#define get_uiobj() (uiobj)
28
static int firstime=1;
29
static gulong signal_ref;
30
static GtkWidget *applet_button=NULL;
31
static GdkPixbuf *original_icon=NULL;
32
static GtkWidget *icon=NULL;
34
void draw_icon(GtkWidget *button, int size)
37
if (original_icon==NULL){
38
original_icon=gdk_pixbuf_new_from_file(PACKAGE_DATA_DIR "/pixmaps/linphone/linphone2.xpm",
40
g_return_if_fail( original_icon!=NULL);
43
gtk_container_remove(GTK_CONTAINER(button),icon);
44
gtk_widget_destroy(icon);
46
resized=gdk_pixbuf_scale_simple(original_icon,size,size,GDK_INTERP_BILINEAR);
47
g_return_if_fail(resized!=NULL);
48
icon=gtk_image_new_from_pixbuf(resized);
49
g_return_if_fail(icon!=NULL);
50
gdk_pixbuf_unref(resized);
51
gtk_container_add(GTK_CONTAINER(button),icon);
52
gtk_widget_show(icon);
55
void linphone_applet_about_cb(gpointer p)
58
about2 = create_about2 ();
59
gtk_widget_show (about2);
64
static void applet_change_pixel_size(GtkWidget *applet, int size)
66
g_return_if_fail(applet_button!=NULL);
67
draw_icon(applet_button,size);
70
static void applet_destroy_cb(GtkWidget *widget, gpointer data)
72
if (get_uiobj()->main_window.window!=NULL){
73
gtk_widget_destroy(get_uiobj()->main_window.window);
75
linphone_gnome_uninit(get_uiobj());
79
gui_destroy_cb (GtkWidget *widget, gpointer data)
81
linphone_gnome_ui_uninit(get_uiobj());
86
static gboolean button_press_cb(GtkWidget *applet, GdkEventButton* event, gpointer data)
88
if (event->button!=1) return FALSE;
90
g_signal_handlers_disconnect_by_func(G_OBJECT(get_uiobj()->main_window.window),
91
G_CALLBACK(gui_destroy_cb),NULL);
92
linphone_gnome_ui_hide(get_uiobj());
96
linphone_gnome_ui_show(get_uiobj());
97
signal_ref=g_signal_connect(G_OBJECT(get_uiobj()->main_window.window),
99
G_CALLBACK(gui_destroy_cb),NULL);
105
const BonoboUIVerb linphone_applet_menu_verbs [] = {
106
BONOBO_UI_UNSAFE_VERB ("About", linphone_applet_about_cb),
111
linphone_applet_fill (PanelApplet *applet)
113
gint size=panel_applet_get_size(applet);
117
applet_button=gtk_frame_new(NULL);
118
gtk_container_add(GTK_CONTAINER(applet),applet_button);
119
gtk_widget_show(applet_button);
121
draw_icon(applet_button,size);
123
g_signal_connect(G_OBJECT(applet),"button-press-event",G_CALLBACK(button_press_cb),NULL);
126
g_signal_connect(G_OBJECT(applet),"change_size",
127
G_CALLBACK(applet_change_pixel_size),
131
g_signal_connect (G_OBJECT (applet), "destroy",
132
G_CALLBACK (applet_destroy_cb), NULL);
134
//sizehint = panel_applet_get_size (PANEL_APPLET (applet));
135
panel_applet_setup_menu_from_file (applet,
137
"GNOME_LinphoneApplet.xml",
139
linphone_applet_menu_verbs,
142
/* tracing for osip */
143
TRACE_INITIALIZE(5,stdout);
145
linphone_gnome_init(&ui,&core);
146
gtk_widget_show_all (GTK_WIDGET (applet));
153
linphone_applet_factory (PanelApplet *applet,
158
static int instances=0;
160
if (!strcmp (iid, "OAFIID:GNOME_LinphoneApplet")){
162
dialog = gtk_message_dialog_new (GTK_WINDOW(applet),
163
GTK_DIALOG_DESTROY_WITH_PARENT,
166
(const gchar*) _("Cannot run multiples instances of the linphone applet."));
167
/* Destroy the dialog when the user responds to it (e.g. clicks a button) */
168
g_signal_connect_swapped (G_OBJECT (dialog), "response",
169
G_CALLBACK (gtk_widget_destroy),
171
gtk_widget_show(GTK_WIDGET(dialog));
174
retval = linphone_applet_fill (applet);
179
#define GNOMELOCALEDIR PACKAGE_LOCALE_DIR
181
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_LinphoneApplet_Factory",
185
linphone_applet_factory,