Skip to content
Snippets Groups Projects
Commit db7e48f0 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#9560: cleanup

parent e70a25bc
No related branches found
No related tags found
No related merge requests found
...@@ -67,29 +67,33 @@ void show_edit_number(callable_obj_t *call); ...@@ -67,29 +67,33 @@ void show_edit_number(callable_obj_t *call);
static GtkWidget *toolbar_; static GtkWidget *toolbar_;
static guint transferButtonConnId_; // The button toggled signal connection ID // store the signal ID in case we need to
static guint recordButtonConnId_; // The button toggled signal connection ID // intercept this signal
static guint transferButtonConnId_;
static guint recordButtonConnId_;
static GtkAction * pickUpAction_; static GtkAction * pickUpAction_;
static GtkWidget * pickUpWidget_;
static GtkAction * newCallAction_; static GtkAction * newCallAction_;
static GtkWidget * newCallWidget_;
static GtkAction * hangUpAction_; static GtkAction * hangUpAction_;
static GtkAction * copyAction_;
static GtkAction * pasteAction_;
static GtkAction * recordAction_;
static GtkAction * muteAction_;
static GtkAction * voicemailAction_;
static GtkAction * imAction_;
static GtkWidget * pickUpWidget_;
static GtkWidget * newCallWidget_;
static GtkWidget * hangUpWidget_; static GtkWidget * hangUpWidget_;
static GtkWidget * holdMenu_; static GtkWidget * holdMenu_;
static GtkWidget * holdToolbar_; static GtkWidget * holdToolbar_;
static GtkWidget * offHoldToolbar_; static GtkWidget * offHoldToolbar_;
static GtkWidget * transferToolbar_; static GtkWidget * transferToolbar_;
static GtkAction * copyAction_;
static GtkAction * pasteAction_;
static GtkAction * recordAction_;
static GtkAction * muteAction_;
static GtkWidget * recordWidget_; static GtkWidget * recordWidget_;
static GtkWidget * muteWidget_; static GtkWidget * muteWidget_;
static GtkAction * voicemailAction_;
static GtkWidget * voicemailToolbar_; static GtkWidget * voicemailToolbar_;
static GtkWidget * imToolbar_; static GtkWidget * imToolbar_;
static GtkAction * imAction_;
static GtkWidget * playRecordWidget_; static GtkWidget * playRecordWidget_;
static GtkWidget * stopRecordWidget_; static GtkWidget * stopRecordWidget_;
...@@ -130,101 +134,18 @@ call_mute(void) ...@@ -130,101 +134,18 @@ call_mute(void)
sflphone_mute_call(); sflphone_mute_call();
} }
void
update_actions()
{
int pos = 0;
gtk_action_set_sensitive(newCallAction_, TRUE);
gtk_action_set_sensitive(pickUpAction_, FALSE);
gtk_action_set_sensitive(hangUpAction_, FALSE);
gtk_action_set_sensitive(imAction_, FALSE);
g_object_ref(hangUpWidget_);
g_object_ref(recordWidget_);
g_object_ref(muteWidget_);
g_object_ref(holdToolbar_);
g_object_ref(offHoldToolbar_);
if (addrbook)
g_object_ref(contactButton_);
g_object_ref(historyButton_);
g_object_ref(transferToolbar_);
g_object_ref(voicemailToolbar_);
g_object_ref(imToolbar_);
remove_from_toolbar(hangUpWidget_);
remove_from_toolbar(recordWidget_);
remove_from_toolbar(muteWidget_);
remove_from_toolbar(transferToolbar_);
remove_from_toolbar(historyButton_);
if (addrbook)
remove_from_toolbar(contactButton_);
remove_from_toolbar(voicemailToolbar_);
remove_from_toolbar(imToolbar_);
gtk_widget_set_sensitive(holdMenu_, FALSE);
gtk_widget_set_sensitive(holdToolbar_, FALSE);
gtk_widget_set_sensitive(offHoldToolbar_, FALSE);
gtk_action_set_sensitive(recordAction_, FALSE);
gtk_action_set_sensitive(muteAction_, FALSE);
gtk_widget_set_sensitive(recordWidget_, FALSE);
gtk_widget_set_sensitive(muteWidget_, FALSE);
gtk_action_set_sensitive(copyAction_, FALSE);
if (addrbook) static void
gtk_widget_set_sensitive(contactButton_, FALSE); update_toolbar_for_call(callable_obj_t *selectedCall, gboolean instant_messaging_enabled) {
int pos = 0;
gtk_widget_set_sensitive(historyButton_, FALSE);
if (addrbook)
gtk_widget_set_tooltip_text(contactButton_, _("No address book selected"));
remove_from_toolbar(holdToolbar_);
remove_from_toolbar(offHoldToolbar_);
remove_from_toolbar(newCallWidget_);
remove_from_toolbar(pickUpWidget_);
add_to_toolbar(toolbar_, newCallWidget_, 0);
remove_from_toolbar(playRecordWidget_);
remove_from_toolbar(stopRecordWidget_);
if (eel_gconf_get_integer(HISTORY_ENABLED)) {
add_to_toolbar(toolbar_, historyButton_, -1);
gtk_widget_set_sensitive(historyButton_, TRUE);
}
GtkToolItem *separator = gtk_separator_tool_item_new();
gtk_toolbar_insert(GTK_TOOLBAR(toolbar_), separator, -1);
// add mute button
gtk_action_set_sensitive(muteAction_, TRUE);
// If addressbook support has been enabled and all addressbooks are loaded, display the icon DEBUG("UIManager: Update actions for call %s", selectedCall->_callID);
if (addrbook && addrbook->is_ready() && addressbook_config_load_parameters()->enable) {
add_to_toolbar(toolbar_, contactButton_, -1);
// Make the icon clickable only if at least one address book is active if(selectedCall == NULL) {
if (addrbook->is_active()) { ERROR("Selected call is NULL while updating toolbar");
gtk_widget_set_sensitive(contactButton_, TRUE); return;
gtk_widget_set_tooltip_text(contactButton_, _("Address book"));
}
} }
callable_obj_t * selectedCall = calltab_get_selected_call(active_calltree_tab);
conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree_tab);
gboolean instant_messaging_enabled = TRUE;
if (eel_gconf_key_exists(INSTANT_MESSAGING_ENABLED))
instant_messaging_enabled = eel_gconf_get_integer(INSTANT_MESSAGING_ENABLED);
if (selectedCall) {
DEBUG("UIManager: Update actions for call %s", selectedCall->_callID);
// update icon in systray // update icon in systray
show_status_hangup_icon(); show_status_hangup_icon();
...@@ -237,6 +158,7 @@ update_actions() ...@@ -237,6 +158,7 @@ update_actions()
// Make the button toolbar clickable // Make the button toolbar clickable
gtk_action_set_sensitive(pickUpAction_, TRUE); gtk_action_set_sensitive(pickUpAction_, TRUE);
gtk_action_set_sensitive(hangUpAction_, TRUE); gtk_action_set_sensitive(hangUpAction_, TRUE);
gtk_action_set_sensitive(muteAction_, TRUE);
// Replace the dial button with the hangup button // Replace the dial button with the hangup button
g_object_ref(newCallWidget_); g_object_ref(newCallWidget_);
remove_from_toolbar(newCallWidget_); remove_from_toolbar(newCallWidget_);
...@@ -305,57 +227,61 @@ update_actions() ...@@ -305,57 +227,61 @@ update_actions()
{ {
DEBUG("UIManager: Call State Current"); DEBUG("UIManager: Call State Current");
gtk_action_set_sensitive(hangUpAction_, TRUE); gtk_action_set_sensitive(hangUpAction_, TRUE);
pos = 1; gtk_action_set_sensitive(recordAction_, TRUE);
add_to_toolbar(toolbar_, hangUpWidget_, pos++); gtk_action_set_sensitive(muteAction_, TRUE);
gtk_widget_set_sensitive(holdMenu_, TRUE); gtk_widget_set_sensitive(holdMenu_, TRUE);
gtk_widget_set_sensitive(holdToolbar_, TRUE); gtk_widget_set_sensitive(holdToolbar_, TRUE);
gtk_widget_set_sensitive(transferToolbar_, TRUE); gtk_widget_set_sensitive(transferToolbar_, TRUE);
gtk_action_set_sensitive(recordAction_, TRUE); gtk_widget_set_sensitive(muteWidget_, TRUE);
if (instant_messaging_enabled)
gtk_action_set_sensitive(imAction_, TRUE);
pos = 1;
add_to_toolbar(toolbar_, hangUpWidget_, pos++);
add_to_toolbar(toolbar_, holdToolbar_, pos++); add_to_toolbar(toolbar_, holdToolbar_, pos++);
add_to_toolbar(toolbar_, transferToolbar_, pos++); add_to_toolbar(toolbar_, transferToolbar_, pos++);
add_to_toolbar(toolbar_, recordWidget_, pos++); add_to_toolbar(toolbar_, recordWidget_, pos++);
add_to_toolbar(toolbar_, muteWidget_, pos++);
if (instant_messaging_enabled) {
add_to_toolbar(toolbar_, imToolbar_, pos++);
g_signal_handler_block(transferToolbar_, transferButtonConnId_); g_signal_handler_block(transferToolbar_, transferButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), FALSE); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), FALSE);
g_signal_handler_unblock(transferToolbar_, transferButtonConnId_); g_signal_handler_unblock(transferToolbar_, transferButtonConnId_);
g_signal_handler_block(recordWidget_, recordButtonConnId_); g_signal_handler_block(recordWidget_, recordButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), FALSE); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), FALSE);
g_signal_handler_unblock(recordWidget_, recordButtonConnId_); g_signal_handler_unblock(recordWidget_, recordButtonConnId_);
if (instant_messaging_enabled) {
gtk_action_set_sensitive(imAction_, TRUE);
add_to_toolbar(toolbar_, imToolbar_, pos++);
}
add_to_toolbar(toolbar_, muteWidget_, pos++);
break; break;
} }
case CALL_STATE_RECORD: case CALL_STATE_RECORD:
{ {
DEBUG("UIManager: Call State Record"); DEBUG("UIManager: Call State Record");
pos = 1;
gtk_action_set_sensitive(hangUpAction_, TRUE); gtk_action_set_sensitive(hangUpAction_, TRUE);
add_to_toolbar(toolbar_, hangUpWidget_, pos++); gtk_action_set_sensitive(recordAction_, TRUE);
gtk_action_set_sensitive(muteAction_, TRUE);
gtk_widget_set_sensitive(holdMenu_, TRUE); gtk_widget_set_sensitive(holdMenu_, TRUE);
gtk_widget_set_sensitive(holdToolbar_, TRUE); gtk_widget_set_sensitive(holdToolbar_, TRUE);
gtk_widget_set_sensitive(transferToolbar_, TRUE); gtk_widget_set_sensitive(transferToolbar_, TRUE);
gtk_action_set_sensitive(recordAction_, TRUE); gtk_widget_set_sensitive(muteWidget_, TRUE);
if (instant_messaging_enabled)
gtk_action_set_sensitive(imAction_, TRUE);
pos = 1;
add_to_toolbar(toolbar_, hangUpWidget_, pos++);
add_to_toolbar(toolbar_, holdToolbar_, pos++); add_to_toolbar(toolbar_, holdToolbar_, pos++);
add_to_toolbar(toolbar_, transferToolbar_, pos++); add_to_toolbar(toolbar_, transferToolbar_, pos++);
add_to_toolbar(toolbar_, recordWidget_, pos++); add_to_toolbar(toolbar_, recordWidget_, pos++);
add_to_toolbar(toolbar_, muteWidget_, pos++);
if (instant_messaging_enabled)
add_to_toolbar(toolbar_, imToolbar_, pos++);
g_signal_handler_block(transferToolbar_, transferButtonConnId_); g_signal_handler_block(transferToolbar_, transferButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), FALSE); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), FALSE);
g_signal_handler_unblock(transferToolbar_, transferButtonConnId_); g_signal_handler_unblock(transferToolbar_, transferButtonConnId_);
g_signal_handler_block(recordWidget_, recordButtonConnId_); g_signal_handler_block(recordWidget_, recordButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), TRUE); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(recordWidget_), TRUE);
g_signal_handler_unblock(recordWidget_, recordButtonConnId_); g_signal_handler_unblock(recordWidget_, recordButtonConnId_);
if (instant_messaging_enabled) {
gtk_action_set_sensitive(imAction_, TRUE);
add_to_toolbar(toolbar_, imToolbar_, pos++);
}
add_to_toolbar(toolbar_, muteWidget_, pos++);
break; break;
} }
case CALL_STATE_BUSY: case CALL_STATE_BUSY:
...@@ -370,15 +296,19 @@ update_actions() ...@@ -370,15 +296,19 @@ update_actions()
case CALL_STATE_TRANSFER: case CALL_STATE_TRANSFER:
{ {
pos = 1; pos = 1;
gtk_action_set_sensitive(hangUpAction_, TRUE);
gtk_action_set_sensitive(muteAction_, TRUE);
gtk_widget_set_sensitive(holdMenu_, TRUE);
gtk_widget_set_sensitive(holdToolbar_, TRUE);
gtk_widget_set_sensitive(transferToolbar_, TRUE);
gtk_widget_set_sensitive(transferToolbar_, TRUE);
gtk_widget_set_sensitive(muteWidget_, TRUE);
add_to_toolbar(toolbar_, hangUpWidget_, pos++); add_to_toolbar(toolbar_, hangUpWidget_, pos++);
add_to_toolbar(toolbar_, transferToolbar_, pos++); add_to_toolbar(toolbar_, transferToolbar_, pos++);
g_signal_handler_block(transferToolbar_, transferButtonConnId_); g_signal_handler_block(transferToolbar_, transferButtonConnId_);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), TRUE); gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transferToolbar_), TRUE);
g_signal_handler_unblock(transferToolbar_, transferButtonConnId_); g_signal_handler_unblock(transferToolbar_, transferButtonConnId_);
gtk_action_set_sensitive(hangUpAction_, TRUE);
gtk_widget_set_sensitive(holdMenu_, TRUE);
gtk_widget_set_sensitive(holdToolbar_, TRUE);
gtk_widget_set_sensitive(transferToolbar_, TRUE);
add_to_toolbar(toolbar_, muteWidget_, pos++); add_to_toolbar(toolbar_, muteWidget_, pos++);
break; break;
} }
...@@ -386,8 +316,12 @@ update_actions() ...@@ -386,8 +316,12 @@ update_actions()
ERROR("UIMAnager: Error: Unknown state in action update!"); ERROR("UIMAnager: Error: Unknown state in action update!");
break; break;
} }
}
}
} else if (selectedConf) { static void
update_toolbar_for_conference(conference_obj_t * selectedConf, gboolean instant_messaging_enabled) {
int pos = 0;
DEBUG("UIManager: Update actions for conference"); DEBUG("UIManager: Update actions for conference");
...@@ -464,6 +398,100 @@ update_actions() ...@@ -464,6 +398,100 @@ update_actions()
WARN("UIManager: Error: Should not happen in action update!"); WARN("UIManager: Error: Should not happen in action update!");
break; break;
} }
}
void
update_actions()
{
gtk_action_set_sensitive(newCallAction_, TRUE);
gtk_action_set_sensitive(pickUpAction_, FALSE);
gtk_action_set_sensitive(hangUpAction_, FALSE);
gtk_action_set_sensitive(recordAction_, FALSE);
gtk_action_set_sensitive(muteAction_, FALSE);
gtk_action_set_sensitive(copyAction_, FALSE);
gtk_action_set_sensitive(imAction_, FALSE);
gtk_widget_set_sensitive(holdMenu_, FALSE);
gtk_widget_set_sensitive(holdToolbar_, FALSE);
gtk_widget_set_sensitive(offHoldToolbar_, FALSE);
gtk_widget_set_sensitive(recordWidget_, FALSE);
gtk_widget_set_sensitive(muteWidget_, FALSE);
gtk_widget_set_sensitive(historyButton_, FALSE);
// Increment the reference counter
g_object_ref(hangUpWidget_);
g_object_ref(recordWidget_);
g_object_ref(muteWidget_);
g_object_ref(holdToolbar_);
g_object_ref(offHoldToolbar_);
g_object_ref(historyButton_);
g_object_ref(transferToolbar_);
g_object_ref(voicemailToolbar_);
g_object_ref(imToolbar_);
if (addrbook)
g_object_ref(contactButton_);
// Make sure the toolbar is reinitialized
// Widget will be added according to the state
// of the selected call
remove_from_toolbar(hangUpWidget_);
remove_from_toolbar(recordWidget_);
remove_from_toolbar(muteWidget_);
remove_from_toolbar(transferToolbar_);
remove_from_toolbar(historyButton_);
remove_from_toolbar(voicemailToolbar_);
remove_from_toolbar(imToolbar_);
remove_from_toolbar(holdToolbar_);
remove_from_toolbar(offHoldToolbar_);
remove_from_toolbar(newCallWidget_);
remove_from_toolbar(pickUpWidget_);
remove_from_toolbar(playRecordWidget_);
remove_from_toolbar(stopRecordWidget_);
if (addrbook) {
remove_from_toolbar(contactButton_);
gtk_widget_set_sensitive(contactButton_, FALSE);
gtk_widget_set_tooltip_text(contactButton_, _("No address book selected"));
}
// New call widget always present
add_to_toolbar(toolbar_, newCallWidget_, 0);
// Add the history button and set it to sensitive if enabled
if (eel_gconf_get_integer(HISTORY_ENABLED)) {
add_to_toolbar(toolbar_, historyButton_, -1);
gtk_widget_set_sensitive(historyButton_, TRUE);
}
GtkToolItem *separator = gtk_separator_tool_item_new();
gtk_toolbar_insert(GTK_TOOLBAR(toolbar_), separator, -1);
// If addressbook support has been enabled and all addressbooks are loaded, display the icon
if (addrbook && addrbook->is_ready() && addressbook_config_load_parameters()->enable) {
add_to_toolbar(toolbar_, contactButton_, -1);
// Make the icon clickable only if at least one address book is active
if (addrbook->is_active()) {
gtk_widget_set_sensitive(contactButton_, TRUE);
gtk_widget_set_tooltip_text(contactButton_, _("Address book"));
}
}
callable_obj_t * selectedCall = calltab_get_selected_call(active_calltree_tab);
conference_obj_t * selectedConf = calltab_get_selected_conf(active_calltree_tab);
gboolean instant_messaging_enabled = TRUE;
if (eel_gconf_key_exists(INSTANT_MESSAGING_ENABLED))
instant_messaging_enabled = eel_gconf_get_integer(INSTANT_MESSAGING_ENABLED);
if (selectedCall) {
update_toolbar_for_call(selectedCall, instant_messaging_enabled);
} else if (selectedConf) {
update_toolbar_for_conference(selectedConf, instant_messaging_enabled);
} else { } else {
// update icon in systray // update icon in systray
hide_status_hangup_icon(); hide_status_hangup_icon();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment