BUG: multiple selections are lost when re-sorting
Dirk Hohndel
dirk at hohndel.org
Wed Feb 20 00:27:28 PST 2013
Dirk Hohndel <dirk at hohndel.org> writes:
> Miika Turkia <miika.turkia at gmail.com> writes:
>
>> Yes, the focus is on the divelist header in this case as I changed the
>> sorting order. Tabbing the focus to the divelist gives the normal
>> colors that stand out. Is it possible to move the focus
>> programmatically from the header to the divelist when one changes the
>> sorting order?
>
> This is far more visible in Ubuntu's color scheme than any other.
>
> I think it is actually WRONG to switch the focus back to the divelist -
> but we do other things that are similarly wrong as far as Gtk design is
> concerned (grabbing curser-up / -down comes to mind... or our whole
> selection management).
>
> Let me look if there is an obvious solution.
So this seems to do this (but it's extremely hard to see in Fedora)
This hasn't been pushed - please play with the patch and let me know if
this is what you were looking for.
/D
diff --git a/display-gtk.h b/display-gtk.h
index 287a3e2..e256c59 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -9,6 +9,7 @@
#endif
extern GtkWidget *main_window;
+extern GtkWidget *dive_list_widget;
/* we want a progress bar as part of the device_data_t - let's abstract this out */
typedef struct {
diff --git a/divelist.c b/divelist.c
index 0951194..7b13f4d 100644
--- a/divelist.c
+++ b/divelist.c
@@ -2319,6 +2319,9 @@ static void sort_column_change_cb(GtkTreeSortable *treeview, gpointer data)
if (second_call)
return;
+ /* give focus back to the dive_list */
+ gtk_widget_grab_focus(dive_list_widget);
+
gtk_tree_sortable_get_sort_column_id(treeview, &colid, &order);
if (colid == lastcol) {
/* we just changed sort order */
diff --git a/gtk-gui.c b/gtk-gui.c
index 40954ba..e9d1dfa 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -35,6 +35,7 @@ GtkWidget *error_info_bar;
GtkWidget *error_label;
GtkWidget *vpane, *hpane;
GtkWidget *notebook;
+GtkWidget *dive_list_widget;
int error_count;
const char *existing_filename;
@@ -1509,7 +1510,6 @@ void init_ui(int *argcp, char ***argvp)
{
GtkWidget *win;
GtkWidget *nb_page;
- GtkWidget *dive_list;
GtkWidget *menubar;
GtkWidget *vbox;
GtkWidget *scrolled;
@@ -1589,9 +1589,9 @@ void init_ui(int *argcp, char ***argvp)
g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL);
/* Create the actual divelist */
- dive_list = dive_list_create();
- gtk_widget_set_name(dive_list, "Dive List");
- gtk_paned_add2(GTK_PANED(vpane), dive_list);
+ dive_list_widget = dive_list_create();
+ gtk_widget_set_name(dive_list_widget, "Dive List");
+ gtk_paned_add2(GTK_PANED(vpane), dive_list_widget);
/* Frame for dive profile */
dive_profile = dive_profile_widget();
@@ -1619,7 +1619,7 @@ void init_ui(int *argcp, char ***argvp)
g_signal_connect(notebook, "query-tooltip", G_CALLBACK(notebook_tooltip), NULL);
/* handle some keys globally (to deal with gtk focus issues) */
- g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (on_key_press), dive_list);
+ g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (on_key_press), dive_list_widget);
gtk_widget_set_app_paintable(win, TRUE);
gtk_widget_show_all(win);
More information about the subsurface
mailing list