[gnome-todo] Introduce GtdWidget and use it everywhere



commit 0067b4ffef654a6348381ee9c028b6bcd52686ae
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed May 6 10:54:55 2020 -0300

    Introduce GtdWidget and use it everywhere
    
    It's a plain dumb GtkWidget subclass that destroys
    its children on dispose. I wonder if this should be
    on GTK itself.

 src/gnome-todo.h                                   |  1 +
 src/gtd-omni-area.c                                | 22 ++++++-------
 src/gtd-omni-area.h                                |  4 ++-
 src/gtd-omni-area.ui                               |  6 ++--
 src/gtd-types.h                                    |  1 +
 src/gtd-utils-private.h                            |  4 ++-
 src/gtd-utils.c                                    |  9 +++++-
 src/gtd-utils.h                                    |  2 +-
 src/{widgets/gtd-row-header.c => gtd-widget.c}     | 37 ++++++++++++++--------
 src/{widgets/gtd-row-header.h => gtd-widget.h}     | 12 ++++---
 src/gtd-window.c                                   | 30 ++++++++----------
 src/main.c                                         |  5 ++-
 src/meson.build                                    |  5 ++-
 src/notification/gtd-notification-widget.c         |  4 +--
 src/notification/gtd-notification-widget.h         |  6 ++--
 src/notification/gtd-notification-widget.ui        |  2 +-
 src/plugins/task-lists-workspace/gtd-sidebar.c     |  4 +--
 src/plugins/task-lists-workspace/gtd-sidebar.h     |  6 ++--
 src/plugins/task-lists-workspace/gtd-sidebar.ui    |  2 +-
 .../gtd-task-lists-workspace.c                     | 15 +++------
 src/task-list-view/gtd-new-task-row.c              |  5 +--
 src/task-list-view/gtd-new-task-row.ui             |  1 -
 src/task-list-view/gtd-task-list-popover.c         |  2 +-
 src/task-list-view/gtd-task-list-view.c            |  9 +++---
 src/task-list-view/gtd-task-row.c                  | 12 +++----
 src/task-list-view/gtd-task-row.h                  |  5 +--
 src/task-list-view/gtd-task-row.ui                 |  4 +--
 src/widgets/gtd-menu-button.c                      | 16 ++--------
 src/widgets/gtd-star-widget.c                      | 16 ++--------
 src/widgets/gtd-star-widget.h                      |  4 +--
 30 files changed, 122 insertions(+), 129 deletions(-)
---
diff --git a/src/gnome-todo.h b/src/gnome-todo.h
index e8203df..3bb6434 100644
--- a/src/gnome-todo.h
+++ b/src/gnome-todo.h
@@ -42,6 +42,7 @@
 #include "gtd-text-width-layout.h"
 #include "gtd-types.h"
 #include "gtd-utils.h"
+#include "gtd-widget.h"
 #include "gtd-window.h"
 #include "gtd-workspace.h"
 
diff --git a/src/gtd-omni-area.c b/src/gtd-omni-area.c
index deb268c..2fa73fc 100644
--- a/src/gtd-omni-area.c
+++ b/src/gtd-omni-area.c
@@ -30,8 +30,9 @@
 
 struct _GtdOmniArea
 {
-  GtkWidget           parent;
+  GtdWidget           parent;
 
+  GtkWidget          *main_box;
   GtkStack           *main_stack;
   GtkStack           *status_stack;
 
@@ -43,7 +44,7 @@ struct _GtdOmniArea
   guint               switch_messages_timeout_id;
 };
 
-G_DEFINE_TYPE (GtdOmniArea, gtd_omni_area, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtdOmniArea, gtd_omni_area, GTD_TYPE_WIDGET)
 
 
 /*
@@ -104,24 +105,19 @@ on_omni_area_addin_removed_cb (PeasExtensionSet *extension_set,
 
 
 /*
- * GtkWidget overrides
+ * GObject overrides
  */
 
 static void
-gtd_omni_area_destroy (GtkWidget *widget)
+gtd_omni_area_dispose (GObject *object)
 {
-  GtdOmniArea *self = GTD_OMNI_AREA (widget);
+  GtdOmniArea *self = GTD_OMNI_AREA (object);
 
   g_clear_object (&self->addins);
 
-  GTK_WIDGET_CLASS (gtd_omni_area_parent_class)->destroy (widget);
+  G_OBJECT_CLASS (gtd_omni_area_parent_class)->dispose (object);
 }
 
-
-/*
- * GObject overrides
- */
-
 static void
 gtd_omni_area_finalize (GObject *object)
 {
@@ -139,14 +135,14 @@ gtd_omni_area_class_init (GtdOmniAreaClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = gtd_omni_area_dispose;
   object_class->finalize = gtd_omni_area_finalize;
 
-  widget_class->destroy = gtd_omni_area_destroy;
-
   g_type_ensure (GTD_TYPE_TEXT_WIDTH_LAYOUT);
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/gtd-omni-area.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, GtdOmniArea, main_box);
   gtk_widget_class_bind_template_child (widget_class, GtdOmniArea, main_stack);
   gtk_widget_class_bind_template_child (widget_class, GtdOmniArea, status_stack);
 
diff --git a/src/gtd-omni-area.h b/src/gtd-omni-area.h
index a08def0..9d49c38 100644
--- a/src/gtd-omni-area.h
+++ b/src/gtd-omni-area.h
@@ -23,10 +23,12 @@
 #include <gtk/gtk.h>
 #include <glib-object.h>
 
+#include "gtd-widget.h"
+
 G_BEGIN_DECLS
 
 #define GTD_TYPE_OMNI_AREA (gtd_omni_area_get_type())
-G_DECLARE_FINAL_TYPE (GtdOmniArea, gtd_omni_area, GTD, OMNI_AREA, GtkWidget)
+G_DECLARE_FINAL_TYPE (GtdOmniArea, gtd_omni_area, GTD, OMNI_AREA, GtdWidget)
 
 void                 gtd_omni_area_push_message                  (GtdOmniArea        *self,
                                                                   const gchar        *id,
diff --git a/src/gtd-omni-area.ui b/src/gtd-omni-area.ui
index b26aca6..4d9b197 100644
--- a/src/gtd-omni-area.ui
+++ b/src/gtd-omni-area.ui
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GtdOmniArea" parent="GtkWidget">
-
+  <template class="GtdOmniArea" parent="GtdWidget">
+    <property name="layout-manager">
+      <object class="GtkBinLayout" />
+    </property>
     <child>
       <object class="GtkCenterBox">
 
diff --git a/src/gtd-types.h b/src/gtd-types.h
index d1a8c7d..dfff130 100644
--- a/src/gtd-types.h
+++ b/src/gtd-types.h
@@ -48,6 +48,7 @@ typedef struct _GtdTask                 GtdTask;
 typedef struct _GtdTaskList             GtdTaskList;
 typedef struct _GtdTaskListItem         GtdTaskListItem;
 typedef struct _GtdTaskRow              GtdTaskRow;
+typedef struct _GtdWidget               GtdWidget;
 typedef struct _GtdWindow               GtdWindow;
 typedef struct _GtdWorkspace            GtdWorkspace;
 
diff --git a/src/gtd-utils-private.h b/src/gtd-utils-private.h
index 8a5f5d7..5bf687c 100644
--- a/src/gtd-utils-private.h
+++ b/src/gtd-utils-private.h
@@ -1,6 +1,6 @@
 /* gtd-utils-private.h
  *
- * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,4 +26,6 @@ G_BEGIN_DECLS
 
 GdkContentFormats*   _gtd_get_content_formats                    (void);
 
+void                 gtd_ensure_types                            (void);
+
 G_END_DECLS
diff --git a/src/gtd-utils.c b/src/gtd-utils.c
index 3e5646a..0eaad13 100644
--- a/src/gtd-utils.c
+++ b/src/gtd-utils.c
@@ -1,6 +1,6 @@
 /* gtd-utils.c
  *
- * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 #include "gtd-task.h"
 #include "gtd-utils.h"
 #include "gtd-utils-private.h"
+#include "gtd-widget.h"
 
 #include <gtk/gtk.h>
 
@@ -229,3 +230,9 @@ gtd_collate_compare_strings (const gchar *string_a,
 
   return g_strcmp0 (collated_a, collated_b);
 }
+
+void
+gtd_ensure_types (void)
+{
+  g_type_ensure (GTD_TYPE_WIDGET);
+}
diff --git a/src/gtd-utils.h b/src/gtd-utils.h
index 5d60f03..10097c3 100644
--- a/src/gtd-utils.h
+++ b/src/gtd-utils.h
@@ -1,6 +1,6 @@
 /* gtd-utils.h
  *
- * Copyright 2018 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/widgets/gtd-row-header.c b/src/gtd-widget.c
similarity index 56%
rename from src/widgets/gtd-row-header.c
rename to src/gtd-widget.c
index 25a5ad9..48ee3cd 100644
--- a/src/widgets/gtd-row-header.c
+++ b/src/gtd-widget.c
@@ -1,4 +1,4 @@
-/* gtd-row-header.c
+/* gtd-widget.c
  *
  * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
@@ -18,33 +18,42 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include "gtd-row-header.h"
+#include "gtd-widget.h"
 #include "gtd-rows-common-private.h"
 
-struct _GtdRowHeader
+G_DEFINE_TYPE (GtdWidget, gtd_widget, GTK_TYPE_WIDGET)
+
+static void
+gtd_widget_dispose (GObject *object)
 {
-  GtkWidget parent_instance;
-};
+  GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (object));
+
+  while (child)
+    {
+      GtkWidget *next = gtk_widget_get_next_sibling (child);
 
-G_DEFINE_TYPE (GtdRowHeader, gtd_row_header, GTK_TYPE_WIDGET)
+      gtk_widget_unparent (child);
+      child = next;
+    }
+
+  G_OBJECT_CLASS (gtd_widget_parent_class)->dispose (object);
+}
 
 static void
-gtd_row_header_class_init (GtdRowHeaderClass *klass)
+gtd_widget_class_init (GtdWidgetClass *klass)
 {
-  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  widget_class->measure = gtd_row_measure_with_max;
+  object_class->dispose = gtd_widget_dispose;
 }
 
 static void
-gtd_row_header_init (GtdRowHeader *self)
+gtd_widget_init (GtdWidget *self)
 {
 }
 
 GtkWidget*
-gtd_row_header_new (void)
+gtd_widget_new (void)
 {
-  return g_object_new (GTD_TYPE_ROW_HEADER,
-                       "halign", GTK_ALIGN_CENTER,
-                       NULL);
+  return g_object_new (GTD_TYPE_WIDGET, NULL);
 }
diff --git a/src/widgets/gtd-row-header.h b/src/gtd-widget.h
similarity index 76%
rename from src/widgets/gtd-row-header.h
rename to src/gtd-widget.h
index 5e0b110..dff5e54 100644
--- a/src/widgets/gtd-row-header.h
+++ b/src/gtd-widget.h
@@ -1,4 +1,4 @@
-/* gtd-row-header.h
+/* gtd-'gtd-widget.c',.h
  *
  * Copyright 2018-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
@@ -24,10 +24,14 @@
 
 G_BEGIN_DECLS
 
-#define GTD_TYPE_ROW_HEADER (gtd_row_header_get_type())
+#define GTD_TYPE_WIDGET (gtd_widget_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GtdWidget, gtd_widget, GTD, WIDGET, GtkWidget)
 
-G_DECLARE_FINAL_TYPE (GtdRowHeader, gtd_row_header, GTD, ROW_HEADER, GtkWidget)
+struct _GtdWidgetClass
+{
+  GtkWidgetClass      parent;
+};
 
-GtkWidget*           gtd_row_header_new                          (void);
+GtkWidget*           gtd_widget_new                              (void);
 
 G_END_DECLS
diff --git a/src/gtd-window.c b/src/gtd-window.c
index e6be5dd..f4fc6a3 100644
--- a/src/gtd-window.c
+++ b/src/gtd-window.c
@@ -272,25 +272,23 @@ on_action_toggle_fullscreen_state_changed_cb (GSimpleAction *simple,
                                               GVariant      *state,
                                               gpointer       user_data)
 {
-  GtkContainer *parent;
   GtdWindow *self;
   gboolean fullscreen;
 
   self = GTD_WINDOW (user_data);
   fullscreen = g_variant_get_boolean (state);
-  parent = GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (self->headerbar)));
 
   g_clear_handle_id (&self->toggle_headerbar_revealer_id, g_source_remove);
 
   gtk_header_bar_set_show_title_buttons (self->headerbar, !fullscreen);
 
   g_object_ref (self->headerbar);
-  gtk_container_remove (parent, GTK_WIDGET (self->headerbar));
+  gtk_widget_unparent (GTK_WIDGET (self->headerbar));
 
   if (fullscreen)
     {
       gtk_event_controller_set_propagation_phase (self->overlay_motion_controller, GTK_PHASE_BUBBLE);
-      gtk_container_add (GTK_CONTAINER (self->headerbar_overlay_revealer), GTK_WIDGET (self->headerbar));
+      gtk_revealer_set_child (self->headerbar_overlay_revealer, GTK_WIDGET (self->headerbar));
       gtk_revealer_set_reveal_child (self->headerbar_overlay_revealer, TRUE);
       gtk_window_fullscreen (GTK_WINDOW (self));
 
@@ -299,7 +297,7 @@ on_action_toggle_fullscreen_state_changed_cb (GSimpleAction *simple,
   else
     {
       gtk_event_controller_set_propagation_phase (self->overlay_motion_controller, GTK_PHASE_NONE);
-      gtk_revealer_set_reveal_child (self->headerbar_overlay_revealer, FALSE);
+      //gtk_revealer_set_reveal_child (self->headerbar_overlay_revealer, FALSE);
       gtk_container_add (GTK_CONTAINER (self->headerbar_box), GTK_WIDGET (self->headerbar));
       gtk_window_unfullscreen (GTK_WINDOW (self));
     }
@@ -503,16 +501,6 @@ create_workspace_row_func (gpointer item,
  * GtkWindow overrides
  */
 
-static void
-gtd_window_destroy (GtkWidget *widget)
-{
-  GtdWindow *self = GTD_WINDOW (widget);
-
-  g_clear_object (&self->workspaces_set);
-
-  GTK_WIDGET_CLASS (gtd_window_parent_class)->destroy (widget);
-}
-
 static void
 gtd_window_unmap (GtkWidget *widget)
 {
@@ -542,6 +530,16 @@ gtd_window_unmap (GtkWidget *widget)
  * GObject overrides
  */
 
+static void
+gtd_window_dispose (GObject *object)
+{
+  GtdWindow *self = GTD_WINDOW (object);
+
+  g_clear_object (&self->workspaces_set);
+
+  G_OBJECT_CLASS (gtd_window_parent_class)->dispose (object);
+}
+
 static void
 gtd_window_finalize (GObject *object)
 {
@@ -591,10 +589,10 @@ gtd_window_class_init (GtdWindowClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = gtd_window_dispose;
   object_class->finalize = gtd_window_finalize;
   object_class->constructed = gtd_window_constructed;
 
-  widget_class->destroy = gtd_window_destroy;
   widget_class->unmap = gtd_window_unmap;
 
   g_type_ensure (GTD_TYPE_MENU_BUTTON);
diff --git a/src/main.c b/src/main.c
index 3237f10..52f43d3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
 /*
  * main.c
- * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2015-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
  *
  * gnome-todo is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -17,6 +17,7 @@
  */
 
 #include "gtd-application.h"
+#include "gtd-utils-private.h"
 
 #include <config.h>
 #include <glib/gi18n.h>
@@ -28,6 +29,8 @@ main (gint    argc,
   g_autoptr (GtdApplication) app = NULL;
   g_autofree gchar *program_name = NULL;
 
+  gtd_ensure_types ();
+
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
diff --git a/src/meson.build b/src/meson.build
index d18aff1..09663cc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -71,6 +71,7 @@ headers = enum_headers + files(
   'gtd-text-width-layout.h',
   'gtd-types.h',
   'gtd-utils.h',
+  'gtd-widget.h',
   'gtd-window.h',
   'gnome-todo.h'
 )
@@ -109,7 +110,6 @@ sources += files(
   'widgets/gtd-color-button.c',
   'widgets/gtd-empty-list-widget.c',
   'widgets/gtd-menu-button.c',
-  'widgets/gtd-row-header.c',
   'widgets/gtd-star-widget.c',
   'gtd-application.c',
   'gtd-initial-setup-window.c',
@@ -126,6 +126,7 @@ sources += files(
   'gtd-text-width-layout.c',
   'gtd-theme-manager.c',
   'gtd-utils.c',
+  'gtd-widget.c',
   'gtd-window.c',
   'main.c'
 )
@@ -286,6 +287,8 @@ if get_option('introspection')
     'gtd-text-width-layout.c',
     'gtd-text-width-layout.h',
     'gtd-types.h',
+    'gtd-widget.c',
+    'gtd-widget.h',
     'gtd-window.c',
     'gtd-window.h'
   )
diff --git a/src/notification/gtd-notification-widget.c b/src/notification/gtd-notification-widget.c
index 6a38e22..1cd30c4 100644
--- a/src/notification/gtd-notification-widget.c
+++ b/src/notification/gtd-notification-widget.c
@@ -29,7 +29,7 @@ typedef enum
 
 struct _GtdNotificationWidget
 {
-  GtkWidget           parent;
+  GtdWidget           parent;
 
   /* widgets */
   GtkButton          *secondary_button;
@@ -56,7 +56,7 @@ static void          execute_notification                        (GtdNotificatio
 static void          on_notification_executed_cb                 (GtdNotification       *notification,
                                                                   GtdNotificationWidget *self);
 
-G_DEFINE_TYPE (GtdNotificationWidget, gtd_notification_widget, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtdNotificationWidget, gtd_notification_widget, GTD_TYPE_WIDGET)
 
 static void
 clear_bindings (GtdNotificationWidget *self)
diff --git a/src/notification/gtd-notification-widget.h b/src/notification/gtd-notification-widget.h
index 93ecb74..032edb8 100644
--- a/src/notification/gtd-notification-widget.h
+++ b/src/notification/gtd-notification-widget.h
@@ -19,14 +19,12 @@
 #ifndef GTD_NOTIFICATION_WIDGET_H
 #define GTD_NOTIFICATION_WIDGET_H
 
-#include "gtd-types.h"
-
-#include <gtk/gtk.h>
+#include "gnome-todo.h"
 
 G_BEGIN_DECLS
 
 #define GTD_TYPE_NOTIFICATION_WIDGET (gtd_notification_widget_get_type())
-G_DECLARE_FINAL_TYPE (GtdNotificationWidget, gtd_notification_widget, GTD, NOTIFICATION_WIDGET, GtkWidget)
+G_DECLARE_FINAL_TYPE (GtdNotificationWidget, gtd_notification_widget, GTD, NOTIFICATION_WIDGET, GtdWidget)
 
 GtkWidget*           gtd_notification_widget_new                 (void);
 
diff --git a/src/notification/gtd-notification-widget.ui b/src/notification/gtd-notification-widget.ui
index f6e3477..70b14c9 100644
--- a/src/notification/gtd-notification-widget.ui
+++ b/src/notification/gtd-notification-widget.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.16"/>
-  <template class="GtdNotificationWidget" parent="GtkWidget">
+  <template class="GtdNotificationWidget" parent="GtdWidget">
     <child>
       <object class="GtkRevealer" id="revealer">
         <child>
diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.c b/src/plugins/task-lists-workspace/gtd-sidebar.c
index 9416c02..6380d4f 100644
--- a/src/plugins/task-lists-workspace/gtd-sidebar.c
+++ b/src/plugins/task-lists-workspace/gtd-sidebar.c
@@ -38,7 +38,7 @@
 
 struct _GtdSidebar
 {
-  GtkWidget           parent;
+  GtdWidget           parent;
 
   GtkListBox         *archive_listbox;
   GtkListBoxRow      *archive_row;
@@ -51,7 +51,7 @@ struct _GtdSidebar
   GSimpleActionGroup *action_group;
 };
 
-G_DEFINE_TYPE (GtdSidebar, gtd_sidebar, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtdSidebar, gtd_sidebar, GTD_TYPE_WIDGET)
 
 
 /*
diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.h b/src/plugins/task-lists-workspace/gtd-sidebar.h
index 1bca639..20d603b 100644
--- a/src/plugins/task-lists-workspace/gtd-sidebar.h
+++ b/src/plugins/task-lists-workspace/gtd-sidebar.h
@@ -20,14 +20,12 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
-
-#include "gtd-panel.h"
+#include "gnome-todo.h"
 
 G_BEGIN_DECLS
 
 #define GTD_TYPE_SIDEBAR (gtd_sidebar_get_type())
-G_DECLARE_FINAL_TYPE (GtdSidebar, gtd_sidebar, GTD, SIDEBAR, GtkWidget)
+G_DECLARE_FINAL_TYPE (GtdSidebar, gtd_sidebar, GTD, SIDEBAR, GtdWidget)
 
 void                 gtd_sidebar_set_panel_stack                 (GtdSidebar         *self,
                                                                   GtkStack           *stack);
diff --git a/src/plugins/task-lists-workspace/gtd-sidebar.ui b/src/plugins/task-lists-workspace/gtd-sidebar.ui
index 90d1966..e32d520 100644
--- a/src/plugins/task-lists-workspace/gtd-sidebar.ui
+++ b/src/plugins/task-lists-workspace/gtd-sidebar.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GtdSidebar" parent="GtkWidget">
+  <template class="GtdSidebar" parent="GtdWidget">
     <property name="hexpand">0</property>
     <property name="layout-manager">
       <object class="GtdTextWidthLayout">
diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c 
b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
index 31e70f9..e805f7d 100644
--- a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
+++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
@@ -334,26 +334,21 @@ gtd_workspace_iface_init (GtdWorkspaceInterface  *iface)
 
 
 /*
- * GtkWidget overrides
+ * GObject overrides
  */
 
 static void
-gtd_task_lists_workspace_destroy (GtkWidget *widget)
+gtd_task_lists_workspace_dispose (GObject *object)
 {
-  GtdTaskListsWorkspace *self = (GtdTaskListsWorkspace *)widget;
+  GtdTaskListsWorkspace *self = (GtdTaskListsWorkspace *)object;
 
-  GTK_WIDGET_CLASS (gtd_task_lists_workspace_parent_class)->destroy (widget);
+  G_OBJECT_CLASS (gtd_task_lists_workspace_parent_class)->dispose (object);
 
   g_signal_handlers_disconnect_by_func (self->panels_set, on_panel_added_cb, self);
   g_signal_handlers_disconnect_by_func (self->panels_set, on_panel_removed_cb, self);
   g_clear_object (&self->panels_set);
 }
 
-
-/*
- * GObject overrides
- */
-
 static void
 gtd_task_lists_workspace_constructed (GObject *object)
 {
@@ -426,11 +421,11 @@ gtd_task_lists_workspace_class_init (GtdTaskListsWorkspaceClass *klass)
 
   g_resources_register (task_lists_workspace_get_resource ());
 
+  object_class->dispose = gtd_task_lists_workspace_dispose;
   object_class->constructed = gtd_task_lists_workspace_constructed;
   object_class->get_property = gtd_task_lists_workspace_get_property;
   object_class->set_property = gtd_task_lists_workspace_set_property;
 
-  widget_class->destroy = gtd_task_lists_workspace_destroy;
 
   /**
    * GtdTaskListsWorkspace::panel-added:
diff --git a/src/task-list-view/gtd-new-task-row.c b/src/task-list-view/gtd-new-task-row.c
index 4f57267..4352004 100644
--- a/src/task-list-view/gtd-new-task-row.c
+++ b/src/task-list-view/gtd-new-task-row.c
@@ -244,6 +244,8 @@ gtd_new_task_row_dispose (GObject *object)
       self->tasklist_popover = NULL;
     }
 
+  g_clear_pointer (&self->entry, gtk_widget_unparent);
+
   G_OBJECT_CLASS (gtd_new_task_row_parent_class)->dispose (object);
 }
 
@@ -275,8 +277,6 @@ gtd_new_task_row_class_init (GtdNewTaskRowClass *klass)
   object_class->get_property = gtd_new_task_row_get_property;
   object_class->set_property = gtd_new_task_row_set_property;
 
-  widget_class->measure = gtd_row_measure_with_max;
-
   /**
    * GtdNewTaskRow::enter:
    *
@@ -318,6 +318,7 @@ gtd_new_task_row_class_init (GtdNewTaskRowClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, on_tasklist_popover_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_tasklist_popover_closed_cb);
 
+  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
   gtk_widget_class_set_css_name (widget_class, "newtaskrow");
 
   g_type_ensure (GTD_TYPE_TASK_LIST_POPOVER);
diff --git a/src/task-list-view/gtd-new-task-row.ui b/src/task-list-view/gtd-new-task-row.ui
index 6df271d..b28a126 100644
--- a/src/task-list-view/gtd-new-task-row.ui
+++ b/src/task-list-view/gtd-new-task-row.ui
@@ -5,7 +5,6 @@
     <property name="can_focus">1</property>
     <property name="margin-top">12</property>
     <property name="height-request">42</property>
-    <property name="halign">center</property>
     <property name="css-name">newtaskrow</property>
     <child>
       <object class="GtkEntry" id="entry">
diff --git a/src/task-list-view/gtd-task-list-popover.c b/src/task-list-view/gtd-task-list-popover.c
index 50562fa..2467f93 100644
--- a/src/task-list-view/gtd-task-list-popover.c
+++ b/src/task-list-view/gtd-task-list-popover.c
@@ -149,7 +149,7 @@ create_list_row_cb (gpointer item,
 
   /* The row itself */
   row = gtk_list_box_row_new ();
-  gtk_container_add (GTK_CONTAINER (row), box);
+  gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
 
   g_object_set_data (G_OBJECT (row), "tasklist", item);
 
diff --git a/src/task-list-view/gtd-task-list-view.c b/src/task-list-view/gtd-task-list-view.c
index 42fc65c..310e6ac 100644
--- a/src/task-list-view/gtd-task-list-view.c
+++ b/src/task-list-view/gtd-task-list-view.c
@@ -28,11 +28,11 @@
 #include "gtd-new-task-row.h"
 #include "gtd-notification.h"
 #include "gtd-provider.h"
-#include "gtd-row-header.h"
 #include "gtd-task.h"
 #include "gtd-task-list.h"
 #include "gtd-task-row.h"
 #include "gtd-utils-private.h"
+#include "gtd-widget.h"
 #include "gtd-window.h"
 
 #include <glib.h>
@@ -310,8 +310,7 @@ create_row_for_task_cb (gpointer item,
   g_signal_connect (row, "remove-task", G_CALLBACK (on_remove_task_row_cb), self);
 
   listbox_row = gtk_list_box_row_new ();
-  gtk_widget_set_halign (listbox_row, GTK_ALIGN_CENTER);
-  gtk_container_add (GTK_CONTAINER (listbox_row), row);
+  gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (listbox_row), row);
 
   g_object_bind_property (row, "visible", listbox_row, "visible", G_BINDING_BIDIRECTIONAL);
 
@@ -597,8 +596,8 @@ internal_header_func (GtkListBoxRow   *row,
 
   if (header)
     {
-      GtkWidget *real_header = gtd_row_header_new ();
-      gtk_container_add (GTK_CONTAINER (real_header), header);
+      GtkWidget *real_header = gtd_widget_new ();
+      gtk_widget_insert_before (header, real_header, NULL);
 
       header = real_header;
     }
diff --git a/src/task-list-view/gtd-task-row.c b/src/task-list-view/gtd-task-row.c
index 5dde43b..905339a 100644
--- a/src/task-list-view/gtd-task-row.c
+++ b/src/task-list-view/gtd-task-row.c
@@ -30,6 +30,7 @@
 #include "gtd-task-list.h"
 #include "gtd-task-list-view.h"
 #include "gtd-utils-private.h"
+#include "gtd-widget.h"
 
 #include <glib/gi18n.h>
 #include <gdk/gdk.h>
@@ -37,7 +38,7 @@
 
 struct _GtdTaskRow
 {
-  GtkWidget           parent;
+  GtdWidget           parent;
 
   /*<private>*/
   GtkWidget          *content_box;
@@ -79,7 +80,7 @@ static void          on_star_widget_activated_cb                 (GtdStarWidget
                                                                   GParamSpec         *pspec,
                                                                   GtdTaskRow         *self);
 
-G_DEFINE_TYPE (GtdTaskRow, gtd_task_row, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtdTaskRow, gtd_task_row, GTD_TYPE_WIDGET)
 
 enum
 {
@@ -606,8 +607,6 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
   object_class->get_property = gtd_task_row_get_property;
   object_class->set_property = gtd_task_row_set_property;
 
-  widget_class->measure = gtd_row_measure_with_max;
-
   /**
    * GtdTaskRow::handle-subtasks:
    *
@@ -716,6 +715,7 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, on_remove_task_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_task_changed_cb);
 
+  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
   gtk_widget_class_set_css_name (widget_class, "taskrow");
 }
 
@@ -870,7 +870,7 @@ gtd_task_row_set_active (GtdTaskRow *self,
       gtd_edit_pane_set_markdown_renderer (self->edit_pane, self->renderer);
       gtd_edit_pane_set_task (self->edit_pane, self->task);
 
-      gtk_container_add (GTK_CONTAINER (self->edit_panel_revealer), GTK_WIDGET (self->edit_pane));
+      gtk_revealer_set_child (GTK_REVEALER (self->edit_panel_revealer), GTK_WIDGET (self->edit_pane));
       gtk_widget_show (GTK_WIDGET (self->edit_pane));
 
       g_signal_connect_swapped (self->edit_pane, "changed", G_CALLBACK (on_task_changed_cb), self);
@@ -880,7 +880,7 @@ gtd_task_row_set_active (GtdTaskRow *self,
     {
       GTD_TRACE_MSG ("Destroying edit pane");
 
-      gtk_container_remove (GTK_CONTAINER (self->edit_panel_revealer), GTK_WIDGET (self->edit_pane));
+      gtk_revealer_set_child (GTK_REVEALER (self->edit_panel_revealer), NULL);
       self->edit_pane = NULL;
     }
 
diff --git a/src/task-list-view/gtd-task-row.h b/src/task-list-view/gtd-task-row.h
index 011e2d6..f283350 100644
--- a/src/task-list-view/gtd-task-row.h
+++ b/src/task-list-view/gtd-task-row.h
@@ -19,10 +19,7 @@
 #ifndef GTD_TASK_ROW_H
 #define GTD_TASK_ROW_H
 
-#include "gtd-types.h"
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
+#include "gnome-todo.h"
 
 G_BEGIN_DECLS
 
diff --git a/src/task-list-view/gtd-task-row.ui b/src/task-list-view/gtd-task-row.ui
index 9b75d9a..ffa6860 100644
--- a/src/task-list-view/gtd-task-row.ui
+++ b/src/task-list-view/gtd-task-row.ui
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.16"/>
-  <template class="GtdTaskRow" parent="GtkWidget">
-    <property name="halign">center</property>
+  <template class="GtdTaskRow" parent="GtdWidget">
+    <property name="hexpand">true</property>
     <child>
       <object class="GtkEventControllerKey">
         <property name="propagation-phase">capture</property>
diff --git a/src/widgets/gtd-menu-button.c b/src/widgets/gtd-menu-button.c
index a2427ef..c9cbc47 100644
--- a/src/widgets/gtd-menu-button.c
+++ b/src/widgets/gtd-menu-button.c
@@ -130,7 +130,7 @@ add_arrow (GtdMenuButton *self)
 
   arrow = gtk_image_new ();
   set_arrow_type (GTK_IMAGE (arrow), priv->arrow_type);
-  gtk_container_add (GTK_CONTAINER (priv->button), arrow);
+  gtk_button_set_child (GTK_BUTTON (priv->button), arrow);
   priv->arrow_widget = arrow;
 }
 
@@ -794,17 +794,12 @@ gtd_menu_button_set_gicon (GtdMenuButton *self,
                            GIcon         *icon)
 {
   GtdMenuButtonPrivate *priv = gtd_menu_button_get_instance_private (self);
-  GtkWidget *child;
   GtkWidget *box;
   GtkWidget *icon_image;
   GtkWidget *image;
 
   g_return_if_fail (GTD_IS_MENU_BUTTON (self));
 
-  child = gtk_button_get_child (GTK_BUTTON (priv->button));
-  if (child)
-    gtk_container_remove (GTK_CONTAINER (priv->button), child);
-
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_widget_set_margin_start (box, 6);
   gtk_widget_set_margin_end (box, 6);
@@ -816,7 +811,7 @@ gtd_menu_button_set_gicon (GtdMenuButton *self,
 
   gtk_container_add (GTK_CONTAINER (box), icon_image);
   gtk_container_add (GTK_CONTAINER (box), image);
-  gtk_container_add (GTK_CONTAINER (priv->button), box);
+  gtk_button_set_child (GTK_BUTTON (priv->button), box);
 
   g_object_notify_by_pspec (G_OBJECT (self), menu_button_props[PROP_GICON]);
 }
@@ -851,17 +846,12 @@ gtd_menu_button_set_label (GtdMenuButton *self,
                            const gchar   *label)
 {
   GtdMenuButtonPrivate *priv = gtd_menu_button_get_instance_private (self);
-  GtkWidget *child;
   GtkWidget *box;
   GtkWidget *label_widget;
   GtkWidget *image;
 
   g_return_if_fail (GTD_IS_MENU_BUTTON (self));
 
-  child = gtk_button_get_child (GTK_BUTTON (priv->button));
-  if (child)
-    gtk_container_remove (GTK_CONTAINER (priv->button), child);
-
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_widget_set_margin_start (box, 6);
   gtk_widget_set_margin_end (box, 6);
@@ -874,7 +864,7 @@ gtd_menu_button_set_label (GtdMenuButton *self,
   image = gtk_image_new_from_icon_name ("pan-down-symbolic");
   gtk_container_add (GTK_CONTAINER (box), label_widget);
   gtk_container_add (GTK_CONTAINER (box), image);
-  gtk_container_add (GTK_CONTAINER (priv->button), box);
+  gtk_button_set_child (GTK_BUTTON (priv->button), box);
   priv->label_widget = label_widget;
 
   g_object_notify_by_pspec (G_OBJECT (self), menu_button_props[PROP_LABEL]);
diff --git a/src/widgets/gtd-star-widget.c b/src/widgets/gtd-star-widget.c
index 4079377..cb6991b 100644
--- a/src/widgets/gtd-star-widget.c
+++ b/src/widgets/gtd-star-widget.c
@@ -22,7 +22,7 @@
 
 struct _GtdStarWidget
 {
-  GtkWidget           parent;
+  GtdWidget           parent;
 
   GtkWidget          *filled_star;
   GtkWidget          *empty_star;
@@ -30,7 +30,7 @@ struct _GtdStarWidget
   gboolean            active;
 };
 
-G_DEFINE_TYPE (GtdStarWidget, gtd_star_widget, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtdStarWidget, gtd_star_widget, GTD_TYPE_WIDGET)
 
 enum
 {
@@ -62,17 +62,6 @@ on_star_widget_clicked_cb (GtkGestureClick *gesture,
  * GObject overrides
  */
 
-static void
-gtd_star_widget_dispose (GObject *object)
-{
-  GtdStarWidget *self = GTD_STAR_WIDGET (object);
-
-  g_clear_pointer (&self->empty_star, gtk_widget_unparent);
-  g_clear_pointer (&self->filled_star, gtk_widget_unparent);
-
-  G_OBJECT_CLASS (gtd_star_widget_parent_class)->dispose (object);
-}
-
 static void
 gtd_star_widget_get_property (GObject    *object,
                               guint       prop_id,
@@ -117,7 +106,6 @@ gtd_star_widget_class_init (GtdStarWidgetClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->dispose = gtd_star_widget_dispose;
   object_class->get_property = gtd_star_widget_get_property;
   object_class->set_property = gtd_star_widget_set_property;
 
diff --git a/src/widgets/gtd-star-widget.h b/src/widgets/gtd-star-widget.h
index 7a103f5..3c3b9fa 100644
--- a/src/widgets/gtd-star-widget.h
+++ b/src/widgets/gtd-star-widget.h
@@ -20,12 +20,12 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
+#include "gnome-todo.h"
 
 G_BEGIN_DECLS
 
 #define GTD_TYPE_STAR_WIDGET (gtd_star_widget_get_type())
-G_DECLARE_FINAL_TYPE (GtdStarWidget, gtd_star_widget, GTD, STAR_WIDGET, GtkWidget)
+G_DECLARE_FINAL_TYPE (GtdStarWidget, gtd_star_widget, GTD, STAR_WIDGET, GtdWidget)
 
 GtkWidget*           gtd_star_widget_new                         (void);
 


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