diff options
author | waker <wakeroid@gmail.com> | 2012-05-14 21:26:13 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-05-14 21:26:13 +0200 |
commit | 345e1053a2884acfdeea5f5c5721cc7716fc3c1c (patch) | |
tree | d3359bf21a80a1e7bd6bc633707a5513b5b526f5 /plugins | |
parent | bc6abccf00252836bc5d5afd786aef1598e0c0a7 (diff) |
gtkui: removed lots of weird vala-generated code from ddbcellrenderermultiline, added "editing-canceled" property to shut up glib
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/ddbcellrenderertextmultiline.c | 127 | ||||
-rw-r--r-- | plugins/gtkui/ddbcellrenderertextmultiline.h | 1 |
2 files changed, 77 insertions, 51 deletions
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.c b/plugins/gtkui/ddbcellrenderertextmultiline.c index c81f20ea..a79d3154 100644 --- a/plugins/gtkui/ddbcellrenderertextmultiline.c +++ b/plugins/gtkui/ddbcellrenderertextmultiline.c @@ -27,58 +27,22 @@ #include <string.h> #include <gdk/gdk.h> #include "support.h" +#include "ddbcellrenderertextmultiline.h" -#define DDB_TYPE_CELL_EDITABLE_TEXT_VIEW (ddb_cell_editable_text_view_get_type ()) -#define DDB_CELL_EDITABLE_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW, DdbCellEditableTextView)) -#define DDB_CELL_EDITABLE_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW, DdbCellEditableTextViewClass)) -#define DDB_IS_CELL_EDITABLE_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW)) -#define DDB_IS_CELL_EDITABLE_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW)) -#define DDB_CELL_EDITABLE_TEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW, DdbCellEditableTextViewClass)) - -typedef struct _DdbCellEditableTextView DdbCellEditableTextView; -typedef struct _DdbCellEditableTextViewClass DdbCellEditableTextViewClass; -typedef struct _DdbCellEditableTextViewPrivate DdbCellEditableTextViewPrivate; #define _g_free0(var) (var = (g_free (var), NULL)) -#define DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE (ddb_cell_renderer_text_multiline_get_type ()) -#define DDB_CELL_RENDERER_TEXT_MULTILINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE, DdbCellRendererTextMultiline)) -#define DDB_CELL_RENDERER_TEXT_MULTILINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE, DdbCellRendererTextMultilineClass)) -#define DDB_IS_CELL_RENDERER_TEXT_MULTILINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE)) -#define DDB_IS_CELL_RENDERER_TEXT_MULTILINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE)) -#define DDB_CELL_RENDERER_TEXT_MULTILINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE, DdbCellRendererTextMultilineClass)) - -typedef struct _DdbCellRendererTextMultiline DdbCellRendererTextMultiline; -typedef struct _DdbCellRendererTextMultilineClass DdbCellRendererTextMultilineClass; -typedef struct _DdbCellRendererTextMultilinePrivate DdbCellRendererTextMultilinePrivate; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL))) -struct _DdbCellEditableTextView { - GtkTextView parent_instance; - DdbCellEditableTextViewPrivate * priv; - gboolean editing_canceled; - gchar* tree_path; -}; - -struct _DdbCellEditableTextViewClass { - GtkTextViewClass parent_class; -}; - -struct _DdbCellRendererTextMultiline { - GtkCellRendererText parent_instance; - DdbCellRendererTextMultilinePrivate * priv; -}; - -struct _DdbCellRendererTextMultilineClass { - GtkCellRendererTextClass parent_class; -}; - struct _DdbCellRendererTextMultilinePrivate { DdbCellEditableTextView* entry; gulong focus_out_id; }; +struct _DdbCellEditableTextViewPrivate { + gboolean editing_canceled; +}; static gpointer ddb_cell_editable_text_view_parent_class = NULL; static GtkCellEditableIface* ddb_cell_editable_text_view_gtk_cell_editable_parent_iface = NULL; @@ -90,14 +54,12 @@ enum { }; static gboolean ddb_cell_editable_text_view_real_key_press_event (GtkWidget* base, GdkEventKey* event); static void ddb_cell_editable_text_view_real_start_editing (GtkCellEditable* base, GdkEvent* event); -#if GTK_CHECK_VERSION(2,20,0) -static void ddb_cell_editable_text_view_real_editing_canceled (GtkCellRenderer*); -#endif DdbCellEditableTextView* ddb_cell_editable_text_view_new (void); DdbCellEditableTextView* ddb_cell_editable_text_view_construct (GType object_type); static void ddb_cell_editable_text_view_finalize (GObject* obj); GType ddb_cell_renderer_text_multiline_get_type (void) G_GNUC_CONST; #define DDB_CELL_RENDERER_TEXT_MULTILINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DDB_TYPE_CELL_RENDERER_TEXT_MULTILINE, DdbCellRendererTextMultilinePrivate)) +#define DDB_CELL_EDITABLE_TEXT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DDB_TYPE_CELL_EDITABLE_TEXT_VIEW, DdbCellEditableTextViewPrivate)) enum { DDB_CELL_RENDERER_TEXT_MULTILINE_DUMMY_PROPERTY }; @@ -143,7 +105,7 @@ static gboolean ddb_cell_editable_text_view_real_key_press_event (GtkWidget* bas _tmp6_ = *event; _tmp7_ = _tmp6_.keyval; if (_tmp7_ == ((guint) GDK_Escape)) { - self->editing_canceled = TRUE; + self->priv->editing_canceled = TRUE; gtk_cell_editable_editing_done ((GtkCellEditable*) self); gtk_cell_editable_remove_widget ((GtkCellEditable*) self); result = TRUE; @@ -183,11 +145,77 @@ DdbCellEditableTextView* ddb_cell_editable_text_view_new (void) { return ddb_cell_editable_text_view_construct (DDB_TYPE_CELL_EDITABLE_TEXT_VIEW); } +enum +{ + PROP_0, + + PROP_EDITING_canceled, + + N_PROPERTIES +}; + +static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, }; + +static void +ddb_cell_editable_text_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + DdbCellEditableTextView *self = DDB_CELL_EDITABLE_TEXT_VIEW (object); + + switch (property_id) + { + case PROP_EDITING_canceled: + self->priv->editing_canceled = g_value_get_boolean (value); + break; + + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +ddb_cell_editable_text_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + DdbCellEditableTextView *self = DDB_CELL_EDITABLE_TEXT_VIEW (object); + + switch (property_id) + { + case PROP_EDITING_canceled: + g_value_set_boolean (value, self->priv->editing_canceled); + break; + + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} static void ddb_cell_editable_text_view_class_init (DdbCellEditableTextViewClass * klass) { + g_type_class_add_private (klass, sizeof (DdbCellEditableTextViewPrivate)); ddb_cell_editable_text_view_parent_class = g_type_class_peek_parent (klass); GTK_WIDGET_CLASS (klass)->key_press_event = ddb_cell_editable_text_view_real_key_press_event; G_OBJECT_CLASS (klass)->finalize = ddb_cell_editable_text_view_finalize; + + G_OBJECT_CLASS (klass)->set_property = ddb_cell_editable_text_view_set_property; + G_OBJECT_CLASS (klass)->get_property = ddb_cell_editable_text_view_get_property; + + obj_properties[PROP_EDITING_canceled] = + g_param_spec_boolean ("editing-canceled", + "Editing canceled", + "Indicates whether editing on the cell has been canceled", + FALSE, + G_PARAM_READWRITE); + + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + g_object_class_install_properties (gobject_class, N_PROPERTIES, obj_properties); } @@ -198,7 +226,8 @@ static void ddb_cell_editable_text_view_gtk_cell_editable_interface_init (GtkCel static void ddb_cell_editable_text_view_instance_init (DdbCellEditableTextView * self) { - self->editing_canceled = FALSE; + self->priv = DDB_CELL_EDITABLE_TEXT_VIEW_GET_PRIVATE (self); + self->priv->editing_canceled = FALSE; } @@ -259,7 +288,7 @@ static void ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done g_signal_handler_disconnect ((GObject*) _tmp0_, _tmp2_); _tmp3_ = _self_; _tmp4_ = entry; - _tmp5_ = _tmp4_->editing_canceled; + _tmp5_ = _tmp4_->priv->editing_canceled; gtk_cell_renderer_stop_editing ((GtkCellRenderer*) _tmp3_, _tmp5_); _tmp6_ = entry; _tmp7_ = gtk_text_view_get_buffer ((GtkTextView*) _tmp6_); @@ -287,7 +316,7 @@ static gboolean ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_eve g_return_val_if_fail (entry != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (_self_ != NULL, FALSE); - entry->editing_canceled = TRUE; + entry->priv->editing_canceled = TRUE; gtk_cell_editable_remove_widget ((GtkCellEditable*) entry); result = FALSE; return result; @@ -452,14 +481,12 @@ static void ddb_cell_renderer_text_multiline_class_init (DdbCellRendererTextMult g_type_class_add_private (klass, sizeof (DdbCellRendererTextMultilinePrivate)); GTK_CELL_RENDERER_CLASS (klass)->start_editing = ddb_cell_renderer_text_multiline_real_start_editing; G_OBJECT_CLASS (klass)->finalize = ddb_cell_renderer_text_multiline_finalize; -#if GTK_CHECK_VERSION(2,20,0) - GTK_CELL_RENDERER_CLASS (klass)->editing_canceled = (void (*)(GtkCellRenderer*)) ddb_cell_editable_text_view_real_editing_canceled; -#endif } static void ddb_cell_renderer_text_multiline_instance_init (DdbCellRendererTextMultiline * self) { self->priv = DDB_CELL_RENDERER_TEXT_MULTILINE_GET_PRIVATE (self); + printf ("alloc priv %p %p\n", self, self->priv); } diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.h b/plugins/gtkui/ddbcellrenderertextmultiline.h index b464472a..bdfec5ec 100644 --- a/plugins/gtkui/ddbcellrenderertextmultiline.h +++ b/plugins/gtkui/ddbcellrenderertextmultiline.h @@ -37,7 +37,6 @@ typedef struct _DdbCellRendererTextMultilinePrivate DdbCellRendererTextMultiline struct _DdbCellEditableTextView { GtkTextView parent_instance; DdbCellEditableTextViewPrivate * priv; - gboolean editing_canceled; gchar* tree_path; }; |