#include "gtk/gui_utils.h"
#include "gtk/filter_autocomplete.h"
+#include "gtk/old-gtk-compat.h"
+
#define E_FILT_AUTOCOMP_TREE_KEY "filter_autocomplete_tree"
g_free (first);
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list));
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size(list, &requisition, NULL);
+#else
gtk_widget_size_request(list, &requisition);
-
+#endif
#if GTK_CHECK_VERSION(2,18,0)
gtk_widget_get_allocation(popup_win, &popup_win_alloc);
#else
autocomplete_protocol_string(filter_te, value);
g_free(value);
}
+ if(k != GDK_space) {
+ stop_propagation = TRUE; /* stop event propagation */
+ }
}
/* Lose popup */
g_free(prefix_start);
- if(k == GDK_Return || k == GDK_KP_Enter)
- return TRUE; /* stop event propagation */
-
return stop_propagation;
}
static void
filter_autocomplete_disable_sorting(GtkTreeModel *model)
{
-#if GTK_CHECK_VERSION(2,6,0)
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
-#else
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), -2, GTK_SORT_ASCENDING);
-#endif
}
static void
/* Create tree view */
treeview = gtk_tree_view_new();
-#if GTK_CHECK_VERSION(2,6,0)
gtk_tree_view_set_hover_selection(GTK_TREE_VIEW(treeview), TRUE);
-#endif
init_autocompletion_list(treeview);
g_object_set_data(G_OBJECT(popup_win), E_FILT_AUTOCOMP_TREE_KEY, treeview);
g_signal_connect(filter_te, "focus-out-event", G_CALLBACK(filter_te_focus_out_cb), w_toplevel);
g_signal_connect(popup_win, "destroy", G_CALLBACK(filter_autocomplete_win_destroy_cb), NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size(treeview, &requisition, NULL);
+#else
gtk_widget_size_request(treeview, &requisition);
-
+#endif
#if GTK_CHECK_VERSION(2,18,0)
gtk_widget_get_allocation(filter_te, &filter_te_alloc);
#else
gtk_window_resize(GTK_WINDOW(popup_win), filter_te_alloc.width,
(requisition.height<200? requisition.height+8:200));
-#if GTK_CHECK_VERSION(2,14,0)
gdk_window_get_origin(gtk_widget_get_window(filter_te), &x_pos, &y_pos);
+#if GTK_CHECK_VERSION(3,0,0)
+ x_pos += filter_te_alloc.x;
+ y_pos += (filter_te_alloc.y + filter_te_alloc.height);
#else
- gdk_window_get_origin(filter_te->window, &x_pos, &y_pos);
+ y_pos += filter_te_alloc.height;
#endif
- y_pos = y_pos + filter_te_alloc.height;
gtk_window_move(GTK_WINDOW(popup_win), x_pos, y_pos);
gtk_widget_show_all (popup_win);
filter_autocomplete_enable_sorting(model);
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list));
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size(list, &requisition, NULL);
+#else
gtk_widget_size_request(list, &requisition);
+#endif
#if GTK_CHECK_VERSION(2,18,0)
gtk_widget_get_allocation(popup_win, &popup_win_alloc);
popup_win_alloc = popup_win->allocation;
#endif
+ /* XXX use gtk_window_set_default_size()? */
gtk_widget_set_size_request(popup_win, popup_win_alloc.width,
(requisition.height<200? requisition.height+8:200));
gtk_window_resize(GTK_WINDOW(popup_win), popup_win_alloc.width,