From b2284eebfab59a97c60c97a627d4106f10674d89 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Tue, 20 May 2008 16:14:57 -0400 Subject: [PATCH] Add a menu item to hide/show the search bar --- po/fr.po | 4 ++ po/sflphone.pot | 4 ++ sflphone-gtk/src/configurationmanager-glue.h | 75 ++++++++++++++++++++ sflphone-gtk/src/dbus.c | 35 +++++++++ sflphone-gtk/src/dbus.h | 12 ++++ sflphone-gtk/src/historyfilter.c | 7 -- sflphone-gtk/src/mainwindow.c | 46 ++++++++---- sflphone-gtk/src/menus.c | 19 +++++ sflphone-gtk/src/sflphone_const.h | 3 + src/dbus/configurationmanager-glue.h | 33 +++++++++ src/dbus/configurationmanager-introspec.xml | 7 ++ src/dbus/configurationmanager.cpp | 12 ++++ src/dbus/configurationmanager.h | 2 + src/managerimpl.cpp | 13 ++++ src/managerimpl.h | 12 +++- src/user_cfg.h | 1 + 16 files changed, 264 insertions(+), 21 deletions(-) diff --git a/po/fr.po b/po/fr.po index 2beb3d9eb8..26e93ba57f 100644 --- a/po/fr.po +++ b/po/fr.po @@ -79,6 +79,10 @@ msgstr "_Clavier" msgid "_Volume controls" msgstr "_Contrôle du volume" +#: sflphone-gtk/src/menus.c: 610 +msgid "_Search history" +msgstr "Recherche dans l'historique" + #: sflphone-gtk/src/menus.c: 479 msgid "_Toolbar" msgstr "_Barre d'outils" diff --git a/po/sflphone.pot b/po/sflphone.pot index 95a0deb37b..b80a6c7c71 100644 --- a/po/sflphone.pot +++ b/po/sflphone.pot @@ -77,6 +77,10 @@ msgstr "" msgid "_Volume controls" msgstr "" +#: sflphone-gtk/src/menus.c: 610 +msgid "_Search history" +msgstr "" + #: sflphone-gtk/src/menus.c: 479 msgid "_Toolbar" msgstr "" diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index 00e4b3126c..3cad16502d 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -1406,6 +1406,81 @@ static inline #endif gboolean +org_sflphone_SFLphone_ConfigurationManager_get_searchbar (DBusGProxy *proxy, gint* OUT_state, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getSearchbar", error, G_TYPE_INVALID, G_TYPE_INT, OUT_state, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_searchbar_reply) (DBusGProxy *proxy, gint OUT_state, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_get_searchbar_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gint OUT_state; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_state, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_searchbar_reply)data->cb) (proxy, OUT_state, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_get_searchbar_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_searchbar_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getSearchbar", org_sflphone_SFLphone_ConfigurationManager_get_searchbar_async_callback, stuff, g_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_set_searchbar (DBusGProxy *proxy, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setSearchbar", error, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_searchbar_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_set_searchbar_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_set_searchbar_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_set_searchbar_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_set_searchbar_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setSearchbar", org_sflphone_SFLphone_ConfigurationManager_set_searchbar_async_callback, stuff, g_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean org_sflphone_SFLphone_ConfigurationManager_get_volume_controls (DBusGProxy *proxy, gint* OUT_state, GError **error) { diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 2d5f4fe118..c5f10b1b7d 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1181,6 +1181,41 @@ dbus_set_dialpad( ) g_print("DBus called set_dialpad on ConfigurationManager\n"); } +int +dbus_get_searchbar() +{ + int state; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_searchbar( + configurationManagerProxy, + &state, + &error); + g_print("After"); + if(error) + { + g_error_free(error); + } + else + g_print("DBus called get_searchbar on ConfigurationManager\n"); + return state; +} + +void +dbus_set_searchbar( ) +{ + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_searchbar( + configurationManagerProxy, + &error); + g_print("After"); + if(error) + { + g_error_free(error); + } + else + g_print("DBus called set_searchbar on ConfigurationManager\n"); +} + int dbus_get_volume_controls() { diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index d902bd17eb..d54165f3f7 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -291,6 +291,18 @@ void dbus_set_dialpad( ); */ int dbus_get_dialpad( void ); +/** + * ConfigurationManager - Set the searchbar visible or not + */ +void dbus_set_searchbar( ); + +/** + * ConfigurationManager - Tells if the user wants to display the search bar or not + * @return int 1 if the search bar has to be displayed + * 0 otherwise + */ +int dbus_get_searchbar( void ); + /** * ConfigurationManager - Set the volume controls visible or not */ diff --git a/sflphone-gtk/src/historyfilter.c b/sflphone-gtk/src/historyfilter.c index e58a26d787..86aa6f4111 100644 --- a/sflphone-gtk/src/historyfilter.c +++ b/sflphone-gtk/src/historyfilter.c @@ -59,13 +59,6 @@ clear_filter_entry_if_default(GtkWidget* widget, gpointer user_data) } -void -clear_filter_entry(GtkButton* button, - gpointer user_data) -{ - gtk_entry_set_text(GTK_ENTRY(filter_entry), ""); -} - GtkWidget* create_filter_entry() { diff --git a/sflphone-gtk/src/mainwindow.c b/sflphone-gtk/src/mainwindow.c index 191561265f..78bd04bbff 100644 --- a/sflphone-gtk/src/mainwindow.c +++ b/sflphone-gtk/src/mainwindow.c @@ -36,6 +36,7 @@ GtkAccelGroup * accelGroup = NULL; GtkWidget * window = NULL; GtkWidget * subvbox = NULL; +GtkWidget * vbox = NULL; GtkWidget * dialpad = NULL; GtkWidget * speaker_control = NULL; GtkWidget * mic_control = NULL; @@ -112,6 +113,7 @@ on_key_released (GtkWidget *widget, event->keyval == 32 // space ) return FALSE; + g_print("search bar active : %s\n", gtk_widget_is_focus(GTK_WIDGET( filterEntry ))); sflphone_keypad(event->keyval, event->string); return TRUE; } @@ -120,7 +122,6 @@ void create_main_window () { GtkWidget *widget; - GtkWidget *vbox; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 0); @@ -137,7 +138,7 @@ create_main_window () g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (on_delete), NULL); //g_signal_connect (G_OBJECT (window), "key-press-event", - // G_CALLBACK (on_key_released), NULL); + // G_CALLBACK (on_key_released), NULL); /* Create an accel group for window's shortcuts */ accelGroup = gtk_accel_group_new (); @@ -151,28 +152,32 @@ create_main_window () gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); widget = create_toolbar(); - - filterEntry = create_filter_entry(); - gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); - gtk_box_pack_start (GTK_BOX (vbox), filterEntry, FALSE /*expand*/, FALSE /*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), subvbox, FALSE /*expand*/, FALSE /*fill*/, 0 /*padding*/); + + if( SHOW_SEARCHBAR ){ + filterEntry = create_filter_entry(); + gtk_box_pack_start (GTK_BOX (subvbox), filterEntry, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all ( filterEntry ); + } - if( SHOW_VOLUME ){ + if( SHOW_VOLUME ){ speaker_control = create_slider("speaker"); - gtk_box_pack_start (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + 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_start (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + 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_box_reorder_child(GTK_BOX (subvbox), dialpad, 1); gtk_widget_show_all (dialpad); } @@ -258,7 +263,6 @@ main_window_dialpad( gboolean *state ){ { dialpad = create_dialpad(); gtk_box_pack_end (GTK_BOX (subvbox), dialpad, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); - gtk_box_reorder_child(GTK_BOX (subvbox), dialpad, 1); gtk_widget_show_all (dialpad); *state = TRUE; } @@ -274,10 +278,10 @@ main_window_volume_controls( gboolean *state ){ if( !SHOW_VOLUME ) { speaker_control = create_slider("speaker"); - gtk_box_pack_start (GTK_BOX (subvbox), speaker_control, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + 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_start (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + gtk_box_pack_end (GTK_BOX (subvbox), mic_control, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); gtk_widget_show_all (mic_control); *state = TRUE; } @@ -289,6 +293,22 @@ main_window_volume_controls( gboolean *state ){ } } +void +main_window_searchbar( gboolean *state ){ + if( !SHOW_SEARCHBAR ) + { + filterEntry = create_filter_entry(); + gtk_box_pack_start (GTK_BOX (subvbox), filterEntry, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/); + gtk_widget_show_all (filterEntry); + *state = TRUE; + } + else + { + gtk_container_remove( GTK_CONTAINER(subvbox) , filterEntry ); + *state = FALSE; + } +} + void statusbar_push_message(const gchar * message, guint id) { diff --git a/sflphone-gtk/src/menus.c b/sflphone-gtk/src/menus.c index c4e35a202d..e7fc9b21d1 100644 --- a/sflphone-gtk/src/menus.c +++ b/sflphone-gtk/src/menus.c @@ -41,6 +41,7 @@ guint holdConnId; //The hold_menu signal connection ID GtkWidget * dialpadMenu; GtkWidget * volumeMenu; +GtkWidget * searchbarMenu; void update_menus() @@ -563,6 +564,15 @@ view_volume_controls (GtkImageMenuItem *imagemenuitem, dbus_set_volume_controls( state ); } + static void +view_searchbar (GtkImageMenuItem *imagemenuitem, + void* foo) +{ + gboolean state; + main_window_searchbar( &state ); + dbus_set_searchbar( state ); +} + GtkWidget * create_view_menu() { @@ -596,6 +606,15 @@ create_view_menu() NULL); gtk_widget_show (volumeMenu); + image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_MENU ); + searchbarMenu = gtk_image_menu_item_new_with_mnemonic (_("_Search history")); + gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( searchbarMenu ), image ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), searchbarMenu); + g_signal_connect(G_OBJECT (searchbarMenu), "activate", + G_CALLBACK (view_searchbar), + NULL); + gtk_widget_show (searchbarMenu); + root_menu = gtk_menu_item_new_with_mnemonic (_("_View")); gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu); diff --git a/sflphone-gtk/src/sflphone_const.h b/sflphone-gtk/src/sflphone_const.h index d9aef1abfe..ff4c90ba43 100644 --- a/sflphone-gtk/src/sflphone_const.h +++ b/sflphone-gtk/src/sflphone_const.h @@ -74,6 +74,9 @@ #define SHOW_DIALPAD ( dbus_get_dialpad() ) /** Show/Hide the volume controls */ #define SHOW_VOLUME ( dbus_get_volume_controls() ) +/** Show/Hide the dialpad */ +#define SHOW_SEARCHBAR ( dbus_get_searchbar() ) + /** Notification levels */ #define __NOTIF_LEVEL_MIN 0 #define __NOTIF_LEVEL_MED 1 diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index 4b70708af3..dfd7f89204 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -57,6 +57,8 @@ public: register_method(ConfigurationManager, getMailNotify, _getMailNotify_stub); register_method(ConfigurationManager, getDialpad, _getDialpad_stub); register_method(ConfigurationManager, setDialpad, _setDialpad_stub); + register_method(ConfigurationManager, getSearchbar, _getSearchbar_stub); + register_method(ConfigurationManager, setSearchbar, _setSearchbar_stub); register_method(ConfigurationManager, getVolumeControls, _getVolumeControls_stub); register_method(ConfigurationManager, setVolumeControls, _setVolumeControls_stub); register_method(ConfigurationManager, getMaxCalls, _getMaxCalls_stub); @@ -255,6 +257,15 @@ public: { { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument getSearchbar_args[] = + { + { "state", "i", false }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument setSearchbar_args[] = + { + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument getVolumeControls_args[] = { { "state", "i", false }, @@ -345,6 +356,8 @@ public: { "getMailNotify", getMailNotify_args }, { "getDialpad", getDialpad_args }, { "setDialpad", setDialpad_args }, + { "getSearchbar", getSearchbar_args }, + { "setSearchbar", setSearchbar_args }, { "getVolumeControls", getVolumeControls_args }, { "setVolumeControls", setVolumeControls_args }, { "getMaxCalls", getMaxCalls_args }, @@ -424,6 +437,8 @@ public: virtual ::DBus::Int32 getMailNotify( ) = 0; virtual ::DBus::Int32 getDialpad( ) = 0; virtual void setDialpad( ) = 0; + virtual ::DBus::Int32 getSearchbar( ) = 0; + virtual void setSearchbar( ) = 0; virtual ::DBus::Int32 getVolumeControls( ) = 0; virtual void setVolumeControls( ) = 0; virtual ::DBus::Int32 getMaxCalls( ) = 0; @@ -818,6 +833,24 @@ private: ::DBus::ReturnMessage reply(call); return reply; } + ::DBus::Message _getSearchbar_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + ::DBus::Int32 argout1 = getSearchbar(); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } + ::DBus::Message _setSearchbar_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + setSearchbar(); + ::DBus::ReturnMessage reply(call); + return reply; + } ::DBus::Message _getVolumeControls_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 59c96a1e6a..0b785ff3d8 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -159,6 +159,13 @@ <method name="setDialpad"> </method> + <method name="getSearchbar"> + <arg type="i" name="state" direction="out"/> + </method> + + <method name="setSearchbar"> + </method> + <method name="getVolumeControls"> <arg type="i" name="state" direction="out"/> </method> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index b4d488d67f..77e35d2c2d 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -261,6 +261,18 @@ ConfigurationManager::setDialpad( void ) Manager::instance().setDialpad( ); } +::DBus::Int32 +ConfigurationManager::getSearchbar( void ) +{ + return Manager::instance().getSearchbar( ); +} + +void +ConfigurationManager::setSearchbar( void ) +{ + Manager::instance().setSearchbar( ); +} + ::DBus::Int32 ConfigurationManager::getVolumeControls( void ) { diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 067dea7fec..da0c82efb3 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -77,6 +77,8 @@ public: void setRingtoneChoice( const ::DBus::String& tone ); ::DBus::Int32 getDialpad( void ); void setDialpad( void ); + ::DBus::Int32 getSearchbar( void ); + void setSearchbar( void ); void setMaxCalls( const ::DBus::Int32& calls); ::DBus::Int32 getMaxCalls( void ); ::DBus::Int32 getVolumeControls( void ); diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 26f4dc9852..a5fc52eadf 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -975,6 +975,7 @@ ManagerImpl::initConfigFile (void) fill_config_int(CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT_STR); fill_config_int(CONFIG_RINGTONE, YES_STR); fill_config_int(CONFIG_DIALPAD, YES_STR); + fill_config_int(CONFIG_SEARCHBAR, YES_STR); fill_config_int(CONFIG_START, NO_STR); fill_config_int(CONFIG_POPUP, YES_STR); fill_config_int(CONFIG_NOTIFY , YES_STR); @@ -1369,6 +1370,18 @@ ManagerImpl::getMaxCalls( void ) return getConfigInt( PREFERENCES , CONFIG_HISTORY ); } +int +ManagerImpl::getSearchbar( void ) +{ + return getConfigInt( PREFERENCES , CONFIG_SEARCHBAR ); +} + +void +ManagerImpl::setSearchbar( void ) +{ + ( getConfigInt( PREFERENCES , CONFIG_SEARCHBAR ) == 1)? setConfig(PREFERENCES , CONFIG_SEARCHBAR , NO_STR ) : setConfig( PREFERENCES , CONFIG_SEARCHBAR , YES_STR ); +} + int ManagerImpl::popupMode( void ) { diff --git a/src/managerimpl.h b/src/managerimpl.h index 5fa813b906..d6aa83be77 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -506,7 +506,7 @@ class ManagerImpl { void startHidden( void ); /** - Configure the popup behaviour + * Configure the popup behaviour * @return int 1 if it should popup on incoming calls * 0 if it should never popups */ @@ -519,6 +519,16 @@ class ManagerImpl { */ void switchPopupMode( void ); + /** + * Determine whether or not the search bar (history) should be displayed + */ + int getSearchbar( void ); + + /** + * Configure the search bar behaviour + */ + void setSearchbar( void ); + /** * Set the desktop notification level */ diff --git a/src/user_cfg.h b/src/user_cfg.h index 173a669337..e01e0615fc 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -48,6 +48,7 @@ #define PREFERENCES "Preferences" /** Section Preferences */ #define CONFIG_DIALPAD "Dialpad.display" /** Display dialpad preferences */ +#define CONFIG_SEARCHBAR "Searchbar.display" /** Whether or nor display the search bar */ #define CONFIG_HISTORY "History.maxCalls" /** Set the maximum number of calls kept */ #define CONFIG_NOTIFY "Notify.all" /** Desktop notification level */ #define CONFIG_MAIL_NOTIFY "Notify.mails" /** Desktop mail notification level */ -- GitLab