Commit 9de38e1c authored by Mohammed Sadiq's avatar Mohammed Sadiq Committed by Mohammed Sadiq
Browse files

window: Fix chat list row selection

We were using hacks to mark the item as selected, which resulted
in the selected state to be broken in some cases.  Avoid the hacks
and let the default signal callback do its work.
parent a6de329a
...@@ -85,23 +85,6 @@ G_DEFINE_TYPE (ChattyWindow, chatty_window, GTK_TYPE_APPLICATION_WINDOW) ...@@ -85,23 +85,6 @@ G_DEFINE_TYPE (ChattyWindow, chatty_window, GTK_TYPE_APPLICATION_WINDOW)
static void chatty_window_show_new_muc_dialog (ChattyWindow *self); static void chatty_window_show_new_muc_dialog (ChattyWindow *self);
static GtkWidget *
window_chat_list_row_new (ChattyItem *item,
ChattyWindow *self)
GtkWidget *row;
g_assert (CHATTY_IS_ITEM (item));
g_assert (CHATTY_IS_WINDOW (self));
row = chatty_list_row_new (item);
if (self->selected_item == item)
gtk_widget_set_state_flags (row, GTK_STATE_FLAG_SELECTED, FALSE);
return row;
static GtkWidget * static GtkWidget *
window_get_view_for_chat (ChattyWindow *self, window_get_view_for_chat (ChattyWindow *self,
ChattyChat *chat) ChattyChat *chat)
...@@ -174,6 +157,11 @@ window_chat_changed_cb (ChattyWindow *self) ...@@ -174,6 +157,11 @@ window_chat_changed_cb (ChattyWindow *self)
gtk_widget_set_sensitive (self->header_sub_menu_button, !!self->selected_item); gtk_widget_set_sensitive (self->header_sub_menu_button, !!self->selected_item);
/* Select the first item if none selected and we are in expanded mode */
if (!self->selected_item &&
gtk_list_box_get_selection_mode (GTK_LIST_BOX (self->chats_listbox)) == GTK_SELECTION_SINGLE)
chatty_window_chat_list_select_first (self);
/* /*
* When the items are re-arranged, the selection will be lost. * When the items are re-arranged, the selection will be lost.
* Re-select it. In GTK4, A #GtkListView with #GtkSingleSelection * Re-select it. In GTK4, A #GtkListView with #GtkSingleSelection
...@@ -802,7 +790,7 @@ chatty_window_constructed (GObject *object) ...@@ -802,7 +790,7 @@ chatty_window_constructed (GObject *object)
self->chat_filter); self->chat_filter);
gtk_list_box_bind_model (GTK_LIST_BOX (self->chats_listbox), gtk_list_box_bind_model (GTK_LIST_BOX (self->chats_listbox),
G_LIST_MODEL (self->filter_model), G_LIST_MODEL (self->filter_model),
(GtkListBoxCreateWidgetFunc)window_chat_list_row_new, (GtkListBoxCreateWidgetFunc)chatty_list_row_new,
g_object_ref(self), g_object_unref); g_object_ref(self), g_object_unref);
g_signal_connect_object (gtk_filter_list_model_get_model (self->filter_model), g_signal_connect_object (gtk_filter_list_model_get_model (self->filter_model),
Markdown is supported
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