diff --git a/sflphone-gtk/src/accountlist.c b/sflphone-gtk/src/accountlist.c index 26c729a7d93d315a4bc9eb172196924cfca7fe32..b61dd75a23e78e54a2fd80cb1395fa43bcbe3a0e 100644 --- a/sflphone-gtk/src/accountlist.c +++ b/sflphone-gtk/src/accountlist.c @@ -1,10 +1,11 @@ /* * Copyright (C) 2007 Savoir-Faire Linux inc. * Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info> + * Author: Emmanuel Milou <emmanuel.milou@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 2 of the License, or + * 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, @@ -109,6 +110,18 @@ account_list_get_nth ( guint n ) return g_queue_peek_nth (accountQueue, n); } +gchar * +account_list_get_default( ) +{ + return DEFAULT_ACCOUNT; +} + +void +account_list_set_default(const gchar * accountID) +{ + DEFAULT_ACCOUNT = g_strdup(accountID); +} + const gchar * account_state_name(account_state_t s) { gchar * state; diff --git a/sflphone-gtk/src/accountlist.h b/sflphone-gtk/src/accountlist.h index f6640868428a06e6f468662fa2b76c54b2e6a6d4..4379ff141efe3754eabb0a2c0f0c0e1bbf87265c 100644 --- a/sflphone-gtk/src/accountlist.h +++ b/sflphone-gtk/src/accountlist.h @@ -1,10 +1,11 @@ /* * Copyright (C) 2007 Savoir-Faire Linux inc. * Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info> + * Author: Emmanuel Milou <emmanuel.milou@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 2 of the License, or + * 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, @@ -68,6 +69,9 @@ typedef struct { GHashTable * properties; } account_t; + +gchar * DEFAULT_ACCOUNT; + /** This function initialize the account list. */ void account_list_init (); @@ -97,6 +101,15 @@ guint account_list_get_size ( ); * @return An account or NULL */ account_t * account_list_get_nth ( guint n ); +/** Return the account's id chosen as default + * @return The default account */ +gchar * account_list_get_default( ); + +/** This function sets an account as default + * @param n The position of the account you want to select + */ +void account_list_set_default(const gchar * accountID); + /** This function maps account_state_t enums to a description. * @param s The state * @return The full text description of the state */ diff --git a/sflphone-gtk/src/actions.h b/sflphone-gtk/src/actions.h index 8046925f974638b537fb37fadbcdc1a71dac7491..ba35e0ecd770c8122bfdefd64cbbafde6197f75f 100644 --- a/sflphone-gtk/src/actions.h +++ b/sflphone-gtk/src/actions.h @@ -102,4 +102,5 @@ void sflphone_keypad ( guint keyval, gchar * key); void sflphone_place_call ( call_t * c ); void sflphone_fill_account_list(); + #endif diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index 5329a0b164f9892102248f78b2f2d45b7e1b0808..2409141b74b551925e51f7cf6404a53ba61cece1 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -27,6 +27,9 @@ GtkListStore * store; GtkWidget *view; +GtkWidget * account_store; +GtkWidget *item; + GtkWidget * toolbar; GtkToolItem * callButton; GtkToolItem * pickupButton; @@ -36,9 +39,6 @@ GtkToolItem * transfertButton; GtkToolItem * unholdButton; guint transfertButtonConnId; //The button toggled signal connection ID -// list of the accounts to be displayed when the arrow beside the call button is pressed -// should be used to set a default account to make output calls -GtkWidget *accounts_list; /** * Show popup menu @@ -256,33 +256,40 @@ void row_activated(GtkTreeView *tree_view, } } +void +fast_fill_account_list() +{ + int i; + for( i = 0; i < account_list_get_size(); i++) + { + account_t * a = account_list_get_nth (i); + if (a) + { + item = gtk_check_menu_item_new_with_label(g_hash_table_lookup(a->properties, ACCOUNT_ALIAS)); + gtk_menu_shell_append (GTK_MENU_SHELL (account_store), item); + gtk_widget_show(item); + } + } + +} + + GtkWidget * create_toolbar (){ GtkWidget *ret; GtkWidget *image; - GtkWidget *item1; - GtkWidget *item2; - GtkWidget *item3; - ret = gtk_toolbar_new(); toolbar = ret; - accounts_list = gtk_menu_new(); - item1 = gtk_menu_item_new_with_label("Compte A"); - gtk_container_add(GTK_CONTAINER(accounts_list), item1); - gtk_widget_show(item1); - item2 = gtk_menu_item_new(); - gtk_container_add(GTK_CONTAINER(accounts_list), item2); - item3 = gtk_menu_item_new(); - gtk_container_add(GTK_CONTAINER(accounts_list), item3); - + account_store = gtk_menu_new(); + fast_fill_account_list(); image = gtk_image_new_from_file( ICONS_DIR "/call.svg"); callButton = gtk_menu_tool_button_new (image, "Place a Call"); - gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(callButton), GTK_WIDGET(accounts_list)); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(callButton), GTK_WIDGET(account_store)); g_signal_connect (G_OBJECT (callButton), "clicked", G_CALLBACK (call_button), NULL); gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(callButton), -1); diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index 0e55fba13ac9dda8d2b81d604badc5e2c78bffd8..a2feab2a635022b0104b6f418b72b3466cf3e5e4 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -1,10 +1,11 @@ /* * Copyright (C) 2007 Savoir-Faire Linux inc. * Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info> + * Author: Emmanuel Milou <emmanuel.milou@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 2 of the License, or + * 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, @@ -35,6 +36,7 @@ GtkWidget * deleteButton; GtkWidget * defaultButton; account_t * selectedAccount; +account_t * defaultAccount; /** Fills the treelist with accounts */ void @@ -158,6 +160,10 @@ create_accounts_tab() GtkTreeSelection *sel; GtkWidget *label; + GtkTreeIter iter; + GValue val; + val.g_type = G_TYPE_POINTER; + selectedAccount = NULL; ret = gtk_vbox_new(FALSE, 10); @@ -191,6 +197,9 @@ create_accounts_tab() G_CALLBACK (select_account), account_store); + gtk_tree_model_get_value(GTK_TREE_MODEL(account_store), &iter, 3, &val); + + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(account_store), 2, GTK_SORT_ASCENDING); @@ -199,6 +208,7 @@ create_accounts_tab() rend, "markup", 0, NULL); + g_object_set(G_OBJECT(rend), "weight", "bold", NULL); gtk_tree_view_append_column (GTK_TREE_VIEW(view), col); rend = gtk_cell_renderer_text_new(); @@ -285,11 +295,6 @@ show_config_window () gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Accounts")); gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); - /* - GtkWidget* blob;//create_blob_tab(); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), blob, gtk_label_new("Audio")); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook), blob); - */ gtk_dialog_run (dialog); dialogOpen = FALSE;