diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 823769f1e4d1cbe0a1a3f03db1cf7b16056df8bc..c7b66dd63c25fee3afaa1e739ba800f6efe45445 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -236,9 +236,9 @@ gboolean sflphone_init() { dbus_register(getpid(), "Gtk+ Client"); - current_calls = calltab_init(NULL); - contacts = calltab_init("contacts"); - history = calltab_init("history"); + current_calls = calltab_init(FALSE, CURRENT_CALLS); + contacts = calltab_init(TRUE, CONTACTS); + history = calltab_init(TRUE, HISTORY); account_list_init (); codec_list_init(); diff --git a/sflphone-client-gnome/src/contacts/calllist.h b/sflphone-client-gnome/src/contacts/calllist.h index f44afdb69d6b71812f17528fbb4ed3798e50bc72..3caccad439c4689374c411b296125ac8cff5bf18 100644 --- a/sflphone-client-gnome/src/contacts/calllist.h +++ b/sflphone-client-gnome/src/contacts/calllist.h @@ -36,6 +36,7 @@ typedef struct { // Calllist vars GQueue* callQueue; callable_obj_t* selectedCall; + gchar *_name; } calltab_t; void diff --git a/sflphone-client-gnome/src/contacts/calltab.c b/sflphone-client-gnome/src/contacts/calltab.c index f8c6783d84819599a47e438f686bcf37ec3fded6..00cfc85343213d062e0b11d96d35dc2737300745 100644 --- a/sflphone-client-gnome/src/contacts/calltab.c +++ b/sflphone-client-gnome/src/contacts/calltab.c @@ -23,8 +23,7 @@ #include <calltree.h> #include <contacts/searchbar.h> -calltab_t* -calltab_init(gchar* searchbar_type) +calltab_t* calltab_init (gboolean searchbar_type, gchar *name) { calltab_t* ret; @@ -33,11 +32,12 @@ calltab_init(gchar* searchbar_type) ret->store = NULL; ret->view = NULL; ret->tree = NULL; - ret->searchbar = NULL; + ret->searchbar = NULL; ret->callQueue = NULL; ret->selectedCall = NULL; + ret->_name = g_strdup (name); - calltree_create(ret, searchbar_type); + calltree_create (ret, searchbar_type); calllist_init(ret); @@ -58,7 +58,12 @@ calltab_get_selected_call (calltab_t* tab) } void -calltab_create_searchbar(calltab_t* tab, gchar* searchbar_type) +calltab_create_searchbar (calltab_t* tab) { - tab->searchbar = searchbar_new(searchbar_type); + if (g_strcasecmp (tab->_name, HISTORY) == 0) + tab->searchbar = history_searchbar_new (); + else if (g_strcasecmp (tab->_name, CONTACTS) == 0) + tab->searchbar = contacts_searchbar_new (); + else + ERROR ("Current calls tab does not need a searchbar\n"); } diff --git a/sflphone-client-gnome/src/contacts/calltab.h b/sflphone-client-gnome/src/contacts/calltab.h index 081876a7166e18c7ec54d6f5b8c7bfba53e72038..25c3ddb70f99effcd6f507e3a169821e9ca25eb5 100644 --- a/sflphone-client-gnome/src/contacts/calltab.h +++ b/sflphone-client-gnome/src/contacts/calltab.h @@ -28,7 +28,7 @@ calltab_t* current_calls; calltab_t* history; calltab_t* contacts; -calltab_t* calltab_init(gchar* searchbar_type); +calltab_t* calltab_init (gboolean searchbar_type, gchar *name); /** Mark a call as selected. There can be only one selected call. This call * is the currently highlighted one in the list. @@ -42,6 +42,6 @@ callable_obj_t * calltab_get_selected_call (calltab_t*); void -calltab_create_searchbar(calltab_t *, gchar *); +calltab_create_searchbar (calltab_t *); #endif diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 2884216f74f5a49f36dbfb8455652c8b53a7595f..7aac283e3993efe5d43621c58bc8735a80fbf703 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -170,7 +170,7 @@ focus_on_calltree_in(){ } void -calltree_create (calltab_t* tab, gchar* searchbar_type) +calltree_create (calltab_t* tab, gboolean searchbar_type) { // GtkWidget *sw; // GtkCellRenderer *rend; @@ -246,19 +246,13 @@ calltree_create (calltab_t* tab, gchar* searchbar_type) gtk_box_pack_start(GTK_BOX(tab->tree), sw, TRUE, TRUE, 0); - // no search bar if tab is either "history" or "addressbook" + // search bar if tab is either "history" or "addressbook" if(searchbar_type){ - calltab_create_searchbar(tab,searchbar_type); + calltab_create_searchbar (tab); gtk_box_pack_start(GTK_BOX(tab->tree), tab->searchbar, FALSE, TRUE, 0); } gtk_widget_show(tab->tree); - - - // gtk_widget_show(tab->searchbar); - - //toolbar_update_buttons(); - } void diff --git a/sflphone-client-gnome/src/contacts/calltree.h b/sflphone-client-gnome/src/contacts/calltree.h index 8626de319f6d0d354430ecc1d4d03858aa9b2cbb..eedcc1d3ca7a3debebf3ba11a43154447d535d34 100644 --- a/sflphone-client-gnome/src/contacts/calltree.h +++ b/sflphone-client-gnome/src/contacts/calltree.h @@ -33,7 +33,7 @@ * @return GtkWidget* A new widget */ void -calltree_create(calltab_t* tab, gchar* searchbar_type); +calltree_create(calltab_t* tab, gboolean searchbar_type); /** * Add a call in the calltree diff --git a/sflphone-client-gnome/src/contacts/history.c b/sflphone-client-gnome/src/contacts/history.c index d72ee7342393a73c876c408f85c46e5b58409006..ea807892450ca1f849fef11d4d4132cb79d3fdbf 100644 --- a/sflphone-client-gnome/src/contacts/history.c +++ b/sflphone-client-gnome/src/contacts/history.c @@ -28,53 +28,45 @@ GtkWidget * history_searchbar_widget; static GtkTreeModel* history_create_filter (GtkTreeModel*); static gboolean history_is_visible (GtkTreeModel*, GtkTreeIter*, gpointer); - -void -history_search(GtkEntry* entry UNUSED){ - - - if(history_filter != NULL) { - - gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(history_filter)); - - } +void history_search (GtkEntry* entry UNUSED) +{ + if(history_filter != NULL) { + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (history_filter)); + } } -void -history_init(){ - - history_filter = history_create_filter(GTK_TREE_MODEL (history->store)); - gtk_tree_view_set_model(GTK_TREE_VIEW (history->view), GTK_TREE_MODEL(history_filter)); - +void history_init (void) +{ + history_filter = history_create_filter (GTK_TREE_MODEL (history->store)); + gtk_tree_view_set_model (GTK_TREE_VIEW (history->view), GTK_TREE_MODEL (history_filter)); } -void history_set_searchbar_widget(GtkWidget *searchbar){ - - history_searchbar_widget = searchbar; +void history_set_searchbar_widget (GtkWidget *searchbar) +{ + history_searchbar_widget = searchbar; } -static GtkTreeModel* -history_create_filter (GtkTreeModel* child) { +static GtkTreeModel* history_create_filter (GtkTreeModel* child) +{ + GtkTreeModel* ret; - GtkTreeModel* ret; - - DEBUG("Create Filter\n"); - ret = gtk_tree_model_filter_new(child, NULL); - gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(ret), history_is_visible, NULL, NULL); - return GTK_TREE_MODEL(ret); + DEBUG("Create Filter\n"); + ret = gtk_tree_model_filter_new (child, NULL); + gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (ret), history_is_visible, NULL, NULL); + return GTK_TREE_MODEL (ret); } -static gboolean -history_is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED) { - - if( SHOW_SEARCHBAR ) +static gboolean history_is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED) +{ + if (SHOW_SEARCHBAR) { GValue val; gchar* text = NULL; gchar* search = (gchar*)gtk_entry_get_text(GTK_ENTRY(history_searchbar_widget)); memset (&val, 0, sizeof(val)); - gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, 1, &val); + + gtk_tree_model_get_value (GTK_TREE_MODEL(model), iter, 1, &val); if(G_VALUE_HOLDS_STRING(&val)){ text = (gchar *)g_value_get_string(&val); } @@ -84,6 +76,5 @@ history_is_visible (GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED g_value_unset (&val); return TRUE; } - return TRUE; } diff --git a/sflphone-client-gnome/src/contacts/searchbar.c b/sflphone-client-gnome/src/contacts/searchbar.c index ca2947e3d8e3473938c5447a9d9de573c818e2c0..f6e60fa77444b298c77a28ade5964cb3ee78d5a4 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.c +++ b/sflphone-client-gnome/src/contacts/searchbar.c @@ -28,35 +28,65 @@ const GdkColor GRAY_COLOR = { 0, 30000, 30000, 30000 }; GtkWidget * searchbox; -void searchbar_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UNUSED){ - // gtk_widget_grab_focus (GTK_WIDGET(searchbox)); +static GtkWidget *menu = NULL; +void searchbar_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data UNUSED) +{ if (active_calltree == contacts) { - addressbook_search(entry); + addressbook_search (entry); } else if (active_calltree == history) { - history_search(entry); + history_search (entry); } - } -// static void -// focus_in_event(GtkWidget *widget, GdkEventFocus *event, gpointer data) -// { - -// } - - -void searchbar_clear_entry_if_default (GtkWidget* widget, gpointer user_data UNUSED) { - - DEBUG("searchbar_clear_entry_if_default\n"); - gtk_widget_modify_text(widget, GTK_STATE_NORMAL, &BLACK_COLOR); - if(g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(widget)), "Search history", 14) == 0 - || g_ascii_strncasecmp(gtk_entry_get_text(GTK_ENTRY(widget)), "Search contact", 14) == 0 ) - gtk_entry_set_text(GTK_ENTRY(widget), ""); +static void search_all (GtkWidget *item, GtkEntry *entry) +{ + gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND); + gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, + "Search all\n" + "Click here to change the search type"); +} - // gtk_widget_grab_focus (GTK_WIDGET(searchbox));1 +static void search_by_missed (GtkWidget *item, GtkEntry *entry) +{ + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/missed.svg", NULL); + gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); + gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, + "Search by missed call\n" + "Click here to change the search type"); +} + +static void search_by_incoming (GtkWidget *item, GtkEntry *entry) +{ + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/incoming.svg", NULL); + gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); + gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, + "Search by incoming call\n" + "Click here to change the search type"); +} + +static void search_by_outgoing (GtkWidget *item, GtkEntry *entry) +{ + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/outgoing.svg", NULL); + gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); + gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, + "Search by outgoing call\n" + "Click here to change the search type"); +} + +static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event, gpointer data) +{ + if (position == GTK_ENTRY_ICON_PRIMARY) + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, + event->button, event->time); + else + gtk_entry_set_text (entry, ""); +} +static void activate_cb (GtkEntry *entry, GtkButton *button) +{ + history_search (entry); } void @@ -72,52 +102,116 @@ focus_on_searchbar_in(){ // gtk_widget_grab_focus(GTK_WIDGET(sw)); focus_is_on_searchbar = TRUE; } - -void -clear_icon_released(GtkEntry *entry, GtkEntryIconPosition position UNUSED, GdkEventButton *event UNUSED, gpointer data UNUSED) + +void searchbar_init(calltab_t *tab) { - DEBUG("Clear Icon Released!\n"); - gtk_entry_set_text(entry, ""); -} - - - void -searchbar_init(calltab_t *tab) -{ - if (tab == contacts) { + if (g_strcasecmp (tab->_name, CONTACTS) == 0) + { addressbook_init(); } - else if (tab == history) { + else if (g_strcasecmp (tab->_name, HISTORY) == 0) + { history_init(); } + else + ERROR ("searchbar.c - searchbar_init should not happen within this widget\n"); } -GtkWidget* searchbar_new(gchar* searchbar_type) { +GtkWidget* history_searchbar_new (void) +{ + + GtkWidget *ret, *item, *image; - GtkWidget* ret = gtk_hbox_new(FALSE, 0); + ret = gtk_hbox_new(FALSE, 0); #if GTK_CHECK_VERSION(2,16,0) + searchbox = gtk_entry_new(); - gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND); gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); - g_signal_connect_after (G_OBJECT (searchbox), "icon-release",G_CALLBACK (clear_icon_released), NULL); + g_signal_connect (searchbox, "icon-press", G_CALLBACK (icon_press_cb), NULL); + //g_signal_connect (searchbox, "activate", G_CALLBACK (activate_cb), NULL); + + // Set up the search icon + search_all (NULL, GTK_ENTRY (searchbox)); + + // Create the menu + menu = gtk_menu_new (); + gtk_menu_attach_to_widget (GTK_MENU (menu), searchbox, NULL); + + image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_MENU); + item = gtk_image_menu_item_new_with_label ("Search all"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + g_signal_connect (item, "activate", G_CALLBACK (search_all), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_image_menu_item_new_with_label ("Search by missed call"); + image = gtk_image_new_from_file (ICONS_DIR "/missed.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + g_signal_connect (item, "activate", G_CALLBACK (search_by_missed), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_image_menu_item_new_with_label ("Search by incoming call"); + image = gtk_image_new_from_file (ICONS_DIR "/incoming.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + g_signal_connect (item, "activate", G_CALLBACK (search_by_incoming), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_image_menu_item_new_with_label ("Search by outgoing call"); + image = gtk_image_new_from_file (ICONS_DIR "/outgoing.svg"); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + g_signal_connect (item, "activate", G_CALLBACK (search_by_outgoing), searchbox); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + gtk_widget_show_all (menu); + #else GtkWidget *image; - printf("Create search bar\n"); searchbox = sexy_icon_entry_new(); image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(searchbox) ); #endif + + g_signal_connect_after(GTK_ENTRY(searchbox), "changed", G_CALLBACK(searchbar_entry_changed), NULL); + g_signal_connect_after (G_OBJECT (searchbox), "focus-in-event", + G_CALLBACK (focus_on_searchbar_in), NULL); + g_signal_connect_after (G_OBJECT (searchbox), "focus-out-event", + G_CALLBACK (focus_on_searchbar_out), NULL); + + gtk_box_pack_start(GTK_BOX(ret), searchbox, TRUE, TRUE, 0); + history_set_searchbar_widget(searchbox); + + return ret; +} + +GtkWidget* contacts_searchbar_new () { + + GtkWidget *ret; + + ret = gtk_hbox_new(FALSE, 0); + +#if GTK_CHECK_VERSION(2,16,0) + searchbox = gtk_entry_new(); + gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); + gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND); + g_signal_connect (searchbox, "icon-press", G_CALLBACK (icon_press_cb), NULL); +#else + + GtkWidget *image; + + searchbox = sexy_icon_entry_new(); + image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR); + sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) ); + sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(searchbox) ); +#endif gtk_widget_modify_text(searchbox, GTK_STATE_NORMAL, &GRAY_COLOR); g_signal_connect_after(GTK_ENTRY(searchbox), "changed", G_CALLBACK(searchbar_entry_changed), NULL); - g_signal_connect_after(GTK_ENTRY(searchbox), "grab-focus", G_CALLBACK(searchbar_clear_entry_if_default), NULL); g_signal_connect_after (G_OBJECT (searchbox), "focus-in-event", G_CALLBACK (focus_on_searchbar_in), NULL); @@ -126,7 +220,7 @@ GtkWidget* searchbar_new(gchar* searchbar_type) { gtk_box_pack_start(GTK_BOX(ret), searchbox, TRUE, TRUE, 0); - history_set_searchbar_widget(searchbox); + //history_set_searchbar_widget(searchbox); return ret; } diff --git a/sflphone-client-gnome/src/contacts/searchbar.h b/sflphone-client-gnome/src/contacts/searchbar.h index a8b6ad0c7175e21825b1b44e548f2d5d4c22a84b..0b16b3dcc1bfe48e5c09d7c040f3243706a3a96b 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.h +++ b/sflphone-client-gnome/src/contacts/searchbar.h @@ -47,7 +47,8 @@ GdkPixbuf *waitingPixOff; * Create a new search bar with "type" passed in * parameter */ -GtkWidget* searchbar_new(gchar*); +GtkWidget* history_searchbar_new (void); +GtkWidget* contacts_searchbar_new (void); /** * Initialize a specific search bar diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 9ae9bbb696a50aa3a6b8207c7f5a8f30ab0dd8e3..f576ea22a2f459e2802ef330f8d5a91b47faa7cc 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -31,6 +31,10 @@ #define LOGO ICONS_DIR "/sflphone.svg" #define LOGO_SMALL ICONS_DIR "/sflphone_small.svg" +#define CURRENT_CALLS "current_calls" +#define HISTORY "history" +#define CONTACTS "contacts" + /** Locale */ #define _(STRING) gettext( STRING )