Commit 2b455543 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #12575: gnome: check tab identity by name, not address

parent 6291959c
......@@ -640,7 +640,8 @@ sflphone_keypad(guint keyval, gchar * key)
{
callable_obj_t * c = calltab_get_selected_call(current_calls_tab);
if ((active_calltree_tab != current_calls_tab) || (active_calltree_tab == current_calls_tab && !c)) {
const gboolean current_is_active_tab = calltab_has_name(active_calltree_tab, CURRENT_CALLS);
if (!current_is_active_tab || (current_is_active_tab && !c)) {
switch (keyval) {
case GDK_Return:
case GDK_KP_Enter:
......
......@@ -117,9 +117,9 @@ calllist_reset(calltab_t* tab)
void
calllist_add_call(calltab_t* tab, callable_obj_t * c)
{
DEBUG("Adding call with callID %s to tab %s", c->_callID, tab->_name);
DEBUG("Adding call with callID %s to tab %s", c->_callID, tab->name);
g_queue_push_tail(tab->callQueue, c);
DEBUG("Tab %s has %d calls", tab->_name, calllist_get_size(tab));
DEBUG("Tab %s has %d calls", tab->name, calllist_get_size(tab));
}
void
......@@ -159,7 +159,7 @@ calllist_remove_call(calltab_t* tab, const gchar * callID)
callable_obj_t *call = c->data;
DEBUG("Removing call %s from tab %s", callID, tab->_name);
DEBUG("Removing call %s from tab %s", callID, tab->name);
g_queue_remove(tab->callQueue, call);
/* Don't save empty (i.e. started dialing, then deleted) calls */
......@@ -194,7 +194,7 @@ calllist_get_call(calltab_t* tab, const gchar * callID)
GList * c = g_queue_find_custom(tab->callQueue, callID, is_callID_callstruct);
if (c == NULL) {
ERROR("Could not find call %s in tab %s", callID, tab->_name);
ERROR("Could not find call %s in tab %s", callID, tab->name);
return NULL;
}
......
......@@ -35,6 +35,10 @@
#include "callable_obj.h"
#include "conference_obj.h"
static const gchar * const CURRENT_CALLS = "current_calls";
static const gchar * const HISTORY = "history";
static const gchar * const CONTACTS = "contacts";
/** @file calllist.h
* @brief A list to hold calls.
*/
......@@ -51,7 +55,7 @@ typedef struct {
gint selectedType;
callable_obj_t* selectedCall;
conference_obj_t* selectedConf;
gchar *_name;
gchar *name;
} calltab_t;
void
......
......@@ -38,8 +38,8 @@
calltab_t* calltab_init(gboolean searchbar_type, const gchar * const name)
{
calltab_t* ret = calloc(1, sizeof(calltab_t));
ret->_name = g_strdup(name);
calltab_t* ret = g_new0(calltab_t, 1);
ret->name = g_strdup(name);
calltree_create(ret, searchbar_type);
......@@ -98,10 +98,16 @@ calltab_create_searchbar(calltab_t* tab)
{
g_assert(tab);
if (g_strcmp0(tab->_name, HISTORY) == 0)
if (calltab_has_name(tab, HISTORY))
tab->searchbar = history_searchbar_new();
else if (g_strcmp0(tab->_name, CONTACTS) == 0)
else if (calltab_has_name(tab, CONTACTS))
tab->searchbar = contacts_searchbar_new();
else
ERROR("Current calls tab does not need a searchbar\n");
}
gboolean
calltab_has_name(calltab_t *tab, const gchar *name)
{
return g_strcmp0(tab->name, name) == 0;
}
......@@ -65,4 +65,7 @@ calltab_get_selected_conf (calltab_t *);
void
calltab_create_searchbar (calltab_t *);
gboolean
calltab_has_name(calltab_t *tab, const gchar *name);
#endif
......@@ -109,9 +109,8 @@ call_selected_cb(GtkTreeSelection *sel, void* data UNUSED)
if (!gtk_tree_selection_get_selected(sel, &model, &iter))
return;
if (active_calltree_tab == history_tab) {
if (calltab_has_name(active_calltree_tab, HISTORY))
main_window_reset_playback_scale();
}
/* Get ID of selected object, may be a call or a conference */
gchar *id;
......@@ -151,7 +150,7 @@ row_activated_cb(GtkTreeView *tree_view UNUSED,
if (selectedCall) {
// Get the right event from the right calltree
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
switch (selectedCall->_state) {
case CALL_STATE_INCOMING:
dbus_accept(selectedCall);
......@@ -185,7 +184,7 @@ row_activated_cb(GtkTreeView *tree_view UNUSED,
} else if (calltab_get_selected_type(active_calltree_tab) == A_CONFERENCE) {
DEBUG("Selected a conference");
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
conference_obj_t * selectedConf = calltab_get_selected_conf(current_calls_tab);
if (selectedConf) {
......@@ -219,9 +218,9 @@ row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED)
callable_obj_t *selectedCall = calltab_get_selected_call(active_calltree_tab);
conference_obj_t *selectedConf = calltab_get_selected_conf(active_calltree_tab);
if (active_calltree_tab == current_calls_tab)
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS))
DEBUG("Active calltree is current_calls");
else if (active_calltree_tab == history_tab)
else if (calltab_has_name(active_calltree_tab, HISTORY))
DEBUG("Active calltree is history");
if (calltab_get_selected_type(active_calltree_tab) == A_CALL) {
......@@ -245,7 +244,7 @@ row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED)
/* Make sure that we are not in the history tab since
* nothing is defined for it yet
*/
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
switch (selectedCall->_srtp_state) {
case SRTP_STATE_ZRTP_SAS_UNCONFIRMED:
selectedCall->_srtp_state = SRTP_STATE_ZRTP_SAS_CONFIRMED;
......@@ -280,9 +279,9 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS
if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
return FALSE;
if (active_calltree_tab == current_calls_tab)
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS))
show_popup_menu(widget, event);
else if (active_calltree_tab == history_tab)
else if (calltab_has_name(active_calltree_tab, HISTORY))
show_popup_menu_history(widget, event);
else
show_popup_menu_contacts(widget, event);
......@@ -421,7 +420,7 @@ calltree_create(calltab_t* tab, int searchbar_type)
G_CALLBACK(button_pressed),
NULL);
if (g_strcmp0(tab->_name, CURRENT_CALLS) == 0) {
if (calltab_has_name(tab, CURRENT_CALLS)) {
gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(tab->view), GDK_BUTTON1_MASK, target_list, n_targets, GDK_ACTION_DEFAULT | GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(tab->view), target_list, n_targets, GDK_ACTION_DEFAULT);
......@@ -636,7 +635,7 @@ update_call(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gp
g_free(audio_codec);
/* Update icons */
if (tab == current_calls_tab) {
if (calltab_has_name(tab, CURRENT_CALLS)) {
DEBUG("Receiving in state %d", call->_state);
switch (call->_state) {
......@@ -694,7 +693,7 @@ update_call(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gp
pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL);
}
} else if (tab == history_tab) {
} else if (calltab_has_name(tab, HISTORY)) {
pixbuf = history_state_to_pixbuf(call);
g_free(description);
......@@ -770,7 +769,7 @@ void calltree_add_call(calltab_t* tab, callable_obj_t * call, GtkTreeIter *paren
DEBUG("Added call key exchange is %s", key_exchange);
if (tab == current_calls_tab) {
if (calltab_has_name(tab, CURRENT_CALLS)) {
switch (call->_state) {
case CALL_STATE_INCOMING:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
......@@ -803,7 +802,7 @@ void calltree_add_call(calltab_t* tab, callable_obj_t * call, GtkTreeIter *paren
if (srtp_enabled && utf8_case_equal(srtp_enabled, "true"))
pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/secure_off.svg", NULL);
} else if (tab == contacts_tab)
} else if (calltab_has_name(tab, CONTACTS))
pixbuf = call->_contact_thumbnail;
else
WARN("This widget doesn't exist - This is a bug in the application.");
......@@ -1103,21 +1102,21 @@ void calltree_remove_conference(calltab_t* tab, const conference_obj_t* conf)
void calltree_display(calltab_t *tab)
{
/* If we already are displaying the specified calltree */
if (active_calltree_tab == tab)
if (calltab_has_name(active_calltree_tab, tab->name))
return;
if (tab == current_calls_tab) {
if (active_calltree_tab == contacts_tab)
if (calltab_has_name(tab, CURRENT_CALLS)) {
if (calltab_has_name(active_calltree_tab, CONTACTS))
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(contactButton_), FALSE);
else
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton_), FALSE);
} else if (tab == history_tab) {
if (active_calltree_tab == contacts_tab)
} else if (calltab_has_name(tab, HISTORY)) {
if (calltab_has_name(active_calltree_tab, CONTACTS))
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(contactButton_), FALSE);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton_), TRUE);
} else if (tab == contacts_tab) {
if (active_calltree_tab == history_tab)
} else if (calltab_has_name(tab, CONTACTS)) {
if (calltab_has_name(active_calltree_tab, HISTORY))
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(historyButton_), FALSE);
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(contactButton_), TRUE);
......
......@@ -69,7 +69,7 @@ void searchbar_addressbook_activated(GtkEntry *entry, gchar *arg1 UNUSED, gpoint
void searchbar_entry_changed(GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
{
DEBUG("Searchbar: Entry changed");
if (active_calltree_tab == history_tab)
if (calltab_has_name(active_calltree_tab, HISTORY))
history_search();
}
......@@ -247,10 +247,10 @@ static void icon_press_cb(GtkEntry *entry, gint position, GdkEventButton *event,
{
DEBUG("Searchbar: Icon pressed");
if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree_tab == history_tab)
if (position == GTK_ENTRY_ICON_PRIMARY && calltab_has_name(active_calltree_tab, HISTORY))
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
event->button, event->time);
else if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree_tab == contacts_tab) {
else if (position == GTK_ENTRY_ICON_PRIMARY && calltab_has_name(active_calltree_tab, CONTACTS)) {
GtkWidget *addrbook_menu = addressbook_menu_new();
gtk_menu_popup(GTK_MENU(addrbook_menu), NULL, NULL, NULL, NULL,
event->button, event->time);
......@@ -260,14 +260,10 @@ static void icon_press_cb(GtkEntry *entry, gint position, GdkEventButton *event,
static void text_changed_cb(GtkEntry *entry, GParamSpec *pspec UNUSED)
{
gboolean has_text;
has_text = gtk_entry_get_text_length(entry) > 0;
const gboolean has_text = gtk_entry_get_text_length(entry) > 0;
gtk_entry_set_icon_sensitive(entry, GTK_ENTRY_ICON_SECONDARY, has_text);
}
GtkWidget *addressbook_menu_new(void)
{
// Create the menu
......
......@@ -151,10 +151,10 @@ on_key_released(GtkWidget *widget UNUSED, GdkEventKey *event, gpointer user_data
return TRUE;
if (event->keyval == GDK_KEY_Return) {
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
sflphone_keypad(event->keyval, event->string);
return TRUE;
} else if (active_calltree_tab == history_tab)
} else if (calltab_has_name(active_calltree_tab, HISTORY))
return FALSE;
}
......
......@@ -43,10 +43,6 @@
#define LOGO_OFFLINE ICONS_DIR "/sflphone_offline.svg"
#define LOGO_SMALL ICONS_DIR "/sflphone_small.svg"
#define CURRENT_CALLS "current_calls"
#define HISTORY "history"
#define CONTACTS "contacts"
/** Locale */
#define c_(COMMENT,STRING) gettext(STRING)
#define n_(SING,PLUR,COUNT) ngettext(SING,PLUR,COUNT)
......
......@@ -204,7 +204,7 @@ update_toolbar_for_call(callable_obj_t *selectedCall, gboolean instant_messaging
DEBUG("Call State Dialing");
gtk_action_set_sensitive(pickUpAction_, TRUE);
if (active_calltree_tab == current_calls_tab)
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS))
gtk_action_set_sensitive(hangUpAction_, TRUE);
g_object_ref(newCallWidget_);
......@@ -212,11 +212,11 @@ update_toolbar_for_call(callable_obj_t *selectedCall, gboolean instant_messaging
pos = 0;
add_to_toolbar(toolbar_, pickUpWidget_, pos++);
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
add_to_toolbar(toolbar_, hangUpWidget_, pos++);
main_window_hide_playback_scale();
}
else if (active_calltree_tab == history_tab) {
else if (calltab_has_name(active_calltree_tab, HISTORY)) {
main_window_show_playback_scale();
if (is_non_empty(selectedCall->_recordfile)) {
main_window_set_playback_scale_sensitive();
......@@ -346,7 +346,7 @@ update_toolbar_for_conference(conference_obj_t * selectedConf, gboolean instant_
case CONFERENCE_STATE_ACTIVE_DETACHED:
DEBUG("Conference State Active");
g_signal_handler_block(recordWidget_, recordButtonConnId_);
if (active_calltree_tab == current_calls_tab) {
if (calltab_has_name(active_calltree_tab, CURRENT_CALLS)) {
gtk_action_set_sensitive(hangUpAction_, TRUE);
gtk_widget_set_sensitive(holdToolbar_, TRUE);
gtk_widget_set_sensitive(recordWidget_, TRUE);
......@@ -360,7 +360,7 @@ update_toolbar_for_conference(conference_obj_t * selectedConf, gboolean instant_
add_to_toolbar(toolbar_, imToolbar_, pos);
}
main_window_hide_playback_scale();
} else if (active_calltree_tab == history_tab) {
} else if (calltab_has_name(active_calltree_tab, HISTORY)) {
main_window_show_playback_scale();
if (is_non_empty(selectedConf->_recordfile)) {
main_window_set_playback_scale_sensitive();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment