Attached is a patch that does two things:
* The fixed-height-mode property is used to optimize display of large
autocompletion lists. This property was added in gtk 2.4, but is probed
for at runtime so the code should work with older gtk versions.
* The active color is set to the selected color on the list box so the
selected lines are more clearly selected when the listbox widget does
not have the focus. The autocompletion popup never gets the focus so
the active color ends up being used.
John
diff -rup --exclude CVS /src/scint-cvs/scintilla/gtk/PlatGTK.cxx
./gtk/PlatGTK.cxx
--- /src/scint-cvs/scintilla/gtk/PlatGTK.cxx Wed Mar 29 11:21:55 2006
+++ ./gtk/PlatGTK.cxx Sun Apr 23 22:01:37 2006
@@ -1968,6 +2013,31 @@ static gboolean ButtonPress(GtkWidget *,
return FALSE;
}
+#if GTK_MAJOR_VERSION >= 2
+/* Change the active color to the selected color so the listbox uses the color
+scheme that it would use if it had the focus. */
+static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
+ GtkStyle* style;
+
+ g_return_if_fail(w != NULL);
+
+ /* Copy the selected color to active. Note that the modify calls will
cause
+ recursive calls to this function after the value is updated and
w->style to
+ be set to a new object */
+ style = gtk_widget_get_style(w);
+ if (style == NULL)
+ return;
+ if (!gdk_color_equal(&style->base[GTK_STATE_SELECTED],
&style->base[GTK_STATE_ACTIVE]))
+ gtk_widget_modify_base(w, GTK_STATE_ACTIVE,
&style->base[GTK_STATE_SELECTED]);
+
+ style = gtk_widget_get_style(w);
+ if (style == NULL)
+ return;
+ if (!gdk_color_equal(&style->text[GTK_STATE_SELECTED],
&style->text[GTK_STATE_ACTIVE]))
+ gtk_widget_modify_text(w, GTK_STATE_ACTIVE,
&style->text[GTK_STATE_SELECTED]);
+}
+#endif
+
void ListBoxX::Create(Window &, int, Point, int, bool) {
id = gtk_window_new(GTK_WINDOW_POPUP);
@@ -2003,6 +2073,8 @@ void ListBoxX::Create(Window &, int, Poi
gtk_list_store_new(N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ g_signal_connect(G_OBJECT(list), "style-set", G_CALLBACK(StyleSet),
NULL);
+
GtkTreeSelection *selection =
gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
@@ -2011,7 +2083,7 @@ void ListBoxX::Create(Window &, int, Poi
/* Columns */
GtkTreeViewColumn *column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_title(column, "Autocomplete");
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
@@ -2020,11 +2092,14 @@ void ListBoxX::Create(Window &, int, Poi
"pixbuf", PIXBUF_COLUMN);
renderer = gtk_cell_renderer_text_new();
+
gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer),
1);
gtk_tree_view_column_pack_start(column, renderer, TRUE);
gtk_tree_view_column_add_attribute(column, renderer,
"text", TEXT_COLUMN);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(list),
"fixed-height-mode"))
+ g_object_set(G_OBJECT(list), "fixed-height-mode", TRUE, NULL);
gtk_container_add(GTK_CONTAINER(PWidget(scroller)), PWidget(list));
gtk_widget_show(PWidget(list));
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest