[gnome-todo] Switch to GtkEditable API



commit 8b32bcfca5fb75651797522d546ec0654266b1c4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Mar 28 17:28:27 2019 -0300

    Switch to GtkEditable API
    
    GtkEditable is now responsible for the text management
    functions. Switch to it, and remove the now deprecated
    GtdExpandableEntry too.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-todo/issues/240

 src/gtd-task-list-panel.c                  |  20 +--
 src/meson.build                            |   1 -
 src/provider/gtd-provider-popover.c        |   8 +-
 src/task-list-view/gtd-new-task-row.c      |   4 +-
 src/task-list-view/gtd-task-list-popover.c |  12 +-
 src/task-list-view/gtd-task-row.c          |   3 -
 src/task-list-view/gtd-task-row.ui         |   4 +-
 src/widgets/gtd-expandable-entry.c         | 212 -----------------------------
 src/widgets/gtd-expandable-entry.h         |  40 ------
 tests/interactive/test-filter-sort.c       |   2 +-
 10 files changed, 25 insertions(+), 281 deletions(-)
---
diff --git a/src/gtd-task-list-panel.c b/src/gtd-task-list-panel.c
index 5f0dd40..38383c2 100644
--- a/src/gtd-task-list-panel.c
+++ b/src/gtd-task-list-panel.c
@@ -36,7 +36,7 @@ struct _GtdTaskListPanel
   GtkFlowBox         *colors_flowbox;
   GtkPopover         *popover;
   GtkWidget          *rename_button;
-  GtkEntry           *rename_entry;
+  GtkEditable        *rename_entry;
   GtdTaskListView    *task_list_view;
 
   GtkWidget          *previous_color_button;
@@ -154,12 +154,12 @@ rename_list (GtdTaskListPanel *self)
   GtdTaskList *list;
 
   g_assert (gtk_widget_get_visible (GTK_WIDGET (self->popover)));
-  g_assert (g_utf8_validate (gtk_entry_get_text (self->rename_entry), -1, NULL));
+  g_assert (g_utf8_validate (gtk_editable_get_text (self->rename_entry), -1, NULL));
 
   list = GTD_TASK_LIST (gtd_task_list_view_get_model (self->task_list_view));
   g_assert (list != NULL);
 
-  new_name = g_strdup (gtk_entry_get_text (self->rename_entry));
+  new_name = g_strdup (gtk_editable_get_text (self->rename_entry));
   new_name = g_strstrip (new_name);
 
   /*
@@ -169,14 +169,14 @@ rename_list (GtdTaskListPanel *self)
   if (!new_name || new_name[0] == '\0')
     return;
 
-  if (g_strcmp0 (gtk_entry_get_text (self->rename_entry), gtd_task_list_get_name (list)) != 0)
+  if (g_strcmp0 (new_name, gtd_task_list_get_name (list)) != 0)
     {
-      gtd_task_list_set_name (list, gtk_entry_get_text (self->rename_entry));
+      gtd_task_list_set_name (list, new_name);
       gtd_provider_update_task_list (gtd_task_list_get_provider (list), list);
     }
 
   gtk_popover_popdown (self->popover);
-  gtk_entry_set_text (self->rename_entry, "");
+  gtk_editable_set_text (self->rename_entry, "");
 }
 
 
@@ -235,7 +235,7 @@ static void
 on_popover_hidden_cb (GtkPopover       *popover,
                       GtdTaskListPanel *self)
 {
-  gtk_entry_set_text (self->rename_entry, "");
+  gtk_editable_set_text (self->rename_entry, "");
 }
 
 static void
@@ -253,15 +253,14 @@ on_rename_entry_activated_cb (GtkEntry         *entry,
 }
 
 static void
-on_rename_entry_text_changed_cb (GtkEntry         *entry,
+on_rename_entry_text_changed_cb (GtkEditable      *entry,
                                  GParamSpec       *pspec,
                                  GtdTaskListPanel *self)
 {
-
   g_autofree gchar *new_name = NULL;
   gboolean valid;
 
-  new_name = g_strdup (gtk_entry_get_text (self->rename_entry));
+  new_name = g_strdup (gtk_editable_get_text (entry));
   new_name = g_strstrip (new_name);
 
   valid = new_name && new_name[0] != '\0';
@@ -437,6 +436,7 @@ gtd_task_list_panel_class_init (GtdTaskListPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, popover);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_button);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_entry);
+  gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, rename_entry);
   gtk_widget_class_bind_template_child (widget_class, GtdTaskListPanel, task_list_view);
 
   gtk_widget_class_bind_template_callback (widget_class, on_colors_flowbox_child_activated_cb);
diff --git a/src/meson.build b/src/meson.build
index 514557d..627a14b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -69,7 +69,6 @@ sources = files(
   'task-list-view/gtd-task-row.c',
   'widgets/gtd-color-button.c',
   'widgets/gtd-empty-list-widget.c',
-  'widgets/gtd-expandable-entry.c',
   'widgets/gtd-row-header.c',
   'gtd-application.c',
   'gtd-initial-setup-window.c',
diff --git a/src/provider/gtd-provider-popover.c b/src/provider/gtd-provider-popover.c
index 55a7621..42b41bb 100644
--- a/src/provider/gtd-provider-popover.c
+++ b/src/provider/gtd-provider-popover.c
@@ -33,7 +33,7 @@ struct _GtdProviderPopover
   GtkWidget            *change_location_button;
   GtkWidget            *location_provider_image;
   GtkWidget            *new_list_create_button;
-  GtkWidget            *new_list_name_entry;
+  GtkEditable          *new_list_name_entry;
   GtkWidget            *stack;
   GtkWidget            *provider_selector;
 };
@@ -66,7 +66,7 @@ clear_and_hide (GtdProviderPopover *popover)
   g_list_free (locations);
 
   /* By clearing the text, Create button will get insensitive */
-  gtk_entry_set_text (GTK_ENTRY (popover->new_list_name_entry), "");
+  gtk_editable_set_text (popover->new_list_name_entry, "");
 
   /* Hide the popover at last */
   gtk_widget_hide (GTK_WIDGET (popover));
@@ -87,7 +87,7 @@ create_task_list (GtdProviderPopover *popover)
   const gchar *name;
 
   provider = gtd_provider_selector_get_selected_provider (GTD_PROVIDER_SELECTOR 
(popover->provider_selector));
-  name = gtk_entry_get_text (GTK_ENTRY (popover->new_list_name_entry));
+  name = gtk_editable_get_text (popover->new_list_name_entry);
 
   gtd_provider_create_task_list (provider, name);
 }
@@ -154,7 +154,7 @@ gtd_provider_popover__provider_selected (GtdProviderPopover *popover,
       gtk_stack_set_visible_child_name (GTK_STACK (popover->stack), "main");
 
       if (gtk_widget_is_visible (GTK_WIDGET (popover)))
-        gtk_widget_grab_focus (popover->new_list_name_entry);
+        gtk_widget_grab_focus (GTK_WIDGET (popover->new_list_name_entry));
     }
 }
 
diff --git a/src/task-list-view/gtd-new-task-row.c b/src/task-list-view/gtd-new-task-row.c
index 0afe21e..adf4869 100644
--- a/src/task-list-view/gtd-new-task-row.c
+++ b/src/task-list-view/gtd-new-task-row.c
@@ -142,10 +142,10 @@ entry_activated_cb (GtdNewTaskRow *self)
 
   gtd_provider_create_task (gtd_task_list_get_provider (list),
                             list,
-                            gtk_entry_get_text (self->entry),
+                            gtk_editable_get_text (GTK_EDITABLE (self->entry)),
                             gtd_task_list_view_get_default_date (view));
 
-  gtk_entry_set_text (self->entry, "");
+  gtk_editable_set_text (GTK_EDITABLE (self->entry), "");
 }
 
 static void
diff --git a/src/task-list-view/gtd-task-list-popover.c b/src/task-list-view/gtd-task-list-popover.c
index 03142ad..8dd6222 100644
--- a/src/task-list-view/gtd-task-list-popover.c
+++ b/src/task-list-view/gtd-task-list-popover.c
@@ -36,7 +36,7 @@ struct _GtdTaskListPopover
 
   GtkSizeGroup       *sizegroup;
   GtkListBox         *listbox;
-  GtkEntry           *search_entry;
+  GtkEditable        *search_entry;
 
   GtdTaskList        *selected_list;
   GtdManager         *manager;
@@ -90,7 +90,7 @@ filter_listbox_cb (gpointer  item,
   self = (GtdTaskListPopover*) user_data;
   list = (GtdTaskList*) item;
 
-  normalized_search_query = gtd_normalize_casefold_and_unaccent (gtk_entry_get_text (self->search_entry));
+  normalized_search_query = gtd_normalize_casefold_and_unaccent (gtk_editable_get_text (self->search_entry));
   normalized_list_name = gtd_normalize_casefold_and_unaccent (gtd_task_list_get_name (list));
 
   return g_strrstr (normalized_list_name, normalized_search_query) != NULL;
@@ -164,18 +164,18 @@ on_listbox_row_activated_cb (GtkListBox         *listbox,
                              GtkListBoxRow      *row,
                              GtdTaskListPopover *self)
 {
-  GtdTaskList *list = g_object_get_data (G_OBJECT (row), "tasklist");
+  GtdTaskList *list = g_object_get_data (G_OBJECT (row), "tasklit");
 
   set_selected_tasklist (self, list);
   gtk_popover_popdown (GTK_POPOVER (self));
-  gtk_entry_set_text (self->search_entry, "");
+  gtk_editable_set_text (self->search_entry, "");
 }
 
 static void
 on_popover_closed_cb (GtkPopover         *popover,
                       GtdTaskListPopover *self)
 {
-  gtk_entry_set_text (self->search_entry, "");
+  gtk_editable_set_text (self->search_entry, "");
 }
 
 static void
@@ -186,7 +186,7 @@ on_search_entry_activated_cb (GtkEntry           *entry,
 
   set_selected_tasklist (self, list);
   gtk_popover_popdown (GTK_POPOVER (self));
-  gtk_entry_set_text (self->search_entry, "");
+  gtk_editable_set_text (self->search_entry, "");
 }
 
 static void
diff --git a/src/task-list-view/gtd-task-row.c b/src/task-list-view/gtd-task-row.c
index 8d795d4..e59a819 100644
--- a/src/task-list-view/gtd-task-row.c
+++ b/src/task-list-view/gtd-task-row.c
@@ -20,7 +20,6 @@
 
 #include "gtd-debug.h"
 #include "gtd-edit-pane.h"
-#include "gtd-expandable-entry.h"
 #include "gtd-manager.h"
 #include "gtd-markdown-renderer.h"
 #include "gtd-provider.h"
@@ -548,8 +547,6 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
 
   widget_class->measure = gtd_row_measure_with_max;
 
-  g_type_ensure (GTD_TYPE_EXPANDABLE_ENTRY);
-
   /**
    * GtdTaskRow::handle-subtasks:
    *
diff --git a/src/task-list-view/gtd-task-row.ui b/src/task-list-view/gtd-task-row.ui
index 9ea74ef..4cdde8f 100644
--- a/src/task-list-view/gtd-task-row.ui
+++ b/src/task-list-view/gtd-task-row.ui
@@ -89,11 +89,11 @@
 
                     <!-- Task title entry -->
                     <child>
-                      <object class="GtdExpandableEntry" id="title_entry">
+                      <object class="GtkText" id="title_entry">
                         <property name="hexpand">True</property>
                         <property name="halign">start</property>
                         <property name="width-chars">5</property>
-                        <property name="propagate-natural-width">True</property>
+                        <property name="propagate-text-width">True</property>
                         <signal name="activate" handler="on_task_changed_cb" object="GtdTaskRow" 
swapped="yes" />
                         <signal name="notify::text" handler="on_task_changed_cb" object="GtdTaskRow" 
swapped="yes" />
                         <style>
diff --git a/tests/interactive/test-filter-sort.c b/tests/interactive/test-filter-sort.c
index dcb0fb7..2221e2c 100644
--- a/tests/interactive/test-filter-sort.c
+++ b/tests/interactive/test-filter-sort.c
@@ -112,7 +112,7 @@ filter_func (GObject *item,
   task = (GtdTask*) item;
   entry = (GtkEntry*) user_data;
 
-  normalized_entry_text = gtd_normalize_casefold_and_unaccent (gtk_entry_get_text (entry));
+  normalized_entry_text = gtd_normalize_casefold_and_unaccent (gtk_editable_get_text (GTK_EDITABLE (entry)));
   normalized_task_name = gtd_normalize_casefold_and_unaccent (gtd_task_get_title (task));
 
   return strstr (normalized_task_name, normalized_entry_text) != NULL;


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