Skip to content
Snippets Groups Projects
Commit cf0a4a89 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

uimanager_new() : simplify

parent 0d02b874
Branches
Tags
No related merge requests found
...@@ -184,7 +184,6 @@ create_main_window () ...@@ -184,7 +184,6 @@ create_main_window ()
{ {
GtkWidget *widget; GtkWidget *widget;
GError *error = NULL; GError *error = NULL;
gboolean ret;
const char *window_title = "SFLphone VoIP Client"; const char *window_title = "SFLphone VoIP Client";
int width, height, position_x, position_y; int width, height, position_x, position_y;
...@@ -226,9 +225,9 @@ create_main_window () ...@@ -226,9 +225,9 @@ create_main_window ()
gtk_widget_set_name (window, "mainwindow"); gtk_widget_set_name (window, "mainwindow");
ret = uimanager_new (&ui_manager); ui_manager = uimanager_new ();
if (!ret) { if (!ui_manager) {
ERROR ("Could not load xml GUI\n"); ERROR ("Could not load xml GUI\n");
g_error_free (error); g_error_free (error);
exit (1); exit (1);
......
...@@ -1108,52 +1108,32 @@ static const GtkToggleActionEntry toggle_menu_entries[] = { ...@@ -1108,52 +1108,32 @@ static const GtkToggleActionEntry toggle_menu_entries[] = {
{ "Addressbook", GTK_STOCK_ADDRESSBOOK, N_ ("_Address book"), NULL, N_ ("Address book"), G_CALLBACK (toggle_addressbook_cb), FALSE } { "Addressbook", GTK_STOCK_ADDRESSBOOK, N_ ("_Address book"), NULL, N_ ("Address book"), G_CALLBACK (toggle_addressbook_cb), FALSE }
}; };
gboolean GtkUIManager *uimanager_new (void)
uimanager_new (GtkUIManager **_ui_manager)
{ {
guint manager_id;
GtkUIManager *ui_manager;
GtkActionGroup *action_group;
GtkWidget *window;
gchar *path;
guint manager_id = 0;
GError *error = NULL; GError *error = NULL;
gint nb_entries, nb_menu_entries;
nb_entries = abookfactory_is_addressbook_loaded() ? 7 : 6;
nb_menu_entries = abookfactory_is_addressbook_loaded() ? 7 : 6;
gint nb_entries = abookfactory_is_addressbook_loaded() ? 7 : 6;
window = get_main_window(); GtkWidget *window = get_main_window();
ui_manager = gtk_ui_manager_new(); GtkUIManager *ui_manager = gtk_ui_manager_new();
/* Create an accel group for window's shortcuts */ /* Create an accel group for window's shortcuts */
path = g_build_filename (SFLPHONE_UIDIR_UNINSTALLED, "./ui.xml", NULL); gchar *path = g_build_filename (SFLPHONE_UIDIR_UNINSTALLED, "./ui.xml", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) { if (g_file_test (path, G_FILE_TEST_EXISTS)) {
manager_id = gtk_ui_manager_add_ui_from_file (ui_manager, path, &error); manager_id = gtk_ui_manager_add_ui_from_file (ui_manager, path, &error);
if (error != NULL) {
g_error_free (error);
return FALSE;
}
g_free (path);
} else { } else {
g_free (path);
path = g_build_filename (SFLPHONE_UIDIR, "./ui.xml", NULL); path = g_build_filename (SFLPHONE_UIDIR, "./ui.xml", NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS))
if (g_file_test (path, G_FILE_TEST_EXISTS)) { goto fail;
manager_id = gtk_ui_manager_add_ui_from_file (ui_manager, path, &error); manager_id = gtk_ui_manager_add_ui_from_file (ui_manager, path, &error);
if (error != NULL) {
g_error_free (error);
return FALSE;
} }
if (error)
goto fail;
g_free (path); g_free (path);
} else
return FALSE;
}
if(abookfactory_is_addressbook_loaded()) { if(abookfactory_is_addressbook_loaded()) {
// These actions must be loaded dynamically and is not specified in the xml description // These actions must be loaded dynamically and is not specified in the xml description
...@@ -1167,7 +1147,7 @@ uimanager_new (GtkUIManager **_ui_manager) ...@@ -1167,7 +1147,7 @@ uimanager_new (GtkUIManager **_ui_manager)
GTK_UI_MANAGER_TOOLITEM, FALSE); GTK_UI_MANAGER_TOOLITEM, FALSE);
} }
action_group = gtk_action_group_new ("SFLphoneWindowActions"); GtkActionGroup *action_group = gtk_action_group_new ("SFLphoneWindowActions");
// To translate label and tooltip entries // To translate label and tooltip entries
gtk_action_group_set_translation_domain (action_group, "sflphone-client-gnome"); gtk_action_group_set_translation_domain (action_group, "sflphone-client-gnome");
gtk_action_group_add_actions (action_group, menu_entries, G_N_ELEMENTS (menu_entries), window); gtk_action_group_add_actions (action_group, menu_entries, G_N_ELEMENTS (menu_entries), window);
...@@ -1175,9 +1155,15 @@ uimanager_new (GtkUIManager **_ui_manager) ...@@ -1175,9 +1155,15 @@ uimanager_new (GtkUIManager **_ui_manager)
//gtk_action_group_add_radio_actions (action_group, radio_menu_entries, G_N_ELEMENTS (radio_menu_entries), CALLTREE_CALLS, G_CALLBACK (calltree_switch_cb), window); //gtk_action_group_add_radio_actions (action_group, radio_menu_entries, G_N_ELEMENTS (radio_menu_entries), CALLTREE_CALLS, G_CALLBACK (calltree_switch_cb), window);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
*_ui_manager = ui_manager; return ui_manager;
return TRUE; fail:
if (error)
g_error_free (error);
g_free (path);
g_free (ui_manager);
return NULL;
} }
static void static void
......
...@@ -42,7 +42,7 @@ GtkWidget *contactButton; ...@@ -42,7 +42,7 @@ GtkWidget *contactButton;
GtkAction *volumeToggle; GtkAction *volumeToggle;
gboolean uimanager_new (GtkUIManager**); GtkUIManager *uimanager_new (void);
void update_voicemail_status (void); void update_voicemail_status (void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment