Commit 314f4084 authored by Emmanuel Milou's avatar Emmanuel Milou

Improve ergonomy when switching between history, main tab and address book

parent e47a6eae
......@@ -28,7 +28,7 @@ sflphone_gtk_SOURCES = \
menus.c \
calltab.c \
calltree.c \
historyfilter.c \
searchfilter.c \
actions.c \
configwindow.c \
accountlist.c \
......@@ -43,7 +43,7 @@ sflphone_gtk_SOURCES = \
noinst_HEADERS = actions.h dbus.h sflnotify.h mainwindow.h calllist.h dialpad.h audioconf.h codeclist.h assistant.h \
callmanager-glue.h errors.h sflphone_const.h configurationmanager-glue.h instance-glue.h menus.h calltab.h calltree.h configwindow.h \
accountlist.h accountwindow.h marshaller.h sliders.h $(STATUSICON_HEADER) timestamp.h historyfilter.c reqaccount.h addressbook-config.h
accountlist.h accountwindow.h marshaller.h sliders.h $(STATUSICON_HEADER) timestamp.h searchfilter.h reqaccount.h addressbook-config.h
EXTRA_DIST = marshaller.list
......
......@@ -25,7 +25,7 @@
#include <menus.h>
#include <statusicon.h>
#include <calltab.h>
#include <historyfilter.h>
#include <searchfilter.h>
#include <contactlist/eds.h>
#include <gtk/gtk.h>
......@@ -37,7 +37,7 @@
guint voice_mails;
void
void
sflphone_notify_voice_mail ( const gchar* accountID , guint count )
{
gchar *id;
......@@ -71,7 +71,7 @@ sflphone_notify_voice_mail ( const gchar* accountID , guint count )
}
}
void
void
status_bar_display_account( call_t* c)
{
gchar* msg;
......@@ -87,7 +87,7 @@ status_bar_display_account( call_t* c)
}
gboolean
gboolean
sflphone_quit ()
{
gboolean quit = FALSE;
......@@ -110,7 +110,7 @@ sflphone_quit ()
return quit;
}
void
void
sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
......@@ -118,7 +118,7 @@ sflphone_hold(call_t * c )
update_menus();
}
void
void
sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
......@@ -126,7 +126,7 @@ sflphone_ringing(call_t * c )
update_menus();
}
void
void
sflphone_hung_up( call_t * c)
{
call_list_remove( current_calls, c->callID);
......@@ -244,7 +244,7 @@ gboolean sflphone_init()
}
}
void
void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(current_calls);
......@@ -292,7 +292,7 @@ sflphone_hang_up()
}
void
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected(active_calltree);
......@@ -330,7 +330,7 @@ sflphone_pick_up()
}
}
void
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
......@@ -352,7 +352,7 @@ sflphone_on_hold ()
}
}
void
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
......@@ -371,7 +371,7 @@ sflphone_off_hold ()
}
void
void
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
......@@ -379,7 +379,7 @@ sflphone_fail( call_t * c )
update_menus();
}
void
void
sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
......@@ -387,7 +387,7 @@ sflphone_busy( call_t * c )
update_menus();
}
void
void
sflphone_current( call_t * c )
{
if( c->state != CALL_STATE_HOLD )
......@@ -397,7 +397,7 @@ sflphone_current( call_t * c )
update_menus();
}
void
void
sflphone_record( call_t * c )
{
if( c->state != CALL_STATE_HOLD )
......@@ -407,7 +407,7 @@ sflphone_record( call_t * c )
update_menus();
}
void
void
sflphone_set_transfert()
{
call_t * c = call_get_selected(current_calls);
......@@ -421,7 +421,7 @@ sflphone_set_transfert()
toolbar_update_buttons();
}
void
void
sflphone_unset_transfert()
{
call_t * c = call_get_selected(current_calls);
......@@ -435,7 +435,7 @@ sflphone_unset_transfert()
toolbar_update_buttons();
}
void
void
sflphone_incoming_call (call_t * c)
{
c->history_state = MISSED;
......@@ -443,10 +443,10 @@ sflphone_incoming_call (call_t * c)
call_list_add( history, c );
update_call_tree_add( current_calls , c );
update_menus();
switch_tab(current_calls);
display_calltree (current_calls);
}
void
void
process_dialing(call_t * c, guint keyval, gchar * key)
{
// We stop the tone
......@@ -521,7 +521,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
}
call_t *
call_t *
sflphone_new_call()
{
......@@ -551,7 +551,7 @@ sflphone_new_call()
}
void
void
sflphone_keypad( guint keyval, gchar * key)
{
call_t * c = call_get_selected(current_calls);
......@@ -567,7 +567,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65307: /* ESCAPE */
break;
default:
switch_tab(current_calls);
display_calltree (current_calls);
process_dialing(sflphone_new_call(), keyval, key);
break;
}
......@@ -668,7 +668,7 @@ sflphone_keypad( guint keyval, gchar * key)
break;
}
}
}
}
/*
* Place a call with the current account.
......@@ -676,7 +676,7 @@ sflphone_keypad( guint keyval, gchar * key)
* registered account of the account list
* Else, popup an error message
*/
void
void
sflphone_place_call ( call_t * c )
{
......@@ -749,7 +749,7 @@ sflphone_place_call ( call_t * c )
}
void
void
sflphone_display_selected_codec (const gchar* codecName)
{
call_t * selectedCall = call_get_selected(current_calls);
......@@ -767,14 +767,14 @@ sflphone_display_selected_codec (const gchar* codecName)
}
gchar*
gchar*
sflphone_get_current_codec_name()
{
call_t * selectedCall = call_get_selected(current_calls);
return dbus_get_current_codec_name(selectedCall);
}
void
void
sflphone_rec_call()
{
call_t * selectedCall = call_get_selected(current_calls);
......@@ -801,7 +801,7 @@ sflphone_rec_call()
}
/* Internal to action - set the __CURRENT_ACCOUNT variable */
void
void
sflphone_set_current_account()
{
if( account_list_get_size() > 0 )
......@@ -810,7 +810,7 @@ sflphone_set_current_account()
/* Internal to action - get the codec list */
void
void
sflphone_fill_codec_list()
{
......
......@@ -37,9 +37,11 @@ GtkToolItem * hangupButton;
GtkToolItem * holdButton;
GtkToolItem * transfertButton;
GtkToolItem * unholdButton;
// GtkToolItem * historyButton;
GtkToolItem * mailboxButton;
GtkToolItem * recButton;
GtkToolItem * historyButton;
GtkToolItem * contactButton;
guint transfertButtonConnId; //The button toggled signal connection ID
void
......@@ -117,18 +119,18 @@ call_button( GtkWidget *widget UNUSED, gpointer data UNUSED)
call_list_add(current_calls, new_call);
update_call_tree_add(current_calls, new_call);
sflphone_place_call(new_call);
switch_tab(current_calls);
display_calltree (current_calls);
}
else
{
sflphone_new_call();
switch_tab(current_calls);
display_calltree(current_calls);
}
}
else
{
sflphone_new_call();
switch_tab(current_calls);
display_calltree(current_calls);
}
}
......@@ -177,123 +179,19 @@ unhold( GtkWidget *widget UNUSED, gpointer data UNUSED)
sflphone_off_hold();
}
static void
show_current_calls_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
gpointer user_data UNUSED)
static void toggle_button_cb (GtkToggleToolButton *widget, gpointer user_data)
{
GtkTreeSelection *sel;
gchar* msg;
// temporary display in status bar
msg = g_strdup("Current calls");
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
active_calltree = current_calls;
gtk_widget_hide(history->tree);
gtk_widget_hide(contacts->tree);
gtk_widget_show(current_calls->tree);
printf("current calls toggle\n");
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
}
static void
show_history_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
gpointer user_data UNUSED)
{
GtkTreeSelection *sel;
gchar* msg;
// temporary display in status bar
msg = g_strdup("History");
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
active_calltree = history;
gtk_widget_hide(current_calls->tree);
gtk_widget_hide(contacts->tree);
gtk_widget_show(history->tree);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
}
static void
handler_async_search (GList *hits, gpointer user_data) {
calltab_t * to_switch;
gboolean toggle;
GtkTreeSelection *sel;
GList *i;
GdkPixbuf *photo = NULL;
AddressBook_Config *addressbook_config;
call_t *j;
// Load the parameters
addressbook_load_parameters (&addressbook_config);
// freeing calls
while((j = (call_t *)g_queue_pop_tail (contacts->callQueue)) != NULL)
{
free_call_t(j);
}
// reset previous results
reset_call_tree(contacts);
call_list_reset(contacts);
for (i = hits; i != NULL; i = i->next)
{
Hit *entry;
entry = i->data;
if (entry)
{
/* Get the photo */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
photo = entry->photo;
/* Create entry for business phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS))
create_new_entry_in_contactlist (entry->name, entry->phone_business, CONTACT_PHONE_BUSINESS, photo);
/* Create entry for home phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_HOME))
create_new_entry_in_contactlist (entry->name, entry->phone_home, CONTACT_PHONE_HOME, photo);
/* Create entry for mobile phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_MOBILE))
create_new_entry_in_contactlist (entry->name, entry->phone_mobile, CONTACT_PHONE_MOBILE, photo);
}
free_hit(entry);
}
g_list_free(hits);
to_switch = (calltab_t*) user_data;
toggle = gtk_toggle_tool_button_get_active (widget);
active_calltree = contacts;
gtk_widget_hide(current_calls->tree);
gtk_widget_hide(history->tree);
gtk_widget_show(contacts->tree);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
g_print ("%i\n", toggle);
(toggle)? display_calltree (to_switch) : display_calltree (current_calls);
}
static void
show_contacts_tab(GtkToggleToolButton *toggle_tool_button UNUSED,
gpointer user_data UNUSED)
{
gchar* msg;
// temporary display in status bar
msg = g_strdup("Contacts");
statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
// do an asynchronous search
search_async (gtk_entry_get_text (GTK_ENTRY (filter_entry)), 50, &handler_async_search, NULL);
}
void create_new_entry_in_contactlist (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo){
......@@ -354,7 +252,7 @@ call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
update_call_tree_add( current_calls , mailbox_call );
update_menus();
sflphone_place_call( mailbox_call );
switch_tab(current_calls);
display_calltree(current_calls);
}
......@@ -545,7 +443,7 @@ void row_activated(GtkTreeView *tree_view UNUSED,
call_list_add(current_calls, new_call);
update_call_tree_add(current_calls, new_call);
sflphone_place_call(new_call);
switch_tab(current_calls);
display_calltree(current_calls);
}
}
}
......@@ -625,22 +523,24 @@ create_toolbar ()
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(transfertButton), -1);
image = gtk_image_new_from_file( ICONS_DIR "/history2.svg");
historyButton = gtk_tool_button_new(image, _("History"));
historyButton = gtk_toggle_tool_button_new();
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (historyButton), image);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text(GTK_WIDGET(historyButton), _("History"));
#endif
g_signal_connect (G_OBJECT (historyButton), "clicked",
G_CALLBACK (show_history_tab), NULL);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (historyButton), _("History"));
g_signal_connect (G_OBJECT (historyButton), "toggled", G_CALLBACK (toggle_button_cb), history);
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(historyButton), -1);
active_calltree = current_calls;
image = gtk_image_new_from_file( ICONS_DIR "/addressbook.svg");
contactButton = gtk_tool_button_new(image, _("Contacts"));
contactButton = gtk_toggle_tool_button_new();
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (contactButton), image);
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text(GTK_WIDGET(contactButton), _("Contacts"));
gtk_widget_set_tooltip_text(GTK_WIDGET(contactButton), _("Address book"));
#endif
g_signal_connect (G_OBJECT (contactButton), "clicked",
G_CALLBACK (show_contacts_tab), NULL);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (contactButton), _("Address book"));
g_signal_connect (G_OBJECT (contactButton), "toggled", G_CALLBACK (toggle_button_cb), contacts);
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(contactButton), -1);
image = gtk_image_new_from_file( ICONS_DIR "/mailbox.svg");
......@@ -1010,39 +910,82 @@ update_call_tree_add (calltab_t* tab, call_t * c)
toolbar_update_buttons();
}
void display_calltree (calltab_t *tab) {
void
refresh_tab(calltab_t* tab)
{
if(tab == contacts)
{
show_contacts_tab(NULL, NULL);
}
else if (tab == history)
{
show_history_tab(NULL, NULL);
GtkTreeSelection *sel;
g_print ("display_calltree called\n");
/* If we already are displaying the specified calltree */
if (active_calltree == tab)
return;
/* case 1: we want to display the main calltree */
if (tab==current_calls) {
g_print ("display main tab\n");
if (active_calltree==contacts) {
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, FALSE);
} else {
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, FALSE);
}
else
{
show_current_calls_tab(NULL, NULL);
}
}
void
switch_tab(calltab_t* tab)
{
if(active_calltree != tab)
{
if(tab == contacts)
{
show_contacts_tab(NULL, NULL);
/* case 2: we want to display the history */
else if (tab==history) {
g_print ("display history tab\n");
if (active_calltree==contacts) {
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, FALSE);
}
else if (tab == history)
{
show_history_tab(NULL, NULL);
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, TRUE);
}
else
{
show_current_calls_tab(NULL, NULL);
else if (tab==contacts) {
g_print ("display contact tab\n");
if (active_calltree==history) {
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)historyButton, FALSE);
}
gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)contactButton, TRUE);
}
else
g_print ("calltree.c line 1050 . This is probably a bug in the application\n");
gtk_widget_hide (active_calltree->tree);
active_calltree = tab;
gtk_widget_show (active_calltree->tree);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
//gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
}
......@@ -31,9 +31,6 @@
* @brief The GtkTreeView that list calls in the main window.
*/
GtkToolItem * historyButton;
GtkToolItem * contactButton;
GtkWidget * filter_entry;
calltab_t* active_calltree;
......@@ -76,9 +73,7 @@ void reset_call_tree (calltab_t* tab);
*/
GtkWidget * create_toolbar();
void switch_tab( calltab_t* tab );
void refresh_tab( calltab_t* tab );
void display_calltree (calltab_t *tab);
void create_new_entry_in_contactlist (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo);
......
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <historyfilter.h>
#include <calltree.h>
GtkTreeModel*