[gimp] app: fix Search Popup height saving...
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix Search Popup height saving...
- Date: Sun, 6 Sep 2015 21:11:01 +0000 (UTC)
commit a7e7a0bcb933a497bf237509bd9e804172153ce9
Author: Jehan <jehan girinstud io>
Date: Sun Sep 6 23:03:24 2015 +0200
app: fix Search Popup height saving...
and implement it as the size_allocate() class method rather than
"configure-event" signal handling.
app/widgets/gimpsearchpopup.c | 73 ++++++++++++++++++++++------------------
1 files changed, 40 insertions(+), 33 deletions(-)
---
diff --git a/app/widgets/gimpsearchpopup.c b/app/widgets/gimpsearchpopup.c
index fdaaeb8..cfa1f4f 100644
--- a/app/widgets/gimpsearchpopup.c
+++ b/app/widgets/gimpsearchpopup.c
@@ -58,6 +58,8 @@ enum
PROP_CALLBACK_DATA
};
+static gint window_height = 0;
+
struct _GimpSearchPopupPrivate
{
Gimp *gimp;
@@ -65,8 +67,6 @@ struct _GimpSearchPopupPrivate
GtkWidget *results_list;
GtkWidget *list_view;
- gint window_height;
-
GimpSearchPopupCallback build_results;
gpointer build_results_data;
};
@@ -82,6 +82,9 @@ static void gimp_search_popup_get_property (GObject *obj
GValue *value,
GParamSpec *pspec);
+/* GtkWidget handlers */
+static void gimp_search_popup_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
/* GimpPopup handlers */
static void gimp_search_popup_confirm (GimpPopup *popup);
@@ -100,10 +103,6 @@ static void results_list_on_row_activated (GtkTreeView *tre
GtkTreePath *path,
GtkTreeViewColumn *col,
GimpSearchPopup *popup);
-/* Signal handlers on the popup */
-static gboolean gimp_search_popup_on_configured (GtkWindow *window,
- GdkEvent *event,
- GimpSearchPopup *popup);
/* Utils */
static void gimp_search_popup_run_selected (GimpSearchPopup *popup);
static void gimp_search_popup_setup_results (GtkWidget **results_list,
@@ -123,14 +122,17 @@ static void
gimp_search_popup_class_init (GimpSearchPopupClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GimpPopupClass *popup_class = GIMP_POPUP_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GimpPopupClass *popup_class = GIMP_POPUP_CLASS (klass);
GtkBindingSet *binding_set;
- object_class->constructed = gimp_search_popup_constructed;
- object_class->set_property = gimp_search_popup_set_property;
- object_class->get_property = gimp_search_popup_get_property;
+ object_class->constructed = gimp_search_popup_constructed;
+ object_class->set_property = gimp_search_popup_set_property;
+ object_class->get_property = gimp_search_popup_get_property;
+
+ widget_class->size_allocate = gimp_search_popup_size_allocate;
- popup_class->confirm = gimp_search_popup_confirm;
+ popup_class->confirm = gimp_search_popup_confirm;
/**
* GimpSearchPopup:gimp:
@@ -386,11 +388,10 @@ gimp_search_popup_constructed (GObject *object)
G_CALLBACK (results_list_on_row_activated),
popup);
- g_signal_connect (popup, "configure-event",
- G_CALLBACK (gimp_search_popup_on_configured),
- popup);
-
- popup->priv->window_height = gdk_screen_get_height (screen) / 2;
+ /* Default size of the search popup showing the result list is half
+ * the screen. */
+ if (window_height == 0)
+ window_height = gdk_screen_get_height (screen) / 2;
}
static void
@@ -445,6 +446,27 @@ gimp_search_popup_get_property (GObject *object,
}
}
+void
+gimp_search_popup_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GimpSearchPopup *popup = GIMP_SEARCH_POPUP (widget);
+
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget,
+ allocation);
+
+ if (gtk_widget_get_visible (widget) &&
+ gtk_widget_get_visible (popup->priv->list_view))
+ {
+ GdkScreen *screen = gdk_screen_get_default ();
+
+ /* I save the window height when results are shown so that resizes
+ * by the user are saved accross searches. */
+ window_height = MAX (gdk_screen_get_height (screen) / 4,
+ allocation->height);
+ }
+}
+
static void
gimp_search_popup_confirm (GimpPopup *popup)
{
@@ -501,7 +523,7 @@ keyword_entry_on_key_release_event (GtkWidget *widget,
if (strcmp (entry_text, "") != 0)
{
gtk_window_resize (GTK_WINDOW (popup),
- width, popup->priv->window_height);
+ width, window_height);
gtk_list_store_clear (GTK_LIST_STORE (gtk_tree_view_get_model (tree_view)));
gtk_widget_show_all (popup->priv->list_view);
popup->priv->build_results (popup, entry_text,
@@ -512,7 +534,7 @@ keyword_entry_on_key_release_event (GtkWidget *widget,
else if (strcmp (entry_text, "") == 0 && (event->keyval == GDK_KEY_Down))
{
gtk_window_resize (GTK_WINDOW (popup),
- width, popup->priv->window_height);
+ width, window_height);
gtk_list_store_clear (GTK_LIST_STORE (gtk_tree_view_get_model (tree_view)));
gtk_widget_show_all (popup->priv->list_view);
popup->priv->build_results (popup, NULL,
@@ -625,21 +647,6 @@ results_list_on_row_activated (GtkTreeView *treeview,
gimp_search_popup_run_selected (popup);
}
-static gboolean
-gimp_search_popup_on_configured (GtkWindow *window,
- GdkEvent *event,
- GimpSearchPopup *popup)
-{
- if (gtk_widget_get_visible (GTK_WIDGET (window)) &&
- gtk_widget_get_visible (popup->priv->list_view))
- {
- gtk_window_get_size (GTK_WINDOW (popup),
- NULL, &popup->priv->window_height);
- }
-
- return FALSE;
-}
-
static void
gimp_search_popup_run_selected (GimpSearchPopup *popup)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]