Skip to content
Snippets Groups Projects
Commit e3dc135c authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

improve popup menu for contacts; statusbar always display current account

parent 762615b2
No related branches found
No related tags found
No related merge requests found
...@@ -69,12 +69,15 @@ sflphone_notify_voice_mail ( const gchar* accountID , guint count ) ...@@ -69,12 +69,15 @@ sflphone_notify_voice_mail ( const gchar* accountID , guint count )
} }
void void
status_bar_display_account( call_t* c) status_bar_display_account ()
{ {
gchar* msg; gchar* msg;
account_t* acc; account_t* acc;
if(c->accountID != NULL){
acc = account_list_get_by_id(c->accountID); statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
acc = account_list_get_current ();
if(acc){
msg = g_markup_printf_escaped(_("%s account- %s") , msg = g_markup_printf_escaped(_("%s account- %s") ,
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE), (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE),
(gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS)); (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS));
...@@ -133,8 +136,6 @@ sflphone_hung_up( call_t * c) ...@@ -133,8 +136,6 @@ sflphone_hung_up( call_t * c)
#if GTK_CHECK_VERSION(2,10,0) #if GTK_CHECK_VERSION(2,10,0)
status_tray_icon_blink( FALSE ); status_tray_icon_blink( FALSE );
#endif #endif
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
} }
/** Internal to actions: Fill account list */ /** Internal to actions: Fill account list */
...@@ -716,7 +717,6 @@ sflphone_place_call ( call_t * c ) ...@@ -716,7 +717,6 @@ sflphone_place_call ( call_t * c )
{ {
// OK, everything alright - the call is made with the current account // OK, everything alright - the call is made with the current account
c -> accountID = current -> accountID; c -> accountID = current -> accountID;
status_bar_display_account(c);
dbus_place_call(c); dbus_place_call(c);
} }
else else
...@@ -728,7 +728,6 @@ sflphone_place_call ( call_t * c ) ...@@ -728,7 +728,6 @@ sflphone_place_call ( call_t * c )
c -> accountID = current -> accountID; c -> accountID = current -> accountID;
dbus_place_call(c); dbus_place_call(c);
notify_current_account( current ); notify_current_account( current );
status_bar_display_account(c);
account_list_set_current_id( c-> accountID ); account_list_set_current_id( c-> accountID );
} }
} }
...@@ -742,7 +741,6 @@ sflphone_place_call ( call_t * c ) ...@@ -742,7 +741,6 @@ sflphone_place_call ( call_t * c )
c -> accountID = current -> accountID; c -> accountID = current -> accountID;
dbus_place_call(c); dbus_place_call(c);
notify_current_account( current ); notify_current_account( current );
status_bar_display_account(c);
account_list_set_current_id( c-> accountID ); account_list_set_current_id( c-> accountID );
} }
} }
......
...@@ -170,4 +170,7 @@ void sflphone_rec_call (void); ...@@ -170,4 +170,7 @@ void sflphone_rec_call (void);
gchar* sflphone_get_current_codec_name(); gchar* sflphone_get_current_codec_name();
void sflphone_display_selected_codec (const gchar* codecName); void sflphone_display_selected_codec (const gchar* codecName);
void status_bar_display_account ();
#endif #endif
...@@ -848,7 +848,10 @@ show_accounts_window( void ) ...@@ -848,7 +848,10 @@ show_accounts_window( void )
gtk_dialog_run( dialog ); gtk_dialog_run( dialog );
status_bar_display_account ();
accDialogOpen=FALSE; accDialogOpen=FALSE;
gtk_widget_destroy(GTK_WIDGET(dialog)); gtk_widget_destroy(GTK_WIDGET(dialog));
if( account_list_get_size() >0 && account_list_get_current()==NULL ) if( account_list_get_size() >0 && account_list_get_current()==NULL )
account_list_set_current_pos(0); account_list_set_current_pos(0);
......
...@@ -147,11 +147,15 @@ if (event->button == 3 && event->type == GDK_BUTTON_PRESS) ...@@ -147,11 +147,15 @@ if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
show_popup_menu(widget, event); show_popup_menu(widget, event);
return TRUE; return TRUE;
} }
else else if (active_calltree == history)
{ {
show_popup_menu_history (widget, event); show_popup_menu_history (widget, event);
return TRUE; return TRUE;
} }
else{
show_popup_menu_contacts (widget, event);
return TRUE;
}
} }
return FALSE; return FALSE;
} }
......
...@@ -59,6 +59,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\n"); ...@@ -59,6 +59,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\n");
} }
#endif #endif
status_bar_display_account ();
/* start the main loop */ /* start the main loop */
gtk_main (); gtk_main ();
} }
......
...@@ -201,6 +201,7 @@ switch_account( GtkWidget* item , gpointer data UNUSED) ...@@ -201,6 +201,7 @@ switch_account( GtkWidget* item , gpointer data UNUSED)
account_t* acc = g_object_get_data( G_OBJECT(item) , "account" ); account_t* acc = g_object_get_data( G_OBJECT(item) , "account" );
g_print("%s\n" , acc->accountID); g_print("%s\n" , acc->accountID);
account_list_set_current_id( acc->accountID ); account_list_set_current_id( acc->accountID );
status_bar_display_account ();
} }
static void static void
...@@ -835,32 +836,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) ...@@ -835,32 +836,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
if(accounts) if(accounts)
{ {
menu_items = gtk_separator_menu_item_new (); add_registered_accounts_to_menu (menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
unsigned int i;
account_t* acc;
gchar* alias;
for( i = 0 ; i < account_list_get_size() ; i++ ){
acc = account_list_get_nth(i);
// Display only the registered accounts
if( g_strcasecmp( account_state_name(acc -> state) , account_state_name(ACCOUNT_STATE_REGISTERED) ) == 0 ){
alias = g_strconcat( g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) , " - ",g_hash_table_lookup(acc->properties , ACCOUNT_TYPE), NULL);
menu_items = gtk_check_menu_item_new_with_mnemonic(alias);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_object_set_data( G_OBJECT( menu_items ) , "account" , acc );
g_free( alias );
if( account_list_get_current() != NULL ){
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(g_strcasecmp( acc->accountID , account_list_get_current()->accountID) == 0)? TRUE : FALSE);
}
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (switch_account),
NULL);
gtk_widget_show (menu_items);
} // fi
}
} }
if (event) if (event)
...@@ -940,4 +916,95 @@ show_popup_menu_history(GtkWidget *my_widget, GdkEventButton *event) ...@@ -940,4 +916,95 @@ show_popup_menu_history(GtkWidget *my_widget, GdkEventButton *event)
gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL); gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
button, event_time); button, event_time);
}
void
show_popup_menu_contacts(GtkWidget *my_widget, GdkEventButton *event)
{
gboolean pickup = FALSE;
gboolean remove = FALSE;
gboolean accounts = FALSE;
call_t * selectedCall = calltab_get_selected_call( history );
if (selectedCall)
{
remove = TRUE;
pickup = 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(_("_New call"));
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);
}
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 add_registered_accounts_to_menu (GtkWidget *menu) {
GtkWidget *menu_items;
unsigned int i;
account_t* acc;
gchar* alias;
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
for( i = 0 ; i < account_list_get_size() ; i++ ){
acc = account_list_get_nth(i);
// Display only the registered accounts
if( g_strcasecmp( account_state_name(acc -> state) , account_state_name(ACCOUNT_STATE_REGISTERED) ) == 0 ){
alias = g_strconcat( g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) , " - ",g_hash_table_lookup(acc->properties , ACCOUNT_TYPE), NULL);
menu_items = gtk_check_menu_item_new_with_mnemonic(alias);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_object_set_data( G_OBJECT( menu_items ) , "account" , acc );
g_free( alias );
if( account_list_get_current() != NULL ){
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(g_strcasecmp( acc->accountID , account_list_get_current()->accountID) == 0)? TRUE : FALSE);
}
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (switch_account),
NULL);
gtk_widget_show (menu_items);
} // fi
}
} }
...@@ -49,4 +49,8 @@ void show_popup_menu (GtkWidget *my_widget, GdkEventButton *event); ...@@ -49,4 +49,8 @@ void show_popup_menu (GtkWidget *my_widget, GdkEventButton *event);
* @param event The mouse event * @param event The mouse event
*/ */
void show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event); void show_popup_menu_history (GtkWidget *my_widget, GdkEventButton *event);
void show_popup_menu_contacts (GtkWidget *my_widget, GdkEventButton *event);
void add_registered_accounts_to_menu (GtkWidget *menu);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment