From a6afe76b31629d380fc4cab008dd070eb88a950c Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Wed, 31 Oct 2018 16:18:08 +0100 Subject: [PATCH] Apply font changes to server list * Prevent use of inflexible gtk_cell_renderer_text_set_fixed_height_from_font() (performance with lots of servers still seems good) * Redraw server list when applying setup See https://github.com/hexchat/hexchat/issues/2023 --- src/fe-gtk/chanview-tree.c | 12 +++++++++++- src/fe-gtk/chanview.c | 13 +++++++++++++ src/fe-gtk/chanview.h | 1 + src/fe-gtk/maingui.c | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c index 261304db..3cbd78c9 100644 --- a/src/fe-gtk/chanview-tree.c +++ b/src/fe-gtk/chanview-tree.c @@ -153,7 +153,6 @@ cv_tree_init (chanview *cv) renderer = gtk_cell_renderer_text_new (); if (prefs.hex_gui_compact) g_object_set (G_OBJECT (renderer), "ypad", 0, NULL); - gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_set_attributes (col, renderer, "text", COL_NAME, "attributes", COL_ATTR, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); @@ -394,3 +393,14 @@ cv_tree_is_collapsed (chan *ch) return ret; } + +static void +cv_tree_queue_draw (chanview *cv) +{ + /* assign the model again to cause the tree view to be redrawn + note: Simply using gtk_widget_queue_draw() is not sufficient. */ + GtkTreeView *tree_view = ((treeview *)cv)->tree; + GtkTreeModel *model = gtk_tree_view_get_model(tree_view); + gtk_tree_view_set_model(tree_view, NULL); + gtk_tree_view_set_model(tree_view, model); +} diff --git a/src/fe-gtk/chanview.c b/src/fe-gtk/chanview.c index e5556d9f..a7dd81b6 100644 --- a/src/fe-gtk/chanview.c +++ b/src/fe-gtk/chanview.c @@ -69,6 +69,7 @@ struct _chanview gboolean (*func_is_collapsed) (chan *); chan *(*func_get_parent) (chan *); void (*func_cleanup) (chanview *); + void (*func_queue_draw) (chanview *); unsigned int sorted:1; unsigned int vertical:1; @@ -192,6 +193,7 @@ chanview_set_impl (chanview *cv, int type) cv->func_is_collapsed = cv_tabs_is_collapsed; cv->func_get_parent = cv_tabs_get_parent; cv->func_cleanup = cv_tabs_cleanup; + cv->func_queue_draw = NULL; break; default: @@ -209,6 +211,7 @@ chanview_set_impl (chanview *cv, int type) cv->func_is_collapsed = cv_tree_is_collapsed; cv->func_get_parent = cv_tree_get_parent; cv->func_cleanup = cv_tree_cleanup; + cv->func_queue_draw = cv_tree_queue_draw; break; } @@ -439,6 +442,16 @@ chanview_set_orientation (chanview *cv, gboolean vertical) } } +void +chanview_queue_draw (chanview *cv) +{ + if (!cv->func_queue_draw) { + return; + } + cv->func_queue_draw (cv); + cv->func_postinit (cv); +} + int chan_get_tag (chan *ch) { diff --git a/src/fe-gtk/chanview.h b/src/fe-gtk/chanview.h index a1495b1d..828a1eec 100644 --- a/src/fe-gtk/chanview.h +++ b/src/fe-gtk/chanview.h @@ -36,6 +36,7 @@ GtkWidget *chanview_get_box (chanview *cv); void chanview_move_focus (chanview *cv, gboolean relative, int num); GtkOrientation chanview_get_orientation (chanview *cv); void chanview_set_orientation (chanview *cv, gboolean vertical); +void chanview_queue_draw (chanview *cv); int chan_get_tag (chan *ch); void *chan_get_userdata (chan *ch); diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index efeaaaeb..548f152e 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -3312,6 +3312,8 @@ mg_apply_setup (void) mg_place_userlist_and_chanview (sess->gui); if (sess->gui->is_tab) done_main = TRUE; + /* redraw the chanview to prevent visual glitches due to font changes */ + chanview_queue_draw(sess->gui->chanview); list = list->next; } }