Commit 4b50bda6 authored by Julien Bonjean's avatar Julien Bonjean

Fixed toggle button references

parent 4ec27bb1
......@@ -444,7 +444,7 @@ sflphone_incoming_call (call_t * c)
call_list_add( history, c );
update_call_tree_add( current_calls , c );
update_menus();
if( active_calltree == history ) switch_tab();
switch_tab(current_calls);
}
void
......@@ -662,8 +662,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65307: /* ESCAPE */
break;
default:
if( active_calltree == history )
switch_tab();
switch_tab(current_calls);
process_dialing(sflphone_new_call(), keyval, key);
break;
}
......
......@@ -43,14 +43,6 @@ GtkToolItem * recButton;
guint transfertButtonConnId; //The button toggled signal connection ID
gboolean history_shown;
void
switch_tab()
{
(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(historyButton)))?
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), FALSE):
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
}
/**
* Show popup menu
*/
......@@ -114,18 +106,18 @@ call_button( GtkWidget *widget UNUSED, gpointer data UNUSED)
call_list_add(current_calls, newCall);
update_call_tree_add(current_calls, newCall);
sflphone_place_call(newCall);
if( active_calltree == history ) switch_tab();
switch_tab(current_calls);
}
else
{
sflphone_new_call();
if( active_calltree == history ) switch_tab();
switch_tab(current_calls);
}
}
else
{
sflphone_new_call();
if( active_calltree == history ) switch_tab();
switch_tab(current_calls);
}
}
......@@ -174,6 +166,23 @@ unhold( GtkWidget *widget UNUSED, gpointer data UNUSED)
sflphone_off_hold();
}
static void
toggle_current_calls(GtkToggleToolButton *toggle_tool_button UNUSED,
gpointer user_data UNUSED)
{
GtkTreeSelection *sel;
active_calltree = current_calls;
gtk_widget_hide(history->tree);
gtk_widget_hide(contacts->tree);
gtk_widget_show(current_calls->tree);
history_shown = FALSE;
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
}
static void
toggle_history(GtkToggleToolButton *toggle_tool_button UNUSED,
gpointer user_data UNUSED)
......@@ -241,6 +250,7 @@ toggle_contacts(GtkToggleToolButton *toggle_tool_button UNUSED,
gtk_widget_hide(current_calls->tree);
gtk_widget_hide(history->tree);
gtk_widget_show(contacts->tree);
active_calltree = contacts;
history_shown = FALSE;
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (contacts->view));
......@@ -270,7 +280,7 @@ call_mailbox( GtkWidget* widget UNUSED, gpointer data UNUSED)
update_call_tree_add( current_calls , mailboxCall );
update_menus();
sflphone_place_call( mailboxCall );
if( active_calltree == history ) switch_tab();
switch_tab(current_calls);
}
......@@ -465,7 +475,7 @@ void row_activated(GtkTreeView *tree_view UNUSED,
call_list_add(current_calls, newCall);
update_call_tree_add(current_calls, newCall);
sflphone_place_call(newCall);
switch_tab();
switch_tab(current_calls);
}
}
}
......@@ -926,3 +936,23 @@ update_call_tree_add (calltab_t* tab, call_t * c)
gtk_tree_selection_select_iter(GTK_TREE_SELECTION(sel), &iter);
toolbar_update_buttons();
}
void
switch_tab(calltab_t* tab)
{
if(active_calltree != tab)
{
if(tab == contacts)
{
toggle_contacts(NULL, NULL);
}
else if (tab == history)
{
toggle_history(NULL, NULL);
}
else
{
toggle_current_calls(NULL, NULL);
}
}
}
......@@ -71,6 +71,6 @@ void reset_call_tree (calltab_t* tab);
*/
GtkWidget * create_toolbar();
void switch_tab( void );
void switch_tab( calltab_t* tab );
#endif
/*
* 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.
......@@ -30,7 +30,7 @@ create_filter(GtkTreeModel* child)
GtkTreeModel* ret = gtk_tree_model_filter_new(child, NULL);
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(ret), is_visible, NULL, NULL);
return GTK_TREE_MODEL(ret);
}
}
gboolean
is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
......@@ -53,13 +53,12 @@ is_visible(GtkTreeModel* model, GtkTreeIter* iter, gpointer data UNUSED)
return TRUE;
}
return TRUE;
}
}
void
filter_entry_changed(GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
{
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton), TRUE);
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(histfilter));
{
switch_tab(history);
}
void
......@@ -70,17 +69,17 @@ clear_filter_entry_if_default(GtkWidget* widget UNUSED, gpointer user_data UNUSE
}
GtkWidget*
create_filter_entry()
create_filter_entry()
{
GtkWidget* image;
GtkWidget* ret = gtk_hbox_new(FALSE, 0);
filter_entry = sexy_icon_entry_new();
//filter_entry = gtk_entry_new();
image = gtk_image_new_from_stock( GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(filter_entry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(filter_entry) );
gtk_entry_set_text(GTK_ENTRY(filter_entry), _("Search"));
gtk_entry_set_text(GTK_ENTRY(filter_entry), _("Search"));
g_signal_connect(GTK_ENTRY(filter_entry), "changed", G_CALLBACK(filter_entry_changed), NULL);
g_signal_connect(GTK_ENTRY(filter_entry), "grab-focus", G_CALLBACK(clear_filter_entry_if_default), NULL);
......
......@@ -2,17 +2,17 @@
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@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.
......@@ -48,7 +48,7 @@ GtkWidget * searchbarMenu;
void update_menus()
{
{
//Block signals for holdMenu
gtk_signal_handler_block(GTK_OBJECT(holdMenu), holdConnId);
......@@ -63,7 +63,7 @@ void update_menus()
if (selectedCall)
{
gtk_widget_set_sensitive( GTK_WIDGET(copyMenu), TRUE);
switch(selectedCall->state)
switch(selectedCall->state)
{
case CALL_STATE_INCOMING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
......@@ -95,12 +95,12 @@ void update_menus()
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
break;
default:
g_warning("Should not happen in update_menus()!");
break;
}
}
}
else
{
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu), TRUE);
......@@ -109,22 +109,22 @@ void update_menus()
}
/* ----------------------------------------------------------------- */
static void
static void
help_about ( void * foo UNUSED)
{
gchar *authors[] = {
"Yan Morin <yan.morin@savoirfairelinux.com>",
"Yan Morin <yan.morin@savoirfairelinux.com>",
"Jérôme Oufella <jerome.oufella@savoirfairelinux.com>",
"Julien Plissonneau Duquene <julien.plissonneau.duquene@savoirfairelinux.com>",
"Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>",
"Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
"Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
"Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>",
"Yun Liu <yun.liu@savoirfairelinux.com>"
"Jean-Philippe Barrette-LaPierre",
"Laurielle Lea",
NULL};
gchar *artists[] = {
"Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
"Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>",
"Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>",
NULL};
......@@ -141,7 +141,7 @@ help_about ( void * foo UNUSED)
}
GtkWidget *
GtkWidget *
create_help_menu()
{
GtkWidget * menu;
......@@ -153,7 +153,7 @@ create_help_menu()
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_ABOUT, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (help_about),
G_CALLBACK (help_about),
NULL);
gtk_widget_show (menu_items);
......@@ -163,19 +163,19 @@ create_help_menu()
return root_menu;
}
/* ----------------------------------------------------------------- */
static void
static void
call_new_call ( void * foo UNUSED)
{
sflphone_new_call();
}
static void
static void
call_quit ( void * foo UNUSED)
{
sflphone_quit();
}
static void
static void
call_minimize ( void * foo UNUSED)
{
#if GTK_CHECK_VERSION(2,10,0)
......@@ -192,11 +192,11 @@ switch_account( GtkWidget* item , gpointer data UNUSED)
account_list_set_current_id( acc->accountID );
}
static void
static void
call_hold (void* foo UNUSED)
{
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
if(selectedCall->state == CALL_STATE_HOLD)
......@@ -208,29 +208,29 @@ call_hold (void* foo UNUSED)
{
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg"));
sflphone_on_hold();
}
}
}
}
}
static void
static void
call_pick_up ( void * foo UNUSED)
{
sflphone_pick_up();
}
static void
static void
call_hang_up ( void * foo UNUSED)
{
sflphone_hang_up();
}
static void
static void
call_record ( void * foo UNUSED)
{
sflphone_rec_call();
}
static void
static void
call_wizard ( void * foo UNUSED)
{
#if GTK_CHECK_VERSION(2,10,0)
......@@ -259,17 +259,17 @@ call_back( void * foo UNUSED)
newCall->from = g_strconcat("\"\" <", call_get_number(selectedCall), ">",NULL);
newCall->state = CALL_STATE_DIALING;
newCall->callID = g_new0(gchar, 30);
g_sprintf(newCall->callID, "%d", rand());
g_sprintf(newCall->callID, "%d", rand());
newCall->_start = 0;
newCall->_stop = 0;
call_list_add(current_calls, newCall);
update_call_tree_add(current_calls, newCall);
sflphone_place_call(newCall);
switch_tab();
}
switch_tab(current_calls);
}
}
GtkWidget *
GtkWidget *
create_call_menu()
{
GtkWidget * menu;
......@@ -284,7 +284,7 @@ create_call_menu()
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( newCallMenu ), image );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), newCallMenu);
g_signal_connect_swapped (G_OBJECT (newCallMenu), "activate",
G_CALLBACK (call_new_call),
G_CALLBACK (call_new_call),
NULL);
gtk_widget_show (newCallMenu);
......@@ -297,7 +297,7 @@ create_call_menu()
gtk_menu_shell_append (GTK_MENU_SHELL (menu), pickUpMenu);
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
g_signal_connect_swapped (G_OBJECT (pickUpMenu), "activate",
G_CALLBACK (call_pick_up),
G_CALLBACK (call_pick_up),
NULL);
gtk_widget_show (pickUpMenu);
......@@ -307,7 +307,7 @@ create_call_menu()
gtk_menu_shell_append (GTK_MENU_SHELL (menu), hangUpMenu);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
g_signal_connect_swapped (G_OBJECT (hangUpMenu), "activate",
G_CALLBACK (call_hang_up),
G_CALLBACK (call_hang_up),
NULL);
gtk_widget_show (hangUpMenu);
......@@ -319,7 +319,7 @@ create_call_menu()
//Here we connect only to activate
//The toggled state is managed from update_menus()
holdConnId = g_signal_connect(G_OBJECT (holdMenu), "activate",
G_CALLBACK (call_hold),
G_CALLBACK (call_hold),
NULL);
gtk_widget_show (menu_items);
......@@ -329,7 +329,7 @@ create_call_menu()
gtk_menu_shell_append (GTK_MENU_SHELL (menu), recordMenu);
gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), FALSE);
g_signal_connect_swapped (G_OBJECT (recordMenu), "activate",
G_CALLBACK (call_record),
G_CALLBACK (call_record),
NULL);
gtk_widget_show (recordMenu);
......@@ -351,7 +351,7 @@ create_call_menu()
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_CLOSE, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_minimize),
G_CALLBACK (call_minimize),
NULL);
gtk_widget_show (menu_items);
......@@ -363,7 +363,7 @@ create_call_menu()
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_QUIT, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_quit),
G_CALLBACK (call_quit),
NULL);
gtk_widget_show (menu_items);
......@@ -375,20 +375,20 @@ create_call_menu()
}
/* ----------------------------------------------------------------- */
static void
static void
edit_preferences ( void * foo UNUSED)
{
show_config_window();
}
static void
static void
edit_accounts ( void * foo UNUSED)
{
show_accounts_window();
}
// The menu Edit/Copy should copy the current selected call's number
static void
static void
edit_copy ( void * foo UNUSED)
{
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
......@@ -399,7 +399,7 @@ edit_copy ( void * foo UNUSED)
{
switch(selectedCall->state)
{
case CALL_STATE_TRANSFERT:
case CALL_STATE_TRANSFERT:
case CALL_STATE_DIALING:
case CALL_STATE_RINGING:
no = selectedCall->to;
......@@ -420,7 +420,7 @@ edit_copy ( void * foo UNUSED)
}
// The menu Edit/Paste should paste the clipboard into the current selected call
static void
static void
edit_paste ( void * foo UNUSED)
{
GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
......@@ -431,10 +431,10 @@ edit_paste ( void * foo UNUSED)
{
switch(selectedCall->state)
{
case CALL_STATE_TRANSFERT:
case CALL_STATE_TRANSFERT:
case CALL_STATE_DIALING:
// Add the text to the number
{
{
gchar * before = selectedCall->to;
selectedCall->to = g_strconcat(selectedCall->to, no, NULL);
g_free(before);
......@@ -448,7 +448,7 @@ edit_paste ( void * foo UNUSED)
update_call_tree(current_calls, selectedCall);
}
break;
case CALL_STATE_RINGING:
case CALL_STATE_RINGING:
case CALL_STATE_INCOMING:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
......@@ -514,7 +514,7 @@ clear_history (void)
}
}
GtkWidget *
GtkWidget *
create_edit_menu()
{
GtkWidget * menu;
......@@ -527,14 +527,14 @@ create_edit_menu()
copyMenu = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), copyMenu);
g_signal_connect_swapped (G_OBJECT (copyMenu), "activate",
G_CALLBACK (edit_copy),
G_CALLBACK (edit_copy),
NULL);
gtk_widget_show (copyMenu);
pasteMenu = gtk_image_menu_item_new_from_stock( GTK_STOCK_PASTE, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), pasteMenu);
g_signal_connect_swapped (G_OBJECT (pasteMenu), "activate",
G_CALLBACK (edit_paste),
G_CALLBACK (edit_paste),
NULL);
gtk_widget_show (pasteMenu);
......@@ -546,9 +546,9 @@ create_edit_menu()
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_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (clear_history),
G_CALLBACK (clear_history),
NULL);
gtk_widget_show (menu_items);
gtk_widget_show (menu_items);
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
......@@ -556,16 +556,16 @@ create_edit_menu()
menu_items = gtk_menu_item_new_with_mnemonic( _("_Accounts") );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_accounts),
G_CALLBACK (edit_accounts),
NULL);
gtk_widget_show (menu_items);
gtk_widget_show (menu_items);
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PREFERENCES, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect_swapped (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_preferences),
G_CALLBACK (edit_preferences),
NULL);
gtk_widget_show (menu_items);
gtk_widget_show (menu_items);
root_menu = gtk_menu_item_new_with_mnemonic (_("_Edit"));
......@@ -574,7 +574,7 @@ create_edit_menu()
return root_menu;
}
/* ----------------------------------------------------------------- */
static void
static void
view_dialpad (GtkImageMenuItem *imagemenuitem UNUSED,
void* foo UNUSED)
{
......@@ -583,15 +583,15 @@ view_dialpad (GtkImageMenuItem *imagemenuitem UNUSED,
if( state )
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ),
gtk_image_new_from_file( ICONS_DIR "/icon_dialpad_off.svg"));
else
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ),
else
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ),
gtk_image_new_from_file( ICONS_DIR "/icon_dialpad.svg"));
dbus_set_dialpad( state );
}
static void
static void
view_volume_controls (GtkImageMenuItem *imagemenuitem UNUSED,
void* foo UNUSED)
{
......@@ -600,13 +600,13 @@ view_volume_controls (GtkImageMenuItem *imagemenuitem UNUSED,
if( state )
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ),
gtk_image_new_from_file( ICONS_DIR "/icon_volume_off.svg"));
else
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ),
else
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ),
gtk_image_new_from_file( ICONS_DIR "/icon_volume.svg"));
dbus_set_volume_controls( state );
}
static void
static void
view_searchbar (GtkImageMenuItem *imagemenuitem UNUSED,
void* foo UNUSED)
{
......@@ -615,7 +615,7 @@ view_searchbar (GtkImageMenuItem *imagemenuitem UNUSED,
dbus_set_searchbar( state );
}
GtkWidget *
GtkWidget *
create_view_menu()
{
GtkWidget * menu;
......@@ -632,7 +632,7 @@ create_view_menu()
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( dialpadMenu ), image );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), dialpadMenu);
g_signal_connect(G_OBJECT ( dialpadMenu ), "activate",
G_CALLBACK (view_dialpad),
G_CALLBACK (view_dialpad),
NULL);
gtk_widget_show (dialpadMenu);
......@@ -644,7 +644,7 @@ create_view_menu()
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( volumeMenu ), image );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), volumeMenu);
g_signal_connect(G_OBJECT (volumeMenu), "activate",
G_CALLBACK (view_volume_controls),
G_CALLBACK (view_volume_controls),
NULL);
gtk_widget_show (volumeMenu);
......@@ -653,7 +653,7 @@ create_view_menu()
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( searchbarMenu ), image );