Skip to content
Snippets Groups Projects
Commit efbec726 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3854] Create menu for addressbook

parent fec2421b
Branches
Tags
No related merge requests found
......@@ -136,8 +136,6 @@ void threaded_clock_incrementer (void *pc)
while (call->clockStarted) {
DEBUG ("CALL CLOCK");
int duration;
time_t start, current;
......
......@@ -733,3 +733,19 @@ fetch_information_from_contact (EContact *contact, EContactField field, gchar **
*info = g_strdup (to_fetch);
}
void
set_current_addressbook (const gchar *name)
{
GSList *book_list_iterator;
book_data_t *book_data;
// Iterate throw the list
for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator
= book_list_iterator->next) {
book_data = (book_data_t *) book_list_iterator->data;
if (strcmp (book_data->name, name) == 0)
current_uri = book_data->uri;
}
}
......@@ -109,19 +109,6 @@ init (OpenAsyncHandler);
void
fill_books_data (void);
/**
* Asynchronous search function (without the get_contacts method)
*/
void
search_async (const char *query, int max_results, SearchAsyncHandler handler,
gpointer user_data);
/**
* Synchronous query to EDS using get_contacts method. Block the application until a result is received.
*/
void
search_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data);
/**
* Asynchronous query to EDS using get contact method.
*/
......@@ -159,6 +146,12 @@ books_active();
GSList *
addressbook_get_books_data();
/**
* Set the current address book
*/
void
set_current_addressbook (const gchar *name);
G_END_DECLS
#endif /* __EDS_H__ */
......@@ -33,6 +33,7 @@
#include <searchbar.h>
#include <calltree.h>
#include <contacts/addressbook/eds.h>
GtkWidget * searchbox;
......@@ -58,6 +59,13 @@ void searchbar_entry_changed (GtkEntry* entry, gchar* arg1 UNUSED, gpointer data
#if GTK_CHECK_VERSION(2,16,0)
static void select_addressbook (GtkWidget *item, GtkEntry *entry)
{
DEBUG ("Searchbar: Selected item label %s", gtk_menu_item_get_label (item));
set_current_addressbook (gtk_menu_item_get_label (item));
}
static void search_all (GtkWidget *item UNUSED, GtkEntry *entry)
{
HistorySearchType = SEARCH_ALL;
......@@ -109,10 +117,16 @@ static void search_by_outgoing (GtkWidget *item UNUSED, GtkEntry *entry)
static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event, gpointer data UNUSED)
{
DEBUG ("Searchbar: Icon pressed");
if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == history)
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
event->button, event->time);
else
else if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == contacts) {
GtkWidget *addrbook_menu = addressbook_menu_new();
gtk_menu_popup (GTK_MENU (addrbook_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
} else
gtk_entry_set_text (entry, "");
}
......@@ -126,6 +140,33 @@ static void text_changed_cb (GtkEntry *entry, GParamSpec *pspec UNUSED)
#endif
GtkWidget *addressbook_menu_new (void)
{
GtkWidget *menu, *item;
GSList *book_list_iterator;
book_data_t *book_data;
GSList *books_data = addressbook_get_books_data();
// Create the menu
menu = gtk_menu_new ();
gtk_menu_attach_to_widget (GTK_MENU (menu), contacts->searchbar, NULL);
// Populate menu
for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator
= book_list_iterator->next) {
book_data = (book_data_t *) book_list_iterator->data;
item = gtk_menu_item_new_with_label (book_data->name);
g_signal_connect (item, "activate", G_CALLBACK (select_addressbook), searchbox);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
gtk_widget_show_all (menu);
return menu;
}
void
focus_on_searchbar_out()
{
......
......@@ -81,4 +81,6 @@ void activateWaitingLayer();
*/
void deactivateWaitingLayer();
GtkWidget *addressbook_menu_new (void);
#endif
......@@ -85,7 +85,7 @@ void
update_actions()
{
DEBUG ("Update action");
DEBUG ("UIManager: Update action");
gtk_action_set_sensitive (GTK_ACTION (newCallAction), TRUE);
gtk_action_set_sensitive (GTK_ACTION (pickUpAction), FALSE);
......@@ -510,7 +510,7 @@ conference_hold (void* foo UNUSED)
static void
call_pick_up (void * foo UNUSED)
{
DEBUG ("------ call_button -----");
DEBUG ("UIManager: Call_button");
callable_obj_t * selectedCall;
callable_obj_t* new_call;
......@@ -577,7 +577,7 @@ remove_from_history (void * foo UNUSED)
callable_obj_t* c = calltab_get_selected_call (history);
if (c) {
DEBUG ("Remove the call from the history");
DEBUG ("UIManager: Remove the call from the history");
calllist_remove_from_history (c);
}
}
......@@ -637,7 +637,7 @@ edit_copy (void * foo UNUSED)
break;
}
DEBUG ("Clipboard number: %s\n", no);
DEBUG ("UIManager: Clipboard number: %s\n", no);
gtk_clipboard_set_text (clip, no, strlen (no));
}
......@@ -716,7 +716,7 @@ edit_paste (void * foo UNUSED)
selectedCall->_peer_number = g_strconcat (selectedCall->_peer_number, no,
NULL);
g_free (before);
DEBUG ("TO: %s", selectedCall->_peer_number);
DEBUG ("UIManager: TO: %s", selectedCall->_peer_number);
g_free (selectedCall->_peer_info);
selectedCall->_peer_info = g_strconcat ("\"\" <",
......@@ -952,7 +952,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
conference_obj_t * selectedConf;
if (calltab_get_selected_type (current_calls) == A_CALL) {
DEBUG ("MENUS: SELECTED A CALL");
DEBUG ("UIManager: Menus: Selected a call");
selectedCall = calltab_get_selected_call (current_calls);
if (selectedCall) {
......@@ -990,13 +990,13 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
hangup = TRUE;
break;
default:
WARN ("Should not happen in show_popup_menu for calls!")
WARN ("UIManager: Should not happen in show_popup_menu for calls!")
;
break;
}
}
} else {
DEBUG ("MENUS: SELECTED A CONF");
DEBUG ("UIManager: Menus: selected a conf");
selectedConf = calltab_get_selected_conf();
if (selectedConf) {
......@@ -1012,7 +1012,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
hold_conf = TRUE;
break;
default:
WARN ("Should not happen in show_popup_menu for conferences!")
WARN ("UIManager: Should not happen in show_popup_menu for conferences!")
;
break;
}
......@@ -1030,7 +1030,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
//g_signal_connect (menu, "deactivate",
// G_CALLBACK (gtk_widget_destroy), NULL);
if (calltab_get_selected_type (current_calls) == A_CALL) {
DEBUG ("BUILD CALL MENU");
DEBUG ("UIManager: Build call menu");
if (copy) {
menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY,
......@@ -1103,7 +1103,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
}
} else {
DEBUG ("BUILD CONFERENCE MENU");
DEBUG ("UIManager: Build call menus");
if (hangup_conf) {
menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Hang up"));
......@@ -1148,6 +1148,8 @@ void
show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event)
{
DEBUG ("UIManager: Show popup menu history");
gboolean pickup = FALSE;
gboolean remove = FALSE;
gboolean edit = FALSE;
......@@ -1216,6 +1218,75 @@ show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event)
gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time);
}
/*
void
show_popup_menu_addressbook (GtkWidget *my_widget, GdkEventButton *event)
{
if (selectedCall) {
remove = TRUE;
pickup = TRUE;
edit = TRUE;
accounts = TRUE;
}
GtkWidget *menu;
GtkWidget *image;
int button, event_time;
GtkWidget * menu_items;
menu = gtk_menu_new();
//g_signal_connect (menu, "deactivate",
// G_CALLBACK (gtk_widget_destroy), NULL);
if (pickup) {
menu_items = gtk_image_menu_item_new_with_mnemonic (_ ("_Call back"));
image = gtk_image_new_from_file (ICONS_DIR "/icon_accept.svg");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (call_back), NULL);
gtk_widget_show (menu_items);
}
menu_items = gtk_separator_menu_item_new();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
if (edit) {
menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_EDIT,
get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",G_CALLBACK (edit_number_cb), selectedCall);
gtk_widget_show (menu_items);
}
if (remove) {
menu_items = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE,
get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate", G_CALLBACK (remove_from_history), NULL);
gtk_widget_show (menu_items);
}
if (accounts) {
add_registered_accounts_to_menu (menu);
}
if (event) {
button = event->button;
event_time = event->time;
} else {
button = 0;
event_time = gtk_get_current_event_time();
}
gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time);
}
*/
void
show_popup_menu_contacts (GtkWidget *my_widget, GdkEventButton *event)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment