[libhandy] glade: Rename window adapter to bin



commit 2dcc0cd1f22f03a8524a3b44df5eae38833fe2a8
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Dec 4 15:16:03 2020 +0500

    glade: Rename window adapter to bin
    
    We'll use it for HdyStatusPage in the next commit, make it generic to avoid
    copy-pasting it.

 glade/{glade-hdy-window.c => glade-hdy-bin.c} | 59 +++++++++++++--------------
 glade/glade-hdy-bin.h                         | 34 +++++++++++++++
 glade/glade-hdy-window.h                      | 34 ---------------
 glade/libhandy.xml                            | 24 +++++------
 glade/meson.build                             |  2 +-
 5 files changed, 76 insertions(+), 77 deletions(-)
---
diff --git a/glade/glade-hdy-window.c b/glade/glade-hdy-bin.c
similarity index 51%
rename from glade/glade-hdy-window.c
rename to glade/glade-hdy-bin.c
index 7832f912..779666fd 100644
--- a/glade/glade-hdy-window.c
+++ b/glade/glade-hdy-bin.c
@@ -11,16 +11,16 @@
 #include <config.h>
 #include <glib/gi18n-lib.h>
 
-#include "glade-hdy-window.h"
+#include "glade-hdy-bin.h"
 
 #include <gladeui/glade.h>
 
 #define ALREADY_HAS_A_CHILD_MSG _("%s cannot have more than one child.")
 
 static GtkWidget *
-get_child (GtkContainer *window)
+get_child (GtkContainer *container)
 {
-  g_autoptr (GList) children = gtk_container_get_children (window);
+  g_autoptr (GList) children = gtk_container_get_children (container);
 
   if (!children)
     return NULL;
@@ -29,9 +29,9 @@ get_child (GtkContainer *window)
 }
 
 void
-glade_hdy_window_post_create (GladeWidgetAdaptor *adaptor,
-                              GObject            *object,
-                              GladeCreateReason   reason)
+glade_hdy_bin_post_create (GladeWidgetAdaptor *adaptor,
+                           GObject            *object,
+                           GladeCreateReason   reason)
 {
   if (reason != GLADE_CREATE_USER)
     return;
@@ -40,17 +40,17 @@ glade_hdy_window_post_create (GladeWidgetAdaptor *adaptor,
 }
 
 void
-glade_hdy_window_add_child (GladeWidgetAdaptor *adaptor,
-                            GObject            *object,
-                            GObject            *child)
+glade_hdy_bin_add_child (GladeWidgetAdaptor *adaptor,
+                         GObject            *object,
+                         GObject            *child)
 {
-  GtkWidget *window_child = get_child (GTK_CONTAINER (object));
+  GtkWidget *container_child = get_child (GTK_CONTAINER (object));
 
-  if (window_child) {
-    if (GLADE_IS_PLACEHOLDER (window_child)) {
-      gtk_container_remove (GTK_CONTAINER (object), window_child);
+  if (container_child) {
+    if (GLADE_IS_PLACEHOLDER (container_child)) {
+      gtk_container_remove (GTK_CONTAINER (object), container_child);
     } else {
-      g_critical ("Can't add more than one widget to a HdyWindow");
+      g_critical ("Can't add more than one widget to a %s", G_OBJECT_TYPE_NAME (object));
 
       return;
     }
@@ -60,40 +60,40 @@ glade_hdy_window_add_child (GladeWidgetAdaptor *adaptor,
 }
 
 void
-glade_hdy_window_remove_child (GladeWidgetAdaptor *adaptor,
-                               GObject            *object,
-                               GObject            *child)
+glade_hdy_bin_remove_child (GladeWidgetAdaptor *adaptor,
+                            GObject            *object,
+                            GObject            *child)
 {
   gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
   gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
 }
 
 void
-glade_hdy_window_replace_child (GladeWidgetAdaptor *adaptor,
-                                GtkWidget          *object,
-                                GtkWidget          *current,
-                                GtkWidget          *new_widget)
+glade_hdy_bin_replace_child (GladeWidgetAdaptor *adaptor,
+                             GtkWidget          *object,
+                             GtkWidget          *current,
+                             GtkWidget          *new_widget)
 {
   gtk_container_remove (GTK_CONTAINER (object), current);
   gtk_container_add (GTK_CONTAINER (object), new_widget);
 }
 
 GList *
-glade_hdy_window_get_children (GladeWidgetAdaptor *adaptor,
-                               GObject            *object)
+glade_hdy_bin_get_children (GladeWidgetAdaptor *adaptor,
+                            GObject            *object)
 {
   return gtk_container_get_children (GTK_CONTAINER (object));
 }
 
 gboolean
-glade_hdy_window_add_verify (GladeWidgetAdaptor *adaptor,
-                             GtkWidget          *object,
-                             GtkWidget          *child,
-                             gboolean            user_feedback)
+glade_hdy_bin_add_verify (GladeWidgetAdaptor *adaptor,
+                          GtkWidget          *object,
+                          GtkWidget          *child,
+                          gboolean            user_feedback)
 {
-  GtkWidget *window_child = get_child (GTK_CONTAINER (object));
+  GtkWidget *container_child = get_child (GTK_CONTAINER (object));
 
-  if (window_child && !GLADE_IS_PLACEHOLDER (window_child)) {
+  if (container_child && !GLADE_IS_PLACEHOLDER (container_child)) {
     if (user_feedback)
       glade_util_ui_message (glade_app_get_window (),
                              GLADE_UI_INFO, NULL,
@@ -105,4 +105,3 @@ glade_hdy_window_add_verify (GladeWidgetAdaptor *adaptor,
 
   return TRUE;
 }
-
diff --git a/glade/glade-hdy-bin.h b/glade/glade-hdy-bin.h
new file mode 100644
index 00000000..8aeff6b7
--- /dev/null
+++ b/glade/glade-hdy-bin.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 Alexander Mikhaylenko <alexm gnome org>
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+
+#pragma once
+
+#include <gladeui/glade.h>
+
+#include <handy.h>
+
+void glade_hdy_bin_post_create (GladeWidgetAdaptor *adaptor,
+                                GObject            *object,
+                                GladeCreateReason   reason);
+
+void glade_hdy_bin_add_child (GladeWidgetAdaptor *adaptor,
+                              GObject            *object,
+                              GObject            *child);
+void glade_hdy_bin_remove_child (GladeWidgetAdaptor *adaptor,
+                                 GObject            *object,
+                                 GObject            *child);
+void glade_hdy_bin_replace_child (GladeWidgetAdaptor *adaptor,
+                                   GtkWidget          *object,
+                                   GtkWidget          *current,
+                                   GtkWidget          *new_widget);
+
+GList *glade_hdy_bin_get_children (GladeWidgetAdaptor *adaptor,
+                                   GObject            *object);
+
+gboolean glade_hdy_bin_add_verify (GladeWidgetAdaptor *adaptor,
+                                   GtkWidget          *object,
+                                   GtkWidget          *child,
+                                   gboolean            user_feedback);
diff --git a/glade/libhandy.xml b/glade/libhandy.xml
index 84fe0de0..6069105d 100644
--- a/glade/libhandy.xml
+++ b/glade/libhandy.xml
@@ -11,12 +11,12 @@
     </glade-widget-class>
     <glade-widget-class name="HdyAvatar" generic-name="avatar" title="Avatar" since="1.0"/>
     <glade-widget-class name="HdyApplicationWindow" generic-name="applicationwindow" title="Application 
Window" since="1.0" use-placeholders="False">
-      <post-create-function>glade_hdy_window_post_create</post-create-function>
-      <add-child-verify-function>glade_hdy_window_add_verify</add-child-verify-function>
-      <add-child-function>glade_hdy_window_add_child</add-child-function>
-      <remove-child-function>glade_hdy_window_remove_child</remove-child-function>
-      <replace-child-function>glade_hdy_window_replace_child</replace-child-function>
-      <get-children-function>glade_hdy_window_get_children</get-children-function>
+      <post-create-function>glade_hdy_bin_post_create</post-create-function>
+      <add-child-verify-function>glade_hdy_bin_add_verify</add-child-verify-function>
+      <add-child-function>glade_hdy_bin_add_child</add-child-function>
+      <remove-child-function>glade_hdy_bin_remove_child</remove-child-function>
+      <replace-child-function>glade_hdy_bin_replace_child</replace-child-function>
+      <get-children-function>glade_hdy_bin_get_children</get-children-function>
       <properties>
         <property id="show-menubar" disabled="True" />
         <property id="use-csd" disabled="True" />
@@ -404,12 +404,12 @@
       </properties>
     </glade-widget-class>
     <glade-widget-class name="HdyWindow" generic-name="window" title="Window" since="1.0" 
use-placeholders="False">
-      <post-create-function>glade_hdy_window_post_create</post-create-function>
-      <add-child-verify-function>glade_hdy_window_add_verify</add-child-verify-function>
-      <add-child-function>glade_hdy_window_add_child</add-child-function>
-      <remove-child-function>glade_hdy_window_remove_child</remove-child-function>
-      <replace-child-function>glade_hdy_window_replace_child</replace-child-function>
-      <get-children-function>glade_hdy_window_get_children</get-children-function>
+      <post-create-function>glade_hdy_bin_post_create</post-create-function>
+      <add-child-verify-function>glade_hdy_bin_add_verify</add-child-verify-function>
+      <add-child-function>glade_hdy_bin_add_child</add-child-function>
+      <remove-child-function>glade_hdy_bin_remove_child</remove-child-function>
+      <replace-child-function>glade_hdy_bin_replace_child</replace-child-function>
+      <get-children-function>glade_hdy_bin_get_children</get-children-function>
       <properties>
         <property id="use-csd" disabled="True" />
       </properties>
diff --git a/glade/meson.build b/glade/meson.build
index 946cd76a..d8e0d7ac 100644
--- a/glade/meson.build
+++ b/glade/meson.build
@@ -8,6 +8,7 @@ glade_catalogdir   = gladeui_dep.get_pkgconfig_variable('catalogdir',
                                                         define_variable: ['datadir', get_option('datadir')])
 
 libglade_hdy_sources = [
+  'glade-hdy-bin.c',
   'glade-hdy-carousel.c',
   'glade-hdy-expander-row.c',
   'glade-hdy-flap.c',
@@ -18,7 +19,6 @@ libglade_hdy_sources = [
   'glade-hdy-preferences-window.c',
   'glade-hdy-search-bar.c',
   'glade-hdy-swipe-group.c',
-  'glade-hdy-window.c',
   'glade-hdy-utils.c',
 ]
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]