From 2ef8bd0b95dc758af59f70ec65cb54aa4101fffa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 28 May 2019 00:03:24 +0000 Subject: [PATCH] entry completion: Make final --- gtk/gtkentrycompletion.h | 36 ------------ gtk/gtkentryprivate.h | 28 ++++++++++ testsuite/gtk/cellarea.c | 115 --------------------------------------- 3 files changed, 28 insertions(+), 151 deletions(-) diff --git a/gtk/gtkentrycompletion.h b/gtk/gtkentrycompletion.h index d06449b26c..dfe561c474 100644 --- a/gtk/gtkentrycompletion.h +++ b/gtk/gtkentrycompletion.h @@ -33,14 +33,9 @@ G_BEGIN_DECLS #define GTK_TYPE_ENTRY_COMPLETION (gtk_entry_completion_get_type ()) #define GTK_ENTRY_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletion)) -#define GTK_ENTRY_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionClass)) #define GTK_IS_ENTRY_COMPLETION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY_COMPLETION)) -#define GTK_IS_ENTRY_COMPLETION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY_COMPLETION)) -#define GTK_ENTRY_COMPLETION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionClass)) typedef struct _GtkEntryCompletion GtkEntryCompletion; -typedef struct _GtkEntryCompletionClass GtkEntryCompletionClass; -typedef struct _GtkEntryCompletionPrivate GtkEntryCompletionPrivate; /** * GtkEntryCompletionMatchFunc: @@ -65,37 +60,6 @@ typedef gboolean (* GtkEntryCompletionMatchFunc) (GtkEntryCompletion *completion gpointer user_data); -struct _GtkEntryCompletion -{ - GObject parent_instance; - - /*< private >*/ - GtkEntryCompletionPrivate *priv; -}; - -struct _GtkEntryCompletionClass -{ - GObjectClass parent_class; - - gboolean (* match_selected) (GtkEntryCompletion *completion, - GtkTreeModel *model, - GtkTreeIter *iter); - void (* action_activated) (GtkEntryCompletion *completion, - gint index_); - gboolean (* insert_prefix) (GtkEntryCompletion *completion, - const gchar *prefix); - gboolean (* cursor_on_match) (GtkEntryCompletion *completion, - GtkTreeModel *model, - GtkTreeIter *iter); - void (* no_matches) (GtkEntryCompletion *completion); - - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); -}; - -/* core */ GDK_AVAILABLE_IN_ALL GType gtk_entry_completion_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL diff --git a/gtk/gtkentryprivate.h b/gtk/gtkentryprivate.h index 5d6c9d8877..14696eb5ca 100644 --- a/gtk/gtkentryprivate.h +++ b/gtk/gtkentryprivate.h @@ -30,6 +30,34 @@ G_BEGIN_DECLS +typedef struct _GtkEntryCompletionClass GtkEntryCompletionClass; +typedef struct _GtkEntryCompletionPrivate GtkEntryCompletionPrivate; + +struct _GtkEntryCompletion +{ + GObject parent_instance; + + /*< private >*/ + GtkEntryCompletionPrivate *priv; +}; + +struct _GtkEntryCompletionClass +{ + GObjectClass parent_class; + + gboolean (* match_selected) (GtkEntryCompletion *completion, + GtkTreeModel *model, + GtkTreeIter *iter); + void (* action_activated) (GtkEntryCompletion *completion, + gint index_); + gboolean (* insert_prefix) (GtkEntryCompletion *completion, + const gchar *prefix); + gboolean (* cursor_on_match) (GtkEntryCompletion *completion, + GtkTreeModel *model, + GtkTreeIter *iter); + void (* no_matches) (GtkEntryCompletion *completion); +}; + struct _GtkEntryCompletionPrivate { GtkWidget *entry; diff --git a/testsuite/gtk/cellarea.c b/testsuite/gtk/cellarea.c index 6586843eb0..a80f40caea 100644 --- a/testsuite/gtk/cellarea.c +++ b/testsuite/gtk/cellarea.c @@ -521,116 +521,6 @@ test_completion_object_new (void) g_object_unref (c); } -typedef GtkEntryCompletion MyEntryCompletion; -typedef GtkEntryCompletionClass MyEntryCompletionClass; - -GType my_entry_completion_get_type (void); - -G_DEFINE_TYPE (MyEntryCompletion, my_entry_completion, GTK_TYPE_ENTRY_COMPLETION) - -static void -my_entry_completion_class_init (MyEntryCompletionClass *klass) -{ -} - -static void -my_entry_completion_init (MyEntryCompletion *c) -{ - GtkCellArea *area; - - if (subclass_init == 0) - { - /* do nothing to area */ - } - else if (subclass_init == 1) - { - area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); - g_assert (GTK_IS_CELL_AREA_BOX (area)); - g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); - gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_VERTICAL); - } -} - -/* test that a completion subclass has an area */ -static void -test_completion_subclass0 (void) -{ - GtkEntryCompletion *c; - GtkCellArea *area; - - subclass_init = 0; - - c = g_object_new (my_entry_completion_get_type (), NULL); - area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); - g_assert (GTK_IS_CELL_AREA_BOX (area)); - g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); - - g_object_ref_sink (c); - g_object_unref (c); -} - -/* test that a completion subclass keeps the provided area */ -static void -test_completion_subclass1 (void) -{ - GtkEntryCompletion *c; - GtkCellArea *area; - - subclass_init = 0; - - area = gtk_cell_area_box_new (); - c = g_object_new (my_entry_completion_get_type (), "cell-area", area, NULL); - g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c))); - g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_HORIZONTAL); - - g_object_ref_sink (c); - g_object_unref (c); -} - -/* test we can access the area in subclass init */ -static void -test_completion_subclass2 (void) -{ - GtkEntryCompletion *c; - GtkCellArea *area; - - subclass_init = 1; - - c = g_object_new (my_entry_completion_get_type (), NULL); - area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c)); - g_assert (GTK_IS_CELL_AREA_BOX (area)); - g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); - - g_object_ref_sink (c); - g_object_unref (c); -} - -static void -test_completion_subclass3_subprocess (void) -{ - GtkEntryCompletion *c; - GtkCellArea *area; - - subclass_init = 1; - - area = gtk_cell_area_box_new (); - c = g_object_new (my_entry_completion_get_type (), "cell-area", area, NULL); - g_assert (area == gtk_cell_layout_get_area (GTK_CELL_LAYOUT (c))); - g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (area)) == GTK_ORIENTATION_VERTICAL); - - g_object_ref_sink (c); - g_object_unref (c); -} - -/* test we get a warning if an area is provided, but ignored */ -static void -test_completion_subclass3 (void) -{ - g_test_trap_subprocess ("/tests/completion-subclass3/subprocess", 0, 0); - g_test_trap_assert_failed (); - g_test_trap_assert_stderr ("*ignoring construct property*"); -} - int main (int argc, char *argv[]) { @@ -666,11 +556,6 @@ main (int argc, char *argv[]) g_test_add_func ("/tests/completion-new", test_completion_new); g_test_add_func ("/tests/completion-new-with-area", test_completion_new_with_area); g_test_add_func ("/tests/completion-object-new", test_completion_object_new); - g_test_add_func ("/tests/completion-subclass0", test_completion_subclass0); - g_test_add_func ("/tests/completion-subclass1", test_completion_subclass1); - g_test_add_func ("/tests/completion-subclass2", test_completion_subclass2); - g_test_add_func ("/tests/completion-subclass3", test_completion_subclass3); - g_test_add_func ("/tests/completion-subclass3/subprocess", test_completion_subclass3_subprocess); return g_test_run(); }