[PATCH v2 2/9] kconfig: gconf: use configure-event handler to adjust pane separator

Masahiro Yamada posted 9 patches 3 months, 1 week ago
[PATCH v2 2/9] kconfig: gconf: use configure-event handler to adjust pane separator
Posted by Masahiro Yamada 3 months, 1 week ago
The size_request event handler is currently used to adjust the position
of the horizontal separator in the right pane.

However, the size_request signal is not available in GTK 3. Use the
configure-event signal instead.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - Use the "configure-event" instead of "size-allocate" signal.
    This fixes the problem where we cannot move the horizontal
    separator in the right pane.

 scripts/kconfig/gconf.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 22badd2f710e..8b19298eef61 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -604,23 +604,12 @@ static void on_window1_destroy(GtkObject *object, gpointer user_data)
 	gtk_main_quit();
 }
 
-static void on_window1_size_request(GtkWidget *widget,
-				    GtkRequisition *requisition,
-				    gpointer user_data)
+static gboolean on_window1_configure(GtkWidget *self,
+				     GdkEventConfigure *event,
+				     gpointer user_data)
 {
-	static gint old_h;
-	gint w, h;
-
-	if (widget->window == NULL)
-		gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
-	else
-		gdk_window_get_size(widget->window, &w, &h);
-
-	if (h == old_h)
-		return;
-	old_h = h;
-
-	gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
+	gtk_paned_set_position(GTK_PANED(vpaned), 2 * event->height / 3);
+	return FALSE;
 }
 
 static gboolean on_window1_delete_event(GtkWidget *widget, GdkEvent *event,
@@ -1021,8 +1010,8 @@ static void init_main_window(const gchar *glade_file)
 	main_wnd = glade_xml_get_widget(xml, "window1");
 	g_signal_connect(main_wnd, "destroy",
 			 G_CALLBACK(on_window1_destroy), NULL);
-	g_signal_connect(main_wnd, "size_request",
-			 G_CALLBACK(on_window1_size_request), NULL);
+	g_signal_connect(main_wnd, "configure-event",
+			 G_CALLBACK(on_window1_configure), NULL);
 	g_signal_connect(main_wnd, "delete_event",
 			 G_CALLBACK(on_window1_delete_event), NULL);
 
-- 
2.43.0
Re: [PATCH v2 2/9] kconfig: gconf: use configure-event handler to adjust pane separator
Posted by Randy Dunlap 3 months, 1 week ago

On 6/29/25 11:43 AM, Masahiro Yamada wrote:
> The size_request event handler is currently used to adjust the position
> of the horizontal separator in the right pane.
> 
> However, the size_request signal is not available in GTK 3. Use the
> configure-event signal instead.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Tested-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
> 
> Changes in v2:
>   - Use the "configure-event" instead of "size-allocate" signal.
>     This fixes the problem where we cannot move the horizontal
>     separator in the right pane.
> 
>  scripts/kconfig/gconf.c | 25 +++++++------------------
>  1 file changed, 7 insertions(+), 18 deletions(-)
> 
> diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
> index 22badd2f710e..8b19298eef61 100644
> --- a/scripts/kconfig/gconf.c
> +++ b/scripts/kconfig/gconf.c
> @@ -604,23 +604,12 @@ static void on_window1_destroy(GtkObject *object, gpointer user_data)
>  	gtk_main_quit();
>  }
>  
> -static void on_window1_size_request(GtkWidget *widget,
> -				    GtkRequisition *requisition,
> -				    gpointer user_data)
> +static gboolean on_window1_configure(GtkWidget *self,
> +				     GdkEventConfigure *event,
> +				     gpointer user_data)
>  {
> -	static gint old_h;
> -	gint w, h;
> -
> -	if (widget->window == NULL)
> -		gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
> -	else
> -		gdk_window_get_size(widget->window, &w, &h);
> -
> -	if (h == old_h)
> -		return;
> -	old_h = h;
> -
> -	gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
> +	gtk_paned_set_position(GTK_PANED(vpaned), 2 * event->height / 3);
> +	return FALSE;
>  }
>  
>  static gboolean on_window1_delete_event(GtkWidget *widget, GdkEvent *event,
> @@ -1021,8 +1010,8 @@ static void init_main_window(const gchar *glade_file)
>  	main_wnd = glade_xml_get_widget(xml, "window1");
>  	g_signal_connect(main_wnd, "destroy",
>  			 G_CALLBACK(on_window1_destroy), NULL);
> -	g_signal_connect(main_wnd, "size_request",
> -			 G_CALLBACK(on_window1_size_request), NULL);
> +	g_signal_connect(main_wnd, "configure-event",
> +			 G_CALLBACK(on_window1_configure), NULL);
>  	g_signal_connect(main_wnd, "delete_event",
>  			 G_CALLBACK(on_window1_delete_event), NULL);
>  

-- 
~Randy