Add an LdCategory * argument to new() functions.

This commit is contained in:
Přemysl Eric Janouch 2012-09-09 15:42:52 +02:00
parent ec4f78c008
commit 15d8c257d1
5 changed files with 19 additions and 13 deletions

View File

@ -205,13 +205,18 @@ on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
/** /**
* ld_category_symbol_view_new: * ld_category_symbol_view_new:
* @category: (allow-none): a category to be assigned to the widget.
* *
* Create an instance. * Create an instance.
*/ */
GtkWidget * GtkWidget *
ld_category_symbol_view_new (void) ld_category_symbol_view_new (LdCategory *category)
{ {
return g_object_new (LD_TYPE_CATEGORY_SYMBOL_VIEW, NULL); LdCategorySymbolView *self;
self = g_object_new (LD_TYPE_CATEGORY_SYMBOL_VIEW, NULL);
ld_category_symbol_view_set_category (self, category);
return GTK_WIDGET (self);
} }
/** /**

View File

@ -50,7 +50,7 @@ struct _LdCategorySymbolViewClass
GType ld_category_symbol_view_get_type (void) G_GNUC_CONST; GType ld_category_symbol_view_get_type (void) G_GNUC_CONST;
GtkWidget *ld_category_symbol_view_new (void); GtkWidget *ld_category_symbol_view_new (LdCategory *category);
void ld_category_symbol_view_set_category void ld_category_symbol_view_set_category
(LdCategorySymbolView *self, LdCategory *category); (LdCategorySymbolView *self, LdCategory *category);

View File

@ -134,13 +134,18 @@ ld_category_view_set_property (GObject *object, guint property_id,
/** /**
* ld_category_view_new: * ld_category_view_new:
* @category: (allow-none): a category to be assigned to the widget.
* *
* Create an instance. * Create an instance.
*/ */
GtkWidget * GtkWidget *
ld_category_view_new (void) ld_category_view_new (LdCategory *category)
{ {
return g_object_new (LD_TYPE_CATEGORY_VIEW, NULL); LdCategoryView *self;
self = g_object_new (LD_TYPE_CATEGORY_VIEW, NULL);
ld_category_view_set_category (self, category);
return GTK_WIDGET (self);
} }
/** /**
@ -272,9 +277,7 @@ reload_category (LdCategoryView *self)
{ {
GtkWidget *symbol_view; GtkWidget *symbol_view;
symbol_view = ld_category_symbol_view_new (); symbol_view = ld_category_symbol_view_new (self->priv->category);
ld_category_symbol_view_set_category
(LD_CATEGORY_SYMBOL_VIEW (symbol_view), self->priv->category);
gtk_box_pack_start (GTK_BOX (self), symbol_view, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (self), symbol_view, FALSE, FALSE, 0);
} }
@ -312,9 +315,7 @@ load_category_cb (gpointer data, gpointer user_data)
gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE); gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE);
g_free (label_markup); g_free (label_markup);
child = ld_category_view_new (); child = ld_category_view_new (cat);
ld_category_view_set_category (LD_CATEGORY_VIEW (child), cat);
gtk_container_add (GTK_CONTAINER (expander), child); gtk_container_add (GTK_CONTAINER (expander), child);
gtk_box_pack_start (GTK_BOX (self), expander, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (self), expander, FALSE, FALSE, 0);
} }

View File

@ -50,7 +50,7 @@ struct _LdCategoryViewClass
GType ld_category_view_get_type (void) G_GNUC_CONST; GType ld_category_view_get_type (void) G_GNUC_CONST;
GtkWidget *ld_category_view_new (void); GtkWidget *ld_category_view_new (LdCategory *category);
void ld_category_view_set_category (LdCategoryView *self, LdCategory *category); void ld_category_view_set_category (LdCategoryView *self, LdCategory *category);
LdCategory *ld_category_view_get_category (LdCategoryView *self); LdCategory *ld_category_view_get_category (LdCategoryView *self);

View File

@ -262,7 +262,7 @@ ld_window_main_init (LdWindowMain *self)
priv->toolbar = gtk_ui_manager_get_widget (priv->ui_manager, "/Toolbar"); priv->toolbar = gtk_ui_manager_get_widget (priv->ui_manager, "/Toolbar");
/* Create the remaining widgets. */ /* Create the remaining widgets. */
priv->library_view = ld_category_view_new (); priv->library_view = ld_category_view_new (NULL);
priv->view = LD_DIAGRAM_VIEW (ld_diagram_view_new ()); priv->view = LD_DIAGRAM_VIEW (ld_diagram_view_new ());
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL); priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);