2 linphone, gtk-glade interface.
3 Copyright (C) 2008 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (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.
22 static void run_gtk(){
23 while (gtk_events_pending ())
24 gtk_main_iteration ();
28 void *linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, const char *purpose, float progress){
31 case LinphoneWaitingStart:
33 w=linphone_gtk_create_window("waiting");
34 gtk_window_set_transient_for(GTK_WINDOW(w),GTK_WINDOW(linphone_gtk_get_main_window()));
35 gtk_window_set_position(GTK_WINDOW(w),GTK_WIN_POS_CENTER_ON_PARENT);
37 gtk_progress_bar_set_text(
38 GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")),
42 /*g_message("Creating waiting window");*/
47 case LinphoneWaitingProgress:
51 gtk_progress_bar_set_fraction(
52 GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")),
57 gtk_progress_bar_pulse(
58 GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar"))
61 /*g_message("Updating progress");*/
67 case LinphoneWaitingFinished:
70 gtk_widget_destroy(w);
79 GdkPixbuf *_gdk_pixbuf_new_from_memory_at_scale(const void *data, gint len, gint w, gint h, gboolean preserve_ratio){
80 GInputStream *stream=g_memory_input_stream_new_from_data (data,len,NULL);
83 GdkPixbuf *pbuf=gdk_pixbuf_new_from_stream_at_scale (stream,w,h,preserve_ratio,NULL,&error);
84 g_input_stream_close(stream,NULL,NULL);
85 g_object_unref(G_OBJECT(stream));
87 g_warning("Could not open image from memory");
92 GtkWidget * _gtk_image_new_from_memory_at_scale(const void *data, gint len, gint w, gint h, gboolean preserve_ratio){
94 GdkPixbuf *pbuf=_gdk_pixbuf_new_from_memory_at_scale(data,len,w,h,preserve_ratio);
95 if (pbuf==NULL) return NULL;
96 image=gtk_image_new_from_pixbuf(pbuf);
97 g_object_unref(G_OBJECT(pbuf));
101 void linphone_gtk_reload_sound_devices(void){
102 GtkWidget *mw=linphone_gtk_get_main_window();
103 GtkWidget *pb=(GtkWidget*)g_object_get_data(G_OBJECT(mw),"parameters");
104 linphone_core_reload_sound_devices(linphone_gtk_get_core());
105 linphone_gtk_fill_soundcards(pb);
108 void linphone_gtk_reload_video_devices(void){
109 GtkWidget *mw=linphone_gtk_get_main_window();
110 GtkWidget *pb=(GtkWidget*)g_object_get_data(G_OBJECT(mw),"parameters");
111 linphone_core_reload_video_devices(linphone_gtk_get_core());
112 linphone_gtk_fill_webcams(pb);
115 #ifdef HAVE_LIBUDEV_H
117 static struct udev *udevroot=NULL;
118 static struct udev_monitor *monitor=NULL;
119 static GIOChannel *monitor_channel=NULL;
120 static guint monitor_src_id;
124 static gboolean on_monitor_data(GIOChannel *chan, GIOCondition cond, void *userdata){
125 struct udev_device *dev=udev_monitor_receive_device(monitor);
126 const char *subsys=udev_device_get_subsystem(dev);
127 const char *type=udev_device_get_action(dev);
128 g_message("USB event arrived for class %s of action type %s",subsys,type);
129 if (strcmp(subsys,"sound")==0) linphone_gtk_reload_sound_devices();
130 if (strcmp(subsys,"video4linux")==0) linphone_gtk_reload_video_devices();
131 udev_device_unref(dev);
135 void linphone_gtk_monitor_usb(void){
138 if (!udevroot) return;
139 monitor=udev_monitor_new_from_netlink(udevroot,"udev");
140 udev_monitor_filter_add_match_subsystem_devtype(monitor,"sound",NULL);
141 udev_monitor_filter_add_match_subsystem_devtype(monitor,"video4linux",NULL);
142 fd=udev_monitor_get_fd(monitor);
143 monitor_channel=g_io_channel_unix_new(fd);
144 monitor_src_id=g_io_add_watch(monitor_channel,G_IO_IN,on_monitor_data,NULL);
145 udev_monitor_enable_receiving(monitor);
148 void linphone_gtk_unmonitor_usb(void){
149 if (monitor) udev_monitor_unref(monitor);
150 if (udevroot) udev_unref(udevroot);
151 if (monitor_channel) {
152 g_source_remove(monitor_src_id);
153 g_io_channel_unref(monitor_channel);
159 void linphone_gtk_monitor_usb(void){
161 void linphone_gtk_unmonitor_usb(void){