diff --git a/sflphone-client-gnome/Makefile.am b/sflphone-client-gnome/Makefile.am index 47bb88964f5c83a99f19899f9227d279eb1befb8..7b944d233160c5d75d56f3f75104a4fbe54ca3fc 100644 --- a/sflphone-client-gnome/Makefile.am +++ b/sflphone-client-gnome/Makefile.am @@ -2,6 +2,8 @@ SUBDIRS = src pixmaps tests man po doc ACLOCAL_AMFLAGS = -I m4 +GCONFTOOL=gconftool-2 + GNOME_DOC=gnome-doc-utils.make log4crc_DATA = log4crc @@ -10,10 +12,16 @@ log4crcdir = $(datadir)/sflphone uidir=$(datadir)/sflphone/ui ui_DATA=src/ui.xml -EXTRA_DIST = $(log4crc_DATA) sflphone.desktop.in $(GNOME_DOC) m4 $(UI_DATA) +schemadir = @GCONF_SCHEMA_FILE_DIR@ +schema_DATA = sflphone-client-gnome.schemas + +EXTRA_DIST = $(log4crc_DATA) sflphone.desktop.in $(GNOME_DOC) m4 $(UI_DATA) $(schema_DATA) appsdir = $(datadir)/applications apps_in_files = sflphone.desktop.in apps_DATA = $(apps_in_files:.desktop.in=.desktop) #@INTLTOOL_DESKTOP_RULE@ -DISTCLEANFILES= sflphone.desktop $(GNOME_DOC) +DISTCLEANFILES= sflphone.desktop $(GNOME_DOC) + +install-data-local: + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(schema_DATA) diff --git a/sflphone-client-gnome/configure.ac b/sflphone-client-gnome/configure.ac index ff7a520e166c96b3aea26f175869c3fe04d064ae..44f118f5391ac8dff8b6841324c886d691fe6f6d 100644 --- a/sflphone-client-gnome/configure.ac +++ b/sflphone-client-gnome/configure.ac @@ -32,6 +32,9 @@ AC_PROG_INSTALL AC_STDC_HEADERS AC_PROG_LIBTOOL +dnl GCONF utilities +AM_GCONF_SOURCE_2 + dnl Check for log4c AC_CHECK_HEADERS(log4c.h, have_log4c=true, have_log4c=false) if ! $have_log4c; then diff --git a/sflphone-client-gnome/sflphone-client-gnome.schemas b/sflphone-client-gnome/sflphone-client-gnome.schemas new file mode 100644 index 0000000000000000000000000000000000000000..cda7c5e3a686e440b7e751b44252430400d704c8 --- /dev/null +++ b/sflphone-client-gnome/sflphone-client-gnome.schemas @@ -0,0 +1,69 @@ +<gconfschemafile> + <schemalist> + + <schema> + <key>/schemas/apps/sflphone-client-gnome/state/window_width</key> + <applyto>/apps/sflphone-client-gnome/state/window_width</applyto> + <owner>sflphone-client-gnome</owner> + <type>int</type> + <default>240</default> + <locale name="C"> + <short>Main window width</short> + <long>Main window width.</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/sflphone-client-gnome/state/window_position_x</key> + <applyto>/apps/sflphone-client-gnome/state/window_position_x</applyto> + <owner>sflphone-client-gnome</owner> + <type>int</type> + <default>0</default> + <locale name="C"> + <short>Main window X position</short> + <long>Main window X position.</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/sflphone-client-gnome/state/window_position_y</key> + <applyto>/apps/sflphone-client-gnome/state/window_position_y</applyto> + <owner>sflphone-client-gnome</owner> + <type>int</type> + <default>0</default> + <locale name="C"> + <short>Main window Y position</short> + <long>Main window Y position.</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/sflphone-client-gnome/state/window_height</key> + <applyto>/apps/sflphone-client-gnome/state/window_height</applyto> + <owner>sflphone-client-gnome</owner> + <type>int</type> + <default>320</default> + <locale name="C"> + <short>Main window height</short> + <long>Main window height.</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/sflphone-client-gnome/state/dialpad</key> + <applyto>/apps/sflphone-client-gnome/state/dialpad</applyto> + <owner>sflphone-client-gnome</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Display dialpad</short> + <long>Display dialpad.</long> + </locale> + </schema> + + + + </schemalist> +</gconfschemafile> diff --git a/sflphone-client-gnome/src/Makefile.am b/sflphone-client-gnome/src/Makefile.am index 30e2a818e627c7026da2018fa058ffb532345f00..3ce309ce5ac8cf054dfe0ebfb957a7744b33860a 100644 --- a/sflphone-client-gnome/src/Makefile.am +++ b/sflphone-client-gnome/src/Makefile.am @@ -25,12 +25,13 @@ sflphone_client_gnome_SOURCES = \ statusicon.c \ codeclist.c \ reqaccount.c \ - shortcuts.c + shortcuts.c \ + eel-gconf-extensions.c noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \ reqaccount.h errors.h sflphone_const.h uimanager.h \ accountlist.h sliders.h statusicon.h callable_obj.h conference_obj.h \ - shortcuts.h + shortcuts.h eel-gconf-extensions.h sflphone_client_gnome_LDADD = $(DEPS_LIBS) $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(LIBSEXY_LIBS) $(LOG4C) diff --git a/sflphone-client-gnome/src/config/audioconf.c b/sflphone-client-gnome/src/config/audioconf.c index bab96d27e7695ffc761541135ba5af91fe791516..d27b64d2f246e92d73b701036bafc14fbf3a4199 100644 --- a/sflphone-client-gnome/src/config/audioconf.c +++ b/sflphone-client-gnome/src/config/audioconf.c @@ -767,7 +767,7 @@ select_audio_manager( void ) if (gtk_toggle_action_get_active ( GTK_TOGGLE_ACTION (volumeToggle))) { main_window_volume_controls(FALSE); - dbus_set_volume_controls (FALSE); + eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, FALSE); gtk_toggle_action_set_active ( GTK_TOGGLE_ACTION (volumeToggle), FALSE); } gtk_action_set_sensitive (GTK_ACTION (volumeToggle), FALSE); diff --git a/sflphone-client-gnome/src/config/preferencesdialog.c b/sflphone-client-gnome/src/config/preferencesdialog.c index 01be2abd630bcbc1aaac1139cb545c601e2cffea..ff68a31c7af95928bd411b15cbf9e38a2fd4da02 100644 --- a/sflphone-client-gnome/src/config/preferencesdialog.c +++ b/sflphone-client-gnome/src/config/preferencesdialog.c @@ -82,21 +82,24 @@ set_md5_hash_cb (GtkWidget *widget UNUSED, gpointer data UNUSED) static void start_hidden (void) { - dbus_start_hidden (); + gboolean currentstate = eel_gconf_get_integer (START_HIDDEN); + eel_gconf_set_integer (START_HIDDEN, !currentstate); } static void set_popup_mode (GtkWidget *widget, gpointer *userdata) { - if (dbus_popup_mode () || gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (widget))) - dbus_switch_popup_mode (); + gboolean currentstate = eel_gconf_get_integer (POPUP_ON_CALL); + if (currentstate || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + eel_gconf_set_integer (POPUP_ON_CALL, !currentstate); + } } void set_notif_level () { - dbus_set_notify (); + gboolean current_state = eel_gconf_get_integer (NOTIFY_ALL); + eel_gconf_set_integer (NOTIFY_ALL, !current_state); } static void @@ -112,7 +115,7 @@ history_enabled_cb (GtkWidget *widget) gtk_widget_set_sensitive (GTK_WIDGET (history_value), history_enabled); // Toggle it through D-Bus - dbus_set_history_enabled (); + eel_gconf_set_integer (HISTORY_ENABLED, !eel_gconf_get_integer (HISTORY_ENABLED)); } void @@ -135,8 +138,8 @@ void showstatusicon_cb (GtkWidget *widget, gpointer data) { currentstatus ? show_status_icon () : hide_status_icon (); - // Update through D-Bus - dbus_enable_status_icon (currentstatus ? "true" : "false"); + // Update through D-Bus + eel_gconf_set_integer (SHOW_STATUSICON, currentstatus); } @@ -145,7 +148,7 @@ create_general_settings () { GtkWidget *ret, *notifAll, *trayItem, *frame, *checkBoxWidget, *label, *table; - gboolean statusicon = FALSE; + gboolean statusicon; // Load history configuration history_load_configuration (); @@ -161,7 +164,7 @@ create_general_settings () // Notification All notifAll = gtk_check_button_new_with_mnemonic (_("_Enable notifications")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(notifAll), dbus_get_notify ()); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(notifAll), eel_gconf_get_integer (NOTIFY_ALL)); g_signal_connect(G_OBJECT( notifAll ) , "clicked" , G_CALLBACK( set_notif_level ) , NULL ); gtk_table_attach (GTK_TABLE(table), notifAll, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); @@ -171,10 +174,8 @@ create_general_settings () 1); gtk_box_pack_start (GTK_BOX(ret), frame, FALSE, FALSE, 0); - if (g_strcasecmp (dbus_is_status_icon_enabled (), "true") == 0) - statusicon = TRUE; - else - statusicon = FALSE; + // Whether or not displaying an icon in the system tray + statusicon = eel_gconf_get_integer (SHOW_STATUSICON); showstatusicon = gtk_check_button_new_with_mnemonic ( _("Show SFLphone in the system tray")); @@ -194,16 +195,19 @@ create_general_settings () gtk_table_attach (GTK_TABLE(table), neverpopupwindow, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); - // Toggle according to the user configuration - dbus_popup_mode () ? gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (popupwindow), TRUE) : gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (neverpopupwindow), TRUE); + // Toggle according to the user configuration + eel_gconf_get_integer (POPUP_ON_CALL) ? gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (popupwindow), + TRUE) : + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (neverpopupwindow), + TRUE); starthidden = gtk_check_button_new_with_mnemonic ( _("Hide SFLphone window on _startup")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(starthidden), - dbus_is_start_hidden ()); + eel_gconf_get_integer (START_HIDDEN)); g_signal_connect(G_OBJECT (starthidden) , "clicked" , G_CALLBACK( start_hidden ) , NULL); gtk_table_attach (GTK_TABLE(table), starthidden, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5); @@ -261,9 +265,7 @@ void history_load_configuration () { history_limit = dbus_get_history_limit (); - history_enabled = TRUE; - if (g_strcasecmp (dbus_get_history_enabled (), "false") == 0) - history_enabled = FALSE; + history_enabled = eel_gconf_get_integer (HISTORY_ENABLED); } /** diff --git a/sflphone-client-gnome/src/contacts/calllist.c b/sflphone-client-gnome/src/contacts/calllist.c index c5566261be350aa45e96e6d2e2eab331874e8ab1..10744e58ff0fb1c1548661fedceb5f4c9faef927 100644 --- a/sflphone-client-gnome/src/contacts/calllist.c +++ b/sflphone-client-gnome/src/contacts/calllist.c @@ -91,7 +91,7 @@ calllist_reset (calltab_t* tab) void calllist_add_history_entry (callable_obj_t *obj) { - if ( g_strcasecmp (dbus_get_history_enabled (), "true") == 0) + if (eel_gconf_get_integer (HISTORY_ENABLED)) { g_queue_push_tail (history->callQueue, (gpointer *) obj); calltree_add_call (history, obj, NULL); diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index dde1cae4c5e7345cf3c63ea8fadc546b0bc83c9b..6417d628fb4775731f2354fde2ac82ba910c61e6 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -989,7 +989,7 @@ void calltree_add_history_entry (callable_obj_t * c) DEBUG("calltree_add_history_entry %s", c->_callID); - if ( g_strcasecmp (dbus_get_history_enabled (), "false") == 0) + if (!eel_gconf_get_integer (HISTORY_ENABLED)) return; GdkPixbuf *pixbuf=NULL; diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 4aa9c393dfd0f66c7f2a7d5093958523dd60da2c..1722fba991f650a49183f965fb4bb337d5e8189c 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1733,32 +1733,6 @@ dbus_set_searchbar() } } -int -dbus_get_volume_controls() -{ - int state; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_volume_controls( - configurationManagerProxy, &state, &error); - if (error) - { - g_error_free(error); - } - return state; -} - -void -dbus_set_volume_controls(gboolean display) -{ - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_volume_controls( - configurationManagerProxy, display, &error); - if (error) - { - g_error_free(error); - } -} - void dbus_join_participant(const gchar* sel_callID, const gchar* drag_callID) { @@ -1907,32 +1881,6 @@ dbus_set_history_limit(const guint days) } } -void -dbus_set_history_enabled() -{ - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_history_enabled( - configurationManagerProxy, &error); - if (error) - { - g_error_free(error); - } -} - -gchar* -dbus_get_history_enabled() -{ - gchar* state; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_history_enabled( - configurationManagerProxy, &state, &error); - if (error) - { - g_error_free(error); - } - return state; -} - guint dbus_get_history_limit(void) { @@ -1947,96 +1895,6 @@ dbus_get_history_limit(void) return (guint) days; } -void -dbus_start_hidden(void) -{ - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_start_hidden( - configurationManagerProxy, &error); - if (error) - { - g_error_free(error); - } -} - -int -dbus_is_start_hidden(void) -{ - GError* error = NULL; - int state; - org_sflphone_SFLphone_ConfigurationManager_is_start_hidden( - configurationManagerProxy, &state, &error); - if (error) - { - g_error_free(error); - } - return state; -} - -int -dbus_popup_mode(void) -{ - GError* error = NULL; - int state; - org_sflphone_SFLphone_ConfigurationManager_popup_mode( - configurationManagerProxy, &state, &error); - if (error) - { - g_error_free(error); - } - return state; -} - -void -dbus_switch_popup_mode(void) -{ - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode( - configurationManagerProxy, &error); - if (error) - { - g_error_free(error); - } -} - -void -dbus_set_notify(void) -{ - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_notify( - configurationManagerProxy, &error); - if (error) - { - g_error_free(error); - } -} - -guint -dbus_get_notify(void) -{ - gint level; - GError* error = NULL; - if (!org_sflphone_SFLphone_ConfigurationManager_get_notify( - configurationManagerProxy, &level, &error)) - { - if (error->domain == DBUS_GERROR && error->code - == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_notify) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR ("Error while calling get_notify: %s", error->message); - } - g_error_free(error); - return 0; - } - else - { - return (guint) level; - } -} - void dbus_set_audio_manager(int api) { @@ -2686,32 +2544,3 @@ dbus_set_shortcuts(GHashTable * shortcuts) } } - -void dbus_enable_status_icon (const gchar *value) { - - GError *error = NULL; - - org_sflphone_SFLphone_ConfigurationManager_enable_status_icon (configurationManagerProxy, value, &error); - - if (error != NULL) { - ERROR ("Failed to call enable_status_icon on ConfigurationManager: %s", - error->message); - g_error_free (error); - } -} - -gchar* dbus_is_status_icon_enabled (void) { - - GError *error = NULL; - gchar *value = NULL; - - org_sflphone_SFLphone_ConfigurationManager_is_status_icon_enabled (configurationManagerProxy, &value, &error); - - if (error != NULL) { - ERROR ("Failed to call is_status_icon_enabled on ConfigurationManager: %s", - error->message); - g_error_free (error); - } - return value; -} - diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index bf497ff5a4873900611f498efee80d7def886ea4..d028b66ae474c33274fd7c9232d79bc63966a5da 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -414,24 +414,6 @@ void dbus_set_searchbar( ); */ int dbus_get_searchbar( void ); -/** - * ConfigurationManager - Set the volume controls visible or not - */ -void dbus_set_volume_controls (gboolean display); - -/** - * ConfigurationManager - Tells if the user wants to display the volume controls or not - * @return int 1 if the controls have to be displayed - * 0 otherwise - */ -int dbus_get_volume_controls( void ); - -/** - * ConfigurationManager - Configure the start-up option - * At startup, SFLphone can be displayed or start hidden in the system tray - */ -void dbus_start_hidden( void ); - /** * ConfigurationManager - Gives the maximum number of days the user wants to have in the history * @return double The maximum number of days @@ -443,31 +425,6 @@ guint dbus_get_history_limit( void ); */ void dbus_set_history_limit (const guint days); -void dbus_set_history_enabled (void); - -gchar* dbus_get_history_enabled (void); - -/** - * ConfigurationManager - Configure the start-up option - * @return int 1 if SFLphone should start in the system tray - * 0 otherwise - */ -int dbus_is_start_hidden( void ); - -/** - * ConfigurationManager - Configure the popup behaviour - * When SFLphone is in the system tray, you can configure when it popups - * Never or only on incoming calls - */ -void dbus_switch_popup_mode( void ); - -/** - * ConfigurationManager - Configure the popup behaviour - * @return int 1 if it should popup on incoming calls - * 0 if it should never popups - */ -int dbus_popup_mode( void ); - /** * ConfigurationManager - Returns the selected audio manager * @return int 0 ALSA @@ -482,18 +439,6 @@ int dbus_get_audio_manager( void ); */ void dbus_set_audio_manager( int api ); -/** - * ConfigurationManager - Configure the notification level - * @return int 0 disable - * 1 enable - */ -guint dbus_get_notify( void ); - -/** - * ConfigurationManager - Configure the notification level - */ -void dbus_set_notify( void ); - /** * ConfigurationManager - Start a tone when a new call is open and no numbers have been dialed * @param start 1 to start @@ -639,7 +584,4 @@ void dbus_set_window_position_y (const guint posy); GHashTable* dbus_get_shortcuts(void); void dbus_set_shortcuts(GHashTable * shortcuts); -void dbus_enable_status_icon (const gchar*); -gchar* dbus_is_status_icon_enabled (void); - #endif diff --git a/sflphone-client-gnome/src/eel-gconf-extensions.c b/sflphone-client-gnome/src/eel-gconf-extensions.c new file mode 100644 index 0000000000000000000000000000000000000000..2bc4ab804f5d6d16e3bf586a9de8b189cba02fb0 --- /dev/null +++ b/sflphone-client-gnome/src/eel-gconf-extensions.c @@ -0,0 +1,606 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eel-gconf-extensions.c - Stuff to make GConf easier to use. + + Copyright (C) 2000, 2001 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include <stdlib.h> +#include <config.h> +#include "eel-gconf-extensions.h" + +#include <gconf/gconf-client.h> +#include <gconf/gconf.h> +#include <gtk/gtkwidget.h> +#include <libgnome/gnome-i18n.h> +#include <gtk/gtkmessagedialog.h> + +static GConfClient *global_gconf_client = NULL; + +static void +global_client_free (void) +{ + if (global_gconf_client == NULL) { + return; + } + + g_object_unref (G_OBJECT (global_gconf_client)); + global_gconf_client = NULL; +} + +/* Public */ +GConfClient * +eel_gconf_client_get_global (void) +{ + /* Initialize gconf if needed */ + if (!gconf_is_initialized ()) { + char *argv[] = { "eel-preferences", NULL }; + GError *error = NULL; + char *teststr; + + if (!gconf_init (1, argv, &error)) { + if (eel_gconf_handle_error (&error)) { + return NULL; + } + } + + /* check if gconf schemas are working */ + teststr = gconf_client_get_string (eel_gconf_client_get_global(), + "/apps/gpdf/gconf_test", NULL); + if (!teststr) + { + GtkWidget *dialog; + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Cannot find a schema for gpdf preferences. \n" + "Check your gconf setup, look at gpdf FAQ for \n" + "more info")); + gtk_dialog_run (GTK_DIALOG (dialog)); + exit (0); + } + else + { + g_free (teststr); + } + + } + + if (global_gconf_client == NULL) { + global_gconf_client = gconf_client_get_default (); + g_atexit (global_client_free); + } + + return global_gconf_client; +} + +gboolean +eel_gconf_handle_error (GError **error) +{ + g_return_val_if_fail (error != NULL, FALSE); + + if (*error != NULL) { + g_warning (_("GConf error:\n %s"), (*error)->message); + g_error_free (*error); + *error = NULL; + + return TRUE; + } + + return FALSE; +} + +void +eel_gconf_set_boolean (const char *key, + gboolean boolean_value) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_set_bool (client, key, boolean_value, &error); + eel_gconf_handle_error (&error); +} + +gboolean +eel_gconf_get_boolean (const char *key) +{ + gboolean result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, FALSE); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); + + result = gconf_client_get_bool (client, key, &error); + + if (eel_gconf_handle_error (&error)) { + result = FALSE; + } + + return result; +} + +void +eel_gconf_set_integer (const char *key, + int int_value) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_set_int (client, key, int_value, &error); + eel_gconf_handle_error (&error); +} + +int +eel_gconf_get_integer (const char *key) +{ + int result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, 0); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, 0); + + result = gconf_client_get_int (client, key, &error); + + if (eel_gconf_handle_error (&error)) { + result = 0; + } + + return result; +} + +void +eel_gconf_set_float (const char *key, + gfloat float_value) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_set_float (client, key, float_value, &error); + eel_gconf_handle_error (&error); +} + +gfloat +eel_gconf_get_float (const char *key) +{ + gfloat result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, 0); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, 0); + + result = gconf_client_get_float (client, key, &error); + + if (eel_gconf_handle_error (&error)) { + result = 0; + } + + return result; +} + +void +eel_gconf_set_string (const char *key, + const char *string_value) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + g_return_if_fail (string_value != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_set_string (client, key, string_value, &error); + eel_gconf_handle_error (&error); +} + +void +eel_gconf_unset (const char *key) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_unset (client, key, &error); + eel_gconf_handle_error (&error); +} + +char * +eel_gconf_get_string (const char *key) +{ + char *result; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, NULL); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); + + result = gconf_client_get_string (client, key, &error); + + if (eel_gconf_handle_error (&error)) { + result = g_strdup (""); + } + + return result; +} + +void +eel_gconf_set_string_list (const char *key, + const GSList *slist) +{ + GConfClient *client; + GError *error; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + error = NULL; + gconf_client_set_list (client, key, GCONF_VALUE_STRING, + /* Need cast cause of GConf api bug */ + (GSList *) slist, + &error); + eel_gconf_handle_error (&error); +} + +GSList * +eel_gconf_get_string_list (const char *key) +{ + GSList *slist; + GConfClient *client; + GError *error; + + g_return_val_if_fail (key != NULL, NULL); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); + + error = NULL; + slist = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error); + if (eel_gconf_handle_error (&error)) { + slist = NULL; + } + + return slist; +} + +/* This code wasn't part of the original eel-gconf-extensions.c */ +void +eel_gconf_set_integer_list (const char *key, + const GSList *slist) +{ + GConfClient *client; + GError *error; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + error = NULL; + gconf_client_set_list (client, key, GCONF_VALUE_INT, + /* Need cast cause of GConf api bug */ + (GSList *) slist, + &error); + eel_gconf_handle_error (&error); +} + +GSList * +eel_gconf_get_integer_list (const char *key) +{ + GSList *slist; + GConfClient *client; + GError *error; + + g_return_val_if_fail (key != NULL, NULL); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); + + error = NULL; + slist = gconf_client_get_list (client, key, GCONF_VALUE_INT, &error); + if (eel_gconf_handle_error (&error)) { + slist = NULL; + } + + return slist; +} +/* End of added code */ + +gboolean +eel_gconf_is_default (const char *key) +{ + gboolean result; + GConfValue *value; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, FALSE); + + value = gconf_client_get_without_default (eel_gconf_client_get_global (), key, &error); + + if (eel_gconf_handle_error (&error)) { + if (value != NULL) { + gconf_value_free (value); + } + return FALSE; + } + + result = (value == NULL); + + if (value != NULL) { + gconf_value_free (value); + } + + + return result; +} + +gboolean +eel_gconf_monitor_add (const char *directory) +{ + GError *error = NULL; + GConfClient *client; + + g_return_val_if_fail (directory != NULL, FALSE); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); + + gconf_client_add_dir (client, + directory, + GCONF_CLIENT_PRELOAD_NONE, + &error); + + if (eel_gconf_handle_error (&error)) { + return FALSE; + } + + return TRUE; +} + +gboolean +eel_gconf_monitor_remove (const char *directory) +{ + GError *error = NULL; + GConfClient *client; + + if (directory == NULL) { + return FALSE; + } + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); + + gconf_client_remove_dir (client, + directory, + &error); + + if (eel_gconf_handle_error (&error)) { + return FALSE; + } + + return TRUE; +} + +void +eel_gconf_suggest_sync (void) +{ + GConfClient *client; + GError *error = NULL; + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_suggest_sync (client, &error); + eel_gconf_handle_error (&error); +} + +GConfValue* +eel_gconf_get_value (const char *key) +{ + GConfValue *value = NULL; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, NULL); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, NULL); + + value = gconf_client_get (client, key, &error); + + if (eel_gconf_handle_error (&error)) { + if (value != NULL) { + gconf_value_free (value); + value = NULL; + } + } + + return value; +} + +void +eel_gconf_set_value (const char *key, const GConfValue *value) +{ + GConfClient *client; + GError *error = NULL; + + g_return_if_fail (key != NULL); + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_set (client, key, value, &error); + + if (eel_gconf_handle_error (&error)) { + return; + } +} + +gboolean +eel_gconf_key_exists (const char *key) +{ + GConfValue *value = NULL; + GConfClient *client; + GError *error = NULL; + gboolean error_occurred; + gboolean value_found; + + g_return_val_if_fail (key != NULL, FALSE); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, FALSE); + + value = gconf_client_get (client, key, &error); + + value_found = (value != NULL); + error_occurred = (error != NULL); + + eel_gconf_value_free (value); + if (error != NULL) { + g_error_free (error); + } + + return (!error_occurred && value_found); +} + +void +eel_gconf_value_free (GConfValue *value) +{ + if (value == NULL) { + return; + } + + gconf_value_free (value); +} + +guint +eel_gconf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data) +{ + guint notification_id; + GConfClient *client; + GError *error = NULL; + + g_return_val_if_fail (key != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + g_return_val_if_fail (notification_callback != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + + client = eel_gconf_client_get_global (); + g_return_val_if_fail (client != NULL, EEL_GCONF_UNDEFINED_CONNECTION); + + notification_id = gconf_client_notify_add (client, + key, + notification_callback, + callback_data, + NULL, + &error); + + if (eel_gconf_handle_error (&error)) { + if (notification_id != EEL_GCONF_UNDEFINED_CONNECTION) { + gconf_client_notify_remove (client, notification_id); + notification_id = EEL_GCONF_UNDEFINED_CONNECTION; + } + } + + return notification_id; +} + +void +eel_gconf_notification_remove (guint notification_id) +{ + GConfClient *client; + + if (notification_id == EEL_GCONF_UNDEFINED_CONNECTION) { + return; + } + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_notify_remove (client, notification_id); +} + +/* Simple wrapper for eel_gconf_notifier_add which + * adds the notifier id to the GList given as argument + * so that a call to gpdf_notification_free can remove the notifiers + */ +void +gpdf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data, + GList **notifiers) +{ + guint id = 0; + + id = eel_gconf_notification_add(key, + notification_callback, + callback_data); + if (notifiers != NULL) { + *notifiers = g_list_append(*notifiers, + (gpointer)id); + } +} + +/* Removes all the notifiers listed in notifiers */ +/* Frees the notifiers list */ +void +gpdf_notification_remove (GList **notifiers) +{ + g_list_foreach(*notifiers, + (GFunc)eel_gconf_notification_remove, + NULL); + g_list_free(*notifiers); + *notifiers = NULL; +} + + diff --git a/sflphone-client-gnome/src/eel-gconf-extensions.h b/sflphone-client-gnome/src/eel-gconf-extensions.h new file mode 100644 index 0000000000000000000000000000000000000000..f4afab26067c4f0c2116dc2964f0cf6d3844ea19 --- /dev/null +++ b/sflphone-client-gnome/src/eel-gconf-extensions.h @@ -0,0 +1,88 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eel-gconf-extensions.h - Stuff to make GConf easier to use. + + Copyright (C) 2000, 2001 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef EEL_GCONF_EXTENSIONS_H +#define EEL_GCONF_EXTENSIONS_H + +#include <glib/gerror.h> +#include <gconf/gconf.h> +#include <gconf/gconf-client.h> + +#ifdef __cplusplus +BEGIN_EXTERN_C +#endif + +#define EEL_GCONF_UNDEFINED_CONNECTION 0 + +GConfClient *eel_gconf_client_get_global (void); +gboolean eel_gconf_handle_error (GError **error); +void eel_gconf_set_boolean (const char *key, + gboolean boolean_value); +gboolean eel_gconf_get_boolean (const char *key); +int eel_gconf_get_integer (const char *key); +void eel_gconf_set_integer (const char *key, + int int_value); +gfloat eel_gconf_get_float (const char *key); +void eel_gconf_set_float (const char *key, + gfloat float_value); +char * eel_gconf_get_string (const char *key); +void eel_gconf_set_string (const char *key, + const char *string_value); +GSList * eel_gconf_get_string_list (const char *key); +void eel_gconf_set_string_list (const char *key, + const GSList *string_list_value); +gboolean eel_gconf_is_default (const char *key); +gboolean eel_gconf_monitor_add (const char *directory); +gboolean eel_gconf_monitor_remove (const char *directory); +void eel_gconf_suggest_sync (void); +GConfValue* eel_gconf_get_value (const char *key); +gboolean eel_gconf_value_is_equal (const GConfValue *a, + const GConfValue *b); +void eel_gconf_set_value (const char *key, + const GConfValue *value); +gboolean eel_gconf_key_exists (const char *key); + +void eel_gconf_value_free (GConfValue *value); +void eel_gconf_unset (const char *key); + +/* Functions which weren't part of the eel-gconf-extensions.h file from eel */ +GSList *eel_gconf_get_integer_list (const char *key); +void eel_gconf_set_integer_list (const char *key, + const GSList *slist); +void gpdf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data, + GList **notifiers); +void gpdf_notification_remove (GList **notifiers); +guint eel_gconf_notification_add (const char *key, + GConfClientNotifyFunc notification_callback, + gpointer callback_data); +void eel_gconf_notification_remove (guint notification_id); + +#ifdef __cplusplus +END_EXTERN_C +#endif + +#endif /* EEL_GCONF_EXTENSIONS_H */ + diff --git a/sflphone-client-gnome/src/main.c b/sflphone-client-gnome/src/main.c index 6ab9d8c8329698041ee2e5b4144393ec7ae11d87..38cb5cd3f7a05b423116e4727294c168277a414d 100644 --- a/sflphone-client-gnome/src/main.c +++ b/sflphone-client-gnome/src/main.c @@ -72,7 +72,6 @@ main (int argc, char *argv[]) { // Handle logging int i; - gboolean statusicon = FALSE; // Startup logging startup_logging (); @@ -117,13 +116,12 @@ main (int argc, char *argv[]) if (sflphone_init ()) { - if (g_strcasecmp (dbus_is_status_icon_enabled (), "true") == 0) - statusicon = TRUE; + if (eel_gconf_get_integer (SHOW_STATUSICON)) + show_status_icon (); - if (statusicon) show_status_icon (); create_main_window (); - if (statusicon && dbus_is_start_hidden ()) + if (eel_gconf_get_integer (SHOW_STATUSICON) && eel_gconf_get_integer (START_HIDDEN)) { gtk_widget_hide (GTK_WIDGET( get_main_window() )); set_minimized (TRUE); diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index 81fbe51c51167aeb705227f8fba2af19a6e6e3da..cf3ca817572c8c3fb16dfeaa2846c31a24459755 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -44,6 +44,7 @@ #include <widget/minidialog.h> #include <gtk/gtk.h> +#include <eel-gconf-extensions.h> /** Local variables */ GtkUIManager *ui_manager = NULL; @@ -58,460 +59,464 @@ GtkWidget * statusBar = NULL; GtkWidget * filterEntry = NULL; PidginScrollBook *embedded_error_notebook; -static gboolean -window_configure_cb (GtkWidget *win, GdkEventConfigure *event) -{ +/** + * Handle main window resizing + */ +static gboolean window_configure_cb (GtkWidget *win, GdkEventConfigure *event) { - int pos_x, pos_y; + int pos_x, pos_y; - dbus_set_window_width ((guint) event->width); - dbus_set_window_height ((guint) event->height); + eel_gconf_set_integer (CONF_MAIN_WINDOW_WIDTH, event->width); + eel_gconf_set_integer (CONF_MAIN_WINDOW_HEIGHT, event->height); - gtk_window_get_position (GTK_WINDOW (window), &pos_x, &pos_y); - dbus_set_window_position_x ((guint) pos_x); - dbus_set_window_position_y ((guint) pos_y); + gtk_window_get_position (GTK_WINDOW (window), &pos_x, &pos_y); + eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_X, pos_x); + eel_gconf_set_integer (CONF_MAIN_WINDOW_POSITION_Y, pos_y); - return FALSE; + return FALSE; } + /** * Minimize the main window. */ -static gboolean + static gboolean on_delete (GtkWidget * widget UNUSED, gpointer data UNUSED) { - if (g_strcasecmp (dbus_is_status_icon_enabled (), "true") == 0) { - gtk_widget_hide (GTK_WIDGET( get_main_window() )); - set_minimized (TRUE); - } - else { - sflphone_quit (); - } - return TRUE; + if (eel_gconf_get_integer (SHOW_STATUSICON)) { + gtk_widget_hide (GTK_WIDGET( get_main_window() )); + set_minimized (TRUE); + } + else { + sflphone_quit (); + } + return TRUE; } /** Ask the user if he wants to hangup current calls */ -gboolean + gboolean main_window_ask_quit () { - guint count = calllist_get_size (current_calls); - GtkWidget * dialog; - gint response; - gchar * question; + guint count = calllist_get_size (current_calls); + GtkWidget * dialog; + gint response; + gchar * question; - if (count == 1) - { - question = _("There is one call in progress."); - } - else - { - question = _("There are calls in progress."); - } + if (count == 1) + { + question = _("There is one call in progress."); + } + else + { + question = _("There are calls in progress."); + } - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), - GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s\n%s", - question, _("Do you still want to quit?") ); + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), + GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s\n%s", + question, _("Do you still want to quit?") ); - response = gtk_dialog_run (GTK_DIALOG (dialog)); + response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + gtk_widget_destroy (dialog); - return (response == GTK_RESPONSE_NO)? FALSE : TRUE ; + return (response == GTK_RESPONSE_NO)? FALSE : TRUE ; } -static gboolean + static gboolean on_key_released (GtkWidget *widget, GdkEventKey *event, gpointer user_data UNUSED) { - DEBUG("On key released from Main Window : %s", gtk_widget_get_name(widget)); - - if (focus_is_on_searchbar == FALSE) - { - // If a modifier key is pressed, it's a shortcut, pass along - if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK - || event->keyval == 60 || // < - event->keyval == 62 || // > - event->keyval == 34 || // " - event->keyval == 65289 || // tab - event->keyval == 65361 || // left arrow - event->keyval == 65363 || // right arrow - event->keyval >= 65470 || // F-keys - event->keyval == 32 // space - ) - return FALSE; - else - sflphone_keypad (event->keyval, event->string); - } - - return TRUE; + DEBUG("On key released from Main Window : %s", gtk_widget_get_name(widget)); + + if (focus_is_on_searchbar == FALSE) + { + // If a modifier key is pressed, it's a shortcut, pass along + if (event->state & GDK_CONTROL_MASK || event->state & GDK_MOD1_MASK + || event->keyval == 60 || // < + event->keyval == 62 || // > + event->keyval == 34 || // " + event->keyval == 65289 || // tab + event->keyval == 65361 || // left arrow + event->keyval == 65363 || // right arrow + event->keyval >= 65470 || // F-keys + event->keyval == 32 // space + ) + return FALSE; + else + sflphone_keypad (event->keyval, event->string); + } + + return TRUE; } -void + void focus_on_mainwindow_out () { - // gtk_widget_grab_focus(GTK_WIDGET(window)); + // gtk_widget_grab_focus(GTK_WIDGET(window)); } -void + void focus_on_mainwindow_in () { - // gtk_widget_grab_focus(GTK_WIDGET(window)); + // gtk_widget_grab_focus(GTK_WIDGET(window)); } -void + void create_main_window () { - GtkWidget *widget; - gchar *path; - GError *error = NULL; - gboolean ret; - const char *window_title = "SFLphone VoIP Client"; - int width, height, position_x, position_y; - - focus_is_on_calltree = FALSE; - focus_is_on_searchbar = FALSE; - - // Get configuration stored - width = dbus_get_window_width (); - height = dbus_get_window_height (); - position_x = dbus_get_window_position_x (); - position_y = dbus_get_window_position_y (); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - gtk_window_set_title (GTK_WINDOW (window), window_title); - gtk_window_set_default_size (GTK_WINDOW (window), width, height); - gtk_window_set_default_icon_from_file (LOGO, NULL); - gtk_window_set_position (GTK_WINDOW( window ), GTK_WIN_POS_MOUSE); - - /* Connect the destroy event of the window with our on_destroy function - * When the window is about to be destroyed we get a notificaiton and - * stop the main GTK loop - */ - g_signal_connect (G_OBJECT (window), "delete-event", - G_CALLBACK (on_delete), NULL); - - g_signal_connect (G_OBJECT (window), "key-release-event", - G_CALLBACK (on_key_released), NULL); - - g_signal_connect_after (G_OBJECT (window), "focus-in-event", - G_CALLBACK (focus_on_mainwindow_in), NULL); - - g_signal_connect_after (G_OBJECT (window), "focus-out-event", - G_CALLBACK (focus_on_mainwindow_out), NULL); - - g_signal_connect_object (G_OBJECT (window), "configure-event", - G_CALLBACK (window_configure_cb), NULL, 0); - - gtk_widget_set_name (window, "mainwindow"); - - ret = uimanager_new (&ui_manager); - if (!ret) - { - ERROR ("Could not load xml GUI\n"); - g_error_free (error); - exit (1); - } - - /* Create an accel group for window's shortcuts */ - gtk_window_add_accel_group (GTK_WINDOW(window), - gtk_ui_manager_get_accel_group (ui_manager)); - - vbox = gtk_vbox_new (FALSE /*homogeneous*/, 0 /*spacing*/); - subvbox = gtk_vbox_new (FALSE /*homogeneous*/, 5 /*spacing*/); - - create_menus (ui_manager, &widget); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, - 0 /*padding*/); - - create_toolbar_actions (ui_manager, &widget); - // Do not override GNOME user settings - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, - 0 /*padding*/); - - gtk_box_pack_start (GTK_BOX (vbox), current_calls->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_box_pack_start (GTK_BOX (vbox), history->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_box_pack_start (GTK_BOX (vbox), contacts->tree, TRUE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - - gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, - FALSE /*fill*/, 0 /*padding*/); - - embedded_error_notebook = PIDGIN_SCROLL_BOOK(pidgin_scroll_book_new()); - gtk_box_pack_start (GTK_BOX(subvbox), GTK_WIDGET(embedded_error_notebook), - FALSE, FALSE, 0); - - if (SHOW_VOLUME) - { - speaker_control = create_slider ("speaker"); - gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (speaker_control); - mic_control = create_slider ("mic"); - gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (mic_control); - } - - if (SHOW_DIALPAD) - { - dialpad = create_dialpad (); - gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (dialpad); - } - - /* Status bar */ - statusBar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox), statusBar, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_container_add (GTK_CONTAINER (window), vbox); - - /* make sure that everything, window and label, are visible */ - gtk_widget_show_all (window); - - /* dont't show the history */ - gtk_widget_hide (history->tree); - - /* dont't show the contact list */ - gtk_widget_hide (contacts->tree); - - searchbar_init (history); - searchbar_init (contacts); - - /* don't show waiting layer */ - gtk_widget_hide (waitingLayer); - - // Configuration wizard - if (account_list_get_size () == 1) - { + GtkWidget *widget; + gchar *path; + GError *error = NULL; + gboolean ret; + const char *window_title = "SFLphone VoIP Client"; + int width, height, position_x, position_y; + + focus_is_on_calltree = FALSE; + focus_is_on_searchbar = FALSE; + + // Get configuration stored in gconf + width = eel_gconf_get_integer (CONF_MAIN_WINDOW_WIDTH); + height = eel_gconf_get_integer (CONF_MAIN_WINDOW_HEIGHT); + position_x = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X); + position_y = eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width (GTK_CONTAINER (window), 0); + gtk_window_set_title (GTK_WINDOW (window), window_title); + gtk_window_set_default_size (GTK_WINDOW (window), width, height); + gtk_window_set_default_icon_from_file (LOGO, + NULL); + gtk_window_set_position (GTK_WINDOW(window) , GTK_WIN_POS_MOUSE); + + /* Connect the destroy event of the window with our on_destroy function + * When the window is about to be destroyed we get a notificaiton and + * stop the main GTK loop + */ + g_signal_connect (G_OBJECT (window), "delete-event", + G_CALLBACK (on_delete), NULL); + + g_signal_connect (G_OBJECT (window), "key-release-event", + G_CALLBACK (on_key_released), NULL); + + g_signal_connect_after (G_OBJECT (window), "focus-in-event", + G_CALLBACK (focus_on_mainwindow_in), NULL); + + g_signal_connect_after (G_OBJECT (window), "focus-out-event", + G_CALLBACK (focus_on_mainwindow_out), NULL); + + g_signal_connect_object (G_OBJECT (window), "configure-event", + G_CALLBACK (window_configure_cb), NULL, 0); + + gtk_widget_set_name (window, "mainwindow"); + + ret = uimanager_new (&ui_manager); + if (!ret) + { + ERROR ("Could not load xml GUI\n"); + g_error_free (error); + exit (1); + } + + /* Create an accel group for window's shortcuts */ + gtk_window_add_accel_group (GTK_WINDOW(window), + gtk_ui_manager_get_accel_group (ui_manager)); + + vbox = gtk_vbox_new (FALSE /*homogeneous*/, 0 /*spacing*/); + subvbox = gtk_vbox_new (FALSE /*homogeneous*/, 5 /*spacing*/); + + create_menus (ui_manager, &widget); + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, + 0 /*padding*/); + + create_toolbar_actions (ui_manager, &widget); + // Do not override GNOME user settings + gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, + 0 /*padding*/); + + gtk_box_pack_start (GTK_BOX (vbox), current_calls->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_box_pack_start (GTK_BOX (vbox), history->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_box_pack_start (GTK_BOX (vbox), contacts->tree, TRUE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + + g_signal_connect_object (G_OBJECT (window), "configure-event", + G_CALLBACK (window_configure_cb), NULL, 0); + gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, + FALSE /*fill*/, 0 /*padding*/); + + embedded_error_notebook = PIDGIN_SCROLL_BOOK(pidgin_scroll_book_new()); + gtk_box_pack_start (GTK_BOX(subvbox), GTK_WIDGET(embedded_error_notebook), + FALSE, FALSE, 0); + + if (SHOW_VOLUME) + { + speaker_control = create_slider ("speaker"); + gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (speaker_control); + mic_control = create_slider ("mic"); + gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (mic_control); + } + + + if (eel_gconf_get_boolean (CONF_SHOW_DIALPAD)){ + dialpad = create_dialpad(); + gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (dialpad); + } + + /* Status bar */ + statusBar = gtk_statusbar_new (); + gtk_box_pack_start (GTK_BOX (vbox), statusBar, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_container_add (GTK_CONTAINER (window), vbox); + + /* make sure that everything, window and label, are visible */ + gtk_widget_show_all (window); + + /* dont't show the history */ + gtk_widget_hide (history->tree); + + /* dont't show the contact list */ + gtk_widget_hide (contacts->tree); + + searchbar_init (history); + searchbar_init (contacts); + + /* don't show waiting layer */ + gtk_widget_hide (waitingLayer); + + // Configuration wizard + if (account_list_get_size () == 1) + { #if GTK_CHECK_VERSION(2,10,0) - build_wizard (); + build_wizard (); #else - GtkWidget * dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_YES_NO, - "<b><big>Welcome to SFLphone!</big></b>\n\nThere are no VoIP accounts configured, would you like to edit the preferences now?"); + GtkWidget * dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_YES_NO, + "<b><big>Welcome to SFLphone!</big></b>\n\nThere are no VoIP accounts configured, would you like to edit the preferences now?"); - int response = gtk_dialog_run (GTK_DIALOG(dialog)); + int response = gtk_dialog_run (GTK_DIALOG(dialog)); - gtk_widget_destroy (GTK_WIDGET(dialog)); + gtk_widget_destroy (GTK_WIDGET(dialog)); - if (response == GTK_RESPONSE_YES) - { - show_preferences_dialog(); - } + if (response == GTK_RESPONSE_YES) + { + show_preferences_dialog(); + } #endif - } + } - // Move the main window - gtk_window_move (GTK_WINDOW (window), position_x, position_y); + // Restore position according to the configuration stored in gconf + gtk_window_move (GTK_WINDOW (window), position_x, position_y); } -GtkAccelGroup * + GtkAccelGroup * get_accel_group () { - return accelGroup; + return accelGroup; } -GtkWidget * + GtkWidget * get_main_window () { - return window; + return window; } -void + void main_window_message (GtkMessageType type, gchar * markup) { - GtkWidget * dialog = gtk_message_dialog_new_with_markup ( - GTK_WINDOW(get_main_window()), GTK_DIALOG_MODAL - | GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_CLOSE, NULL); + GtkWidget * dialog = gtk_message_dialog_new_with_markup ( + GTK_WINDOW(get_main_window()), GTK_DIALOG_MODAL + | GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_CLOSE, NULL); - gtk_window_set_title (GTK_WINDOW(dialog), _("SFLphone Error")); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog), markup); + gtk_window_set_title (GTK_WINDOW(dialog), _("SFLphone Error")); + gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog), markup); - gtk_dialog_run (GTK_DIALOG(dialog)); - gtk_widget_destroy (GTK_WIDGET(dialog)); + gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (GTK_WIDGET(dialog)); } -void + void main_window_error_message (gchar * markup) { - main_window_message (GTK_MESSAGE_ERROR, markup); + main_window_message (GTK_MESSAGE_ERROR, markup); } -void + void main_window_warning_message (gchar * markup) { - main_window_message (GTK_MESSAGE_WARNING, markup); + main_window_message (GTK_MESSAGE_WARNING, markup); } -void + void main_window_info_message (gchar * markup) { - main_window_message (GTK_MESSAGE_INFO, markup); + main_window_message (GTK_MESSAGE_INFO, markup); } -void + void main_window_dialpad (gboolean state) { - g_print ("main_window_dialpad\n"); - - if (state) - { - dialpad = create_dialpad (); - gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (dialpad); - } - else - { - gtk_container_remove (GTK_CONTAINER (subvbox), dialpad); - } + g_print ("main_window_dialpad\n"); + + if (state) + { + dialpad = create_dialpad (); + gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (dialpad); + } + else + { + gtk_container_remove (GTK_CONTAINER (subvbox), dialpad); + } } -void + void main_window_volume_controls (gboolean state) { - if (state) - { - speaker_control = create_slider ("speaker"); - gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (speaker_control); - mic_control = create_slider ("mic"); - gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, - TRUE /*fill*/, 0 /*padding*/); - gtk_widget_show_all (mic_control); - } - else - { - gtk_container_remove (GTK_CONTAINER(subvbox), speaker_control); - gtk_container_remove (GTK_CONTAINER(subvbox), mic_control); - } + if (state) + { + speaker_control = create_slider ("speaker"); + gtk_box_pack_end (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (speaker_control); + mic_control = create_slider ("mic"); + gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, + TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (mic_control); + } + else + { + gtk_container_remove (GTK_CONTAINER(subvbox), speaker_control); + gtk_container_remove (GTK_CONTAINER(subvbox), mic_control); + } } -void + void statusbar_push_message (const gchar * message, guint id) { - gtk_statusbar_push (GTK_STATUSBAR(statusBar), id, message); + gtk_statusbar_push (GTK_STATUSBAR(statusBar), id, message); } -void + void statusbar_pop_message (guint id) { - gtk_statusbar_pop (GTK_STATUSBAR(statusBar), id); + gtk_statusbar_pop (GTK_STATUSBAR(statusBar), id); } -static void + static void add_error_dialog (GtkWidget *dialog, callable_obj_t * call) { - gtk_container_add (GTK_CONTAINER(embedded_error_notebook), dialog); - call_add_error (call, dialog); + gtk_container_add (GTK_CONTAINER(embedded_error_notebook), dialog); + call_add_error (call, dialog); } -static void + static void destroy_error_dialog_cb (GtkObject *dialog, callable_obj_t * call) { - call_remove_error (call, dialog); + call_remove_error (call, dialog); } -void + void main_window_zrtp_not_supported (callable_obj_t * c) { - account_t* account_details = NULL; - gchar* warning_enabled = ""; - - account_details = account_list_get_by_id (c->_accountID); - if (account_details != NULL) - { - warning_enabled = g_hash_table_lookup (account_details->properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); - DEBUG("Warning Enabled %s", warning_enabled); - } - else - { - DEBUG("Account is null callID %s", c->_callID); - GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); - if (properties != NULL) - { - warning_enabled = g_hash_table_lookup (properties, - ACCOUNT_ZRTP_NOT_SUPP_WARNING); - } - } - - if (g_strcasecmp (warning_enabled, "true") == 0) - { - PidginMiniDialog *mini_dialog; - gchar *desc = g_markup_printf_escaped ( - _("ZRTP is not supported by peer %s\n"), c->_peer_number); - mini_dialog = pidgin_mini_dialog_new ( - _("Secure Communication Unavailable"), desc, - GTK_STOCK_DIALOG_WARNING); - pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), - sflphone_hang_up, NULL); - - g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); - } + account_t* account_details = NULL; + gchar* warning_enabled = ""; + + account_details = account_list_get_by_id (c->_accountID); + if (account_details != NULL) + { + warning_enabled = g_hash_table_lookup (account_details->properties, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); + DEBUG("Warning Enabled %s", warning_enabled); + } + else + { + DEBUG("Account is null callID %s", c->_callID); + GHashTable * properties = NULL; + sflphone_get_ip2ip_properties (&properties); + if (properties != NULL) + { + warning_enabled = g_hash_table_lookup (properties, + ACCOUNT_ZRTP_NOT_SUPP_WARNING); + } + } + + if (g_strcasecmp (warning_enabled, "true") == 0) + { + PidginMiniDialog *mini_dialog; + gchar *desc = g_markup_printf_escaped ( + _("ZRTP is not supported by peer %s\n"), c->_peer_number); + mini_dialog = pidgin_mini_dialog_new ( + _("Secure Communication Unavailable"), desc, + GTK_STOCK_DIALOG_WARNING); + pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), + sflphone_hang_up, NULL); + + g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); + + add_error_dialog (GTK_WIDGET(mini_dialog), c); + } } -void + void main_window_zrtp_negotiation_failed (const gchar* callID, const gchar* reason, - const gchar* severity) + const gchar* severity) { - gchar* peer_number = "(number unknown)"; - callable_obj_t * c = NULL; - c = calllist_get (current_calls, callID); - if (c != NULL) - { - peer_number = c->_peer_number; - } - - PidginMiniDialog *mini_dialog; - gchar - *desc = - g_markup_printf_escaped ( - _("A %s error forced the call with %s to fall under unencrypted mode.\nExact reason: %s\n"), - severity, peer_number, reason); - mini_dialog = pidgin_mini_dialog_new (_("ZRTP negotiation failed"), desc, - GTK_STOCK_DIALOG_WARNING); - pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, - NULL); - - g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); + gchar* peer_number = "(number unknown)"; + callable_obj_t * c = NULL; + c = calllist_get (current_calls, callID); + if (c != NULL) + { + peer_number = c->_peer_number; + } + + PidginMiniDialog *mini_dialog; + gchar + *desc = + g_markup_printf_escaped ( + _("A %s error forced the call with %s to fall under unencrypted mode.\nExact reason: %s\n"), + severity, peer_number, reason); + mini_dialog = pidgin_mini_dialog_new (_("ZRTP negotiation failed"), desc, + GTK_STOCK_DIALOG_WARNING); + pidgin_mini_dialog_add_button (mini_dialog, _("Continue"), NULL, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, + NULL); + + g_signal_connect_after(mini_dialog, "destroy", (GCallback) destroy_error_dialog_cb, c); + + add_error_dialog (GTK_WIDGET(mini_dialog), c); } -void + void main_window_confirm_go_clear (callable_obj_t * c) { - PidginMiniDialog *mini_dialog; - gchar - *desc = - g_markup_printf_escaped ( - _("%s wants to stop using secure communication. Confirm will resume conversation without SRTP.\n"), - c->_peer_number); - mini_dialog = pidgin_mini_dialog_new (_("Confirm Go Clear"), desc, - GTK_STOCK_STOP); - pidgin_mini_dialog_add_button (mini_dialog, _("Confirm"), - (PidginMiniDialogCallback) sflphone_set_confirm_go_clear, NULL); - pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, - NULL); - - add_error_dialog (GTK_WIDGET(mini_dialog), c); + PidginMiniDialog *mini_dialog; + gchar + *desc = + g_markup_printf_escaped ( + _("%s wants to stop using secure communication. Confirm will resume conversation without SRTP.\n"), + c->_peer_number); + mini_dialog = pidgin_mini_dialog_new (_("Confirm Go Clear"), desc, + GTK_STOCK_STOP); + pidgin_mini_dialog_add_button (mini_dialog, _("Confirm"), + (PidginMiniDialogCallback) sflphone_set_confirm_go_clear, NULL); + pidgin_mini_dialog_add_button (mini_dialog, _("Stop Call"), sflphone_hang_up, + NULL); + + add_error_dialog (GTK_WIDGET(mini_dialog), c); } diff --git a/sflphone-client-gnome/src/sflnotify.c b/sflphone-client-gnome/src/sflnotify.c index 3baaeccccf592bd3348a06ac0d1a09050e11d27f..e728e5ab56c1bdf6d3da4b3613ffa2ae5c3c458e 100644 --- a/sflphone-client-gnome/src/sflnotify.c +++ b/sflphone-client-gnome/src/sflnotify.c @@ -36,7 +36,7 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg { GnomeNotification *_notif; - if( dbus_get_notify()){ + if (eel_gconf_get_integer (NOTIFY_ALL)){ _notif = g_new0 (GnomeNotification, 1); diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 5a63a80bac069cfe6404b37824e3e8f21d96f91b..250a8c56738456d0a351d93bdb52b27667848fe9 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -136,13 +136,11 @@ log4c_category_t* log4c_sfl_gtk_category; /** Tells if the main window is reduced to the system tray or not */ #define MINIMIZED TRUE /** Behaviour of the main window on incoming calls */ -#define __POPUP_WINDOW ( dbus_popup_mode() ) -/** Show/Hide the dialpad */ -#define SHOW_DIALPAD ( dbus_get_dialpad() ) +#define __POPUP_WINDOW (eel_gconf_get_integer (POPUP_ON_CALL)) /** Show/Hide the alsa configuration panel */ #define SHOW_ALSA_CONF ( dbus_get_audio_manager() == ALSA ) /** Show/Hide the volume controls */ -#define SHOW_VOLUME (dbus_get_volume_controls() && SHOW_ALSA_CONF) +#define SHOW_VOLUME (eel_gconf_get_integer (SHOW_VOLUME_CONTROLS) && SHOW_ALSA_CONF) /** Audio Managers */ #define ALSA 0 @@ -179,4 +177,21 @@ log4c_category_t* log4c_sfl_gtk_category; #define ERROR(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_ERROR, __VA_ARGS__); #define FATAL(...) log4c_category_log(log4c_sfl_gtk_category, LOG4C_PRIORITY_FATAL, __VA_ARGS__); +/** + * Gconf + */ +#define CONF_PREFIX "/apps/sflphone-client-gnome" +#define CONF_MAIN_WINDOW_WIDTH CONF_PREFIX "/state/window_width" +#define CONF_MAIN_WINDOW_HEIGHT CONF_PREFIX "/state/window_height" +#define CONF_MAIN_WINDOW_POSITION_X CONF_PREFIX "/state/window_position_x" +#define CONF_MAIN_WINDOW_POSITION_Y CONF_PREFIX "/state/window_position_y" +/** Show/Hide the dialpad */ +#define CONF_SHOW_DIALPAD CONF_PREFIX "/state/dialpad" +#define SHOW_VOLUME_CONTROLS CONF_PREFIX "/state/volume_controls" +#define SHOW_STATUSICON CONF_PREFIX "/state/statusicon" +#define NOTIFY_ALL CONF_PREFIX "/state/notify_all" +#define START_HIDDEN CONF_PREFIX "/state/start_hidden" +#define POPUP_ON_CALL CONF_PREFIX "/state/popup" +#define HISTORY_ENABLED CONF_PREFIX "/state/history" + #endif diff --git a/sflphone-client-gnome/src/statusicon.c b/sflphone-client-gnome/src/statusicon.c index 6ad61747705578cb9e360a4496bafe27b7a8e0b7..72511091f05e8591ce022a2b64984329715c2dd3 100644 --- a/sflphone-client-gnome/src/statusicon.c +++ b/sflphone-client-gnome/src/statusicon.c @@ -55,10 +55,12 @@ popup_main_window(void) void show_status_hangup_icon() { - if (status) { - DEBUG("Show Hangup in Systray"); - gtk_widget_show(GTK_WIDGET(hangup_menu_item)); - } + if (__POPUP_WINDOW) + { + gtk_widget_show (get_main_window ()); + gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); + set_minimized (FALSE); + } } void @@ -97,18 +99,17 @@ main_widget_minimized() void show_hide(void) { - if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item))) - { - gtk_widget_show(GTK_WIDGET(get_main_window())); - gtk_window_move(GTK_WINDOW (get_main_window ()), - dbus_get_window_position_x(), dbus_get_window_position_y()); - set_minimized(!MINIMIZED); - } - else - { - gtk_widget_hide(GTK_WIDGET(get_main_window())); - set_minimized(MINIMIZED); - } + if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(show_menu_item))) + { + gtk_widget_show(GTK_WIDGET(get_main_window())); + gtk_window_move (GTK_WINDOW (get_main_window ()), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_X), eel_gconf_get_integer (CONF_MAIN_WINDOW_POSITION_Y)); + set_minimized( !MINIMIZED ); + } + else + { + gtk_widget_hide(GTK_WIDGET(get_main_window())); + set_minimized( MINIMIZED ); + } } void @@ -203,7 +204,6 @@ statusicon_set_tooltip() g_free(tip); } - } void diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 46def19d3dfd989a233936dede77091f7a298a79..8f3a41ca1ef14a4b8dc0bce3dab4cdc750edda5a 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -92,6 +92,7 @@ update_actions() g_object_ref(holdToolbar); g_object_ref(offHoldToolbar); g_object_ref(contactButton); + g_object_ref(historyButton); g_object_ref(transferToolbar); g_object_ref(voicemailToolbar); @@ -111,6 +112,11 @@ update_actions() GTK_WIDGET (transferToolbar)); } + if (is_inserted(GTK_WIDGET(historyButton), GTK_WIDGET (toolbar))) + { + gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (historyButton)); + } + if (is_inserted(GTK_WIDGET(contactButton), GTK_WIDGET (toolbar))) { gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (contactButton)); @@ -129,6 +135,7 @@ update_actions() gtk_widget_set_sensitive(GTK_WIDGET (recordWidget), FALSE); gtk_action_set_sensitive(GTK_ACTION (copyAction), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(contactButton), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(historyButton), FALSE); gtk_widget_set_tooltip_text(GTK_WIDGET (contactButton), _("No address book selected")); @@ -143,6 +150,11 @@ update_actions() gtk_container_remove(GTK_CONTAINER (toolbar), GTK_WIDGET (pickUpWidget)); gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (newCallWidget), 0); + + if (eel_gconf_get_integer (HISTORY_ENABLED)) { + gtk_toolbar_insert(GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (historyButton), -1); + gtk_widget_set_sensitive(GTK_WIDGET(historyButton), TRUE); + } // If addressbook support has been enabled and all addressbooks are loaded, display the icon if (addressbook_is_enabled() && addressbook_is_ready()) { @@ -353,18 +365,20 @@ volume_bar_cb(GtkToggleAction *togglemenuitem, gpointer user_data) return; main_window_volume_controls(toggled); if (toggled || SHOW_VOLUME) - dbus_set_volume_controls(toggled); + eel_gconf_set_integer (SHOW_VOLUME_CONTROLS, toggled); } static void dialpad_bar_cb(GtkToggleAction *togglemenuitem, gpointer user_data) { - gboolean toggled = gtk_toggle_action_get_active(togglemenuitem); - if (toggled == SHOW_DIALPAD) - return; - main_window_dialpad(toggled); - if (toggled || SHOW_DIALPAD) - dbus_set_dialpad(toggled); + gboolean toggled = gtk_toggle_action_get_active (togglemenuitem); + gboolean conf_dialpad = eel_gconf_get_boolean (CONF_SHOW_DIALPAD); + if (toggled == conf_dialpad) + return; + main_window_dialpad (toggled); + if (toggled || conf_dialpad) + eel_gconf_set_boolean (CONF_SHOW_DIALPAD, toggled); //dbus_set_dialpad (toggled); + } static void @@ -428,7 +442,7 @@ static void call_minimize(void * foo UNUSED) { - if (g_strcasecmp (dbus_is_status_icon_enabled (), "true") == 0) { + if (eel_gconf_get_integer (SHOW_STATUSICON)) { gtk_widget_hide(GTK_WIDGET( get_main_window() )); set_minimized(TRUE); } @@ -1457,43 +1471,31 @@ void create_menus(GtkUIManager *ui_manager, GtkWidget **widget) { - GtkWidget * menu_bar; - - menu_bar = gtk_ui_manager_get_widget(ui_manager, "/MenuBar"); - pickUpAction = gtk_ui_manager_get_action(ui_manager, - "/MenuBar/CallMenu/PickUp"); - newCallAction = gtk_ui_manager_get_action(ui_manager, - "/MenuBar/CallMenu/NewCall"); - hangUpAction = gtk_ui_manager_get_action(ui_manager, - "/MenuBar/CallMenu/HangUp"); - holdMenu = gtk_ui_manager_get_widget(ui_manager, - "/MenuBar/CallMenu/OnHoldMenu"); - recordAction = gtk_ui_manager_get_action(ui_manager, - "/MenuBar/CallMenu/Record"); - copyAction = gtk_ui_manager_get_action(ui_manager, "/MenuBar/EditMenu/Copy"); - pasteAction - = gtk_ui_manager_get_action(ui_manager, "/MenuBar/EditMenu/Paste"); - volumeToggle = gtk_ui_manager_get_action(ui_manager, - "/MenuBar/ViewMenu/VolumeControls"); - - // Set the toggle buttons - gtk_toggle_action_set_active( - GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Dialpad")), - (gboolean) SHOW_DIALPAD); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION (volumeToggle), - (gboolean) SHOW_VOLUME); - - gtk_action_set_sensitive(GTK_ACTION (volumeToggle), SHOW_ALSA_CONF); - - // Disable it right now - gtk_action_set_sensitive( - GTK_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Toolbar")), - FALSE); - - waitingLayer = create_waiting_icon(); - gtk_menu_shell_append(GTK_MENU_SHELL (menu_bar), waitingLayer); - - *widget = menu_bar; + GtkWidget * menu_bar; + + menu_bar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar"); + pickUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/PickUp"); + newCallAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/NewCall"); + hangUpAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/HangUp"); + holdMenu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar/CallMenu/OnHoldMenu"); + recordAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/CallMenu/Record"); + copyAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Copy"); + pasteAction = gtk_ui_manager_get_action (ui_manager, "/MenuBar/EditMenu/Paste"); + volumeToggle = gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/VolumeControls"); + + // Set the toggle buttons + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Dialpad")), eel_gconf_get_boolean (CONF_SHOW_DIALPAD)); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (volumeToggle), (gboolean) SHOW_VOLUME); + + gtk_action_set_sensitive (GTK_ACTION (volumeToggle), SHOW_ALSA_CONF); + + // Disable it right now + gtk_action_set_sensitive (GTK_ACTION (gtk_ui_manager_get_action (ui_manager, "/MenuBar/ViewMenu/Toolbar")), FALSE); + + waitingLayer = create_waiting_icon (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), waitingLayer); + + *widget = menu_bar; } void