[gtk+] sidebarrow: Avoid object-valued properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] sidebarrow: Avoid object-valued properties
- Date: Tue, 23 Jun 2015 21:46:18 +0000 (UTC)
commit f2a8ddfecf0868fe381ce287205156a7db84729c
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 23 14:42:57 2015 -0400
sidebarrow: Avoid object-valued properties
They tend to leak...as these do.
gtk/gtkplacessidebar.c | 18 +++++-----
gtk/gtksidebarrow.c | 74 +++++++++++++++----------------------------
gtk/gtksidebarrowprivate.h | 3 ++
3 files changed, 38 insertions(+), 57 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index f8f87d6..a09ae1b 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -426,15 +426,15 @@ add_place (GtkPlacesSidebar *sidebar,
NULL);
g_free (tooltip_escaped);
- g_object_get (row,
- "eject-button", &eject_button,
- "event-box", &event_box,
- NULL);
- g_signal_connect_swapped (eject_button, "clicked", G_CALLBACK (eject_or_unmount_bookmark), row);
- /* Needs event box since GtkListBoxRow doesn't have a GdkWindow associated that can
- * listen events */
- g_signal_connect (event_box, "button-press-event", G_CALLBACK (on_button_press_event), row);
- g_signal_connect (event_box, "button-release-event", G_CALLBACK (on_button_release_event), row);
+ eject_button = gtk_sidebar_row_get_eject_button (GTK_SIDEBAR_ROW (row));
+ event_box = gtk_sidebar_row_get_event_box (GTK_SIDEBAR_ROW (row));
+
+ g_signal_connect_swapped (eject_button, "clicked",
+ G_CALLBACK (eject_or_unmount_bookmark), row);
+ g_signal_connect (event_box, "button-press-event",
+ G_CALLBACK (on_button_press_event), row);
+ g_signal_connect (event_box, "button-release-event",
+ G_CALLBACK (on_button_release_event), row);
gtk_container_add (GTK_CONTAINER (sidebar->list_box), GTK_WIDGET (row));
gtk_widget_show_all (row);
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index e56180c..a5ff9cc 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -70,8 +70,6 @@ enum
PROP_MOUNT,
PROP_SENSITIVE,
PROP_PLACEHOLDER,
- PROP_EJECT_BUTTON,
- PROP_EVENT_BOX,
LAST_PROP
};
@@ -171,18 +169,6 @@ gtk_sidebar_row_get_property (GObject *object,
break;
}
- case PROP_EJECT_BUTTON:
- {
- g_value_set_object (value, self->eject_button);
- break;
- }
-
- case PROP_EVENT_BOX:
- {
- g_value_set_object (value, self->event_box);
- break;
- }
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -576,26 +562,6 @@ gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
g_object_class_install_property (object_class, PROP_PLACEHOLDER,
gParamSpecs [PROP_PLACEHOLDER]);
- gParamSpecs [PROP_EJECT_BUTTON] =
- g_param_spec_object ("eject-button",
- "Eject Button",
- "Eject button",
- GTK_TYPE_WIDGET,
- (G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_EJECT_BUTTON,
- gParamSpecs [PROP_EJECT_BUTTON]);
-
- gParamSpecs [PROP_EVENT_BOX] =
- g_param_spec_object ("event-box",
- "Event Box",
- "Event Box",
- GTK_TYPE_WIDGET,
- (G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_EVENT_BOX,
- gParamSpecs [PROP_EVENT_BOX]);
-
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/libgtk/ui/gtksidebarrow.ui");
@@ -612,18 +578,30 @@ gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
GtkSidebarRow*
gtk_sidebar_row_clone (GtkSidebarRow *self)
{
- return g_object_new (GTK_TYPE_SIDEBAR_ROW,
- "sidebar", self->sidebar,
- "icon", self->icon,
- "label", self->label,
- "tooltip", self->tooltip,
- "ejectable", self->ejectable,
- "order-index", self->order_index,
- "section-type", self->section_type,
- "place-type", self->place_type,
- "uri", self->uri,
- "drive", self->drive,
- "volume", self->volume,
- "mount", self->mount,
- NULL);
+ return g_object_new (GTK_TYPE_SIDEBAR_ROW,
+ "sidebar", self->sidebar,
+ "icon", self->icon,
+ "label", self->label,
+ "tooltip", self->tooltip,
+ "ejectable", self->ejectable,
+ "order-index", self->order_index,
+ "section-type", self->section_type,
+ "place-type", self->place_type,
+ "uri", self->uri,
+ "drive", self->drive,
+ "volume", self->volume,
+ "mount", self->mount,
+ NULL);
+}
+
+GtkWidget *
+gtk_sidebar_row_get_eject_button (GtkSidebarRow *self)
+{
+ return self->eject_button;
+}
+
+GtkWidget *
+gtk_sidebar_row_get_event_box (GtkSidebarRow *self)
+{
+ return self->event_box;
}
diff --git a/gtk/gtksidebarrowprivate.h b/gtk/gtksidebarrowprivate.h
index b513184..b624d36 100644
--- a/gtk/gtksidebarrowprivate.h
+++ b/gtk/gtksidebarrowprivate.h
@@ -48,6 +48,9 @@ void gtk_sidebar_row_hide (GtkSidebarRow *self,
gboolean inmediate);
void gtk_sidebar_row_reveal (GtkSidebarRow *self);
+GtkWidget *gtk_sidebar_row_get_eject_button (GtkSidebarRow *self);
+GtkWidget *gtk_sidebar_row_get_event_box (GtkSidebarRow *self);
+
G_END_DECLS
#endif /* GTK_SIDEBAR_ROW_PRIVATE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]