From: Andrea Zagli Date: Thu, 6 Dec 2012 15:59:57 +0000 (+0100) Subject: Added namespace to all classes. X-Git-Tag: v0.0.1~3 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=754cb687dc01dbe1c55170e62ce7d81fc06c09da;p=zakautho%2Fgui Added namespace to all classes. Bugfixes on managing roles and resources in authorization. --- diff --git a/src/authorization.c b/src/authorization.c index c258e03..35393e4 100644 --- a/src/authorization.c +++ b/src/authorization.c @@ -24,41 +24,41 @@ #include "roles.h" #include "resources.h" -static void authorization_class_init (AuthorizationClass *klass); -static void authorization_init (Authorization *authorization); +static void autoz_gui_authorization_class_init (AutozGuiAuthorizationClass *klass); +static void autoz_gui_authorization_init (AutozGuiAuthorization *authorization); -static void authorization_load (Authorization *authorization); -static void authorization_save (Authorization *authorization); +static void autoz_gui_authorization_load (AutozGuiAuthorization *authorization); +static void autoz_gui_authorization_save (AutozGuiAuthorization *authorization); -static void authorization_fill_role (Authorization *authorization); -static void authorization_fill_resource (Authorization *authorization); +static void autoz_gui_authorization_fill_role (AutozGuiAuthorization *authorization); +static void autoz_gui_authorization_fill_resource (AutozGuiAuthorization *authorization); -static void authorization_on_role_selected (gpointer instance, guint id, gpointer user_data); -static void authorization_on_resource_selected (gpointer instance, guint id, gpointer user_data); +static void autoz_gui_authorization_on_role_selected (gpointer instance, guint id, gpointer user_data); +static void autoz_gui_authorization_on_resource_selected (gpointer instance, guint id, gpointer user_data); -static void authorization_set_property (GObject *object, +static void autoz_gui_authorization_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void authorization_get_property (GObject *object, +static void autoz_gui_authorization_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void authorization_on_btn_role_clicked (GtkButton *button, +static void autoz_gui_authorization_on_btn_role_clicked (GtkButton *button, gpointer user_data); -static void authorization_on_btn_resource_clicked (GtkButton *button, +static void autoz_gui_authorization_on_btn_resource_clicked (GtkButton *button, gpointer user_data); -static void authorization_on_btn_cancel_clicked (GtkButton *button, +static void autoz_gui_authorization_on_btn_cancel_clicked (GtkButton *button, gpointer user_data); -static void authorization_on_btn_save_clicked (GtkButton *button, +static void autoz_gui_authorization_on_btn_save_clicked (GtkButton *button, gpointer user_data); -#define AUTHORIZATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTHORIZATION, AuthorizationPrivate)) +#define AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_AUTHORIZATION, AutozGuiAuthorizationPrivate)) -typedef struct _AuthorizationPrivate AuthorizationPrivate; -struct _AuthorizationPrivate +typedef struct _AutozGuiAuthorizationPrivate AutozGuiAuthorizationPrivate; +struct _AutozGuiAuthorizationPrivate { AutozGuiCommons *commons; @@ -67,20 +67,20 @@ struct _AuthorizationPrivate gint id; }; -G_DEFINE_TYPE (Authorization, authorization, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiAuthorization, autoz_gui_authorization, G_TYPE_OBJECT) static void -authorization_class_init (AuthorizationClass *klass) +autoz_gui_authorization_class_init (AutozGuiAuthorizationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (AuthorizationPrivate)); + g_type_class_add_private (object_class, sizeof (AutozGuiAuthorizationPrivate)); - object_class->set_property = authorization_set_property; - object_class->get_property = authorization_get_property; + object_class->set_property = autoz_gui_authorization_set_property; + object_class->get_property = autoz_gui_authorization_get_property; /** - * Authorization::updated: + * AutozGuiAuthorization::updated: * @authorization: * */ @@ -96,26 +96,26 @@ authorization_class_init (AuthorizationClass *klass) } static void -authorization_init (Authorization *authorization) +autoz_gui_authorization_init (AutozGuiAuthorization *authorization) { - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); } /** - * authorization_new: + * autoz_gui_authorization_new: * @commons: * @id: * - * Returns: the newly created #Authorization object. + * Returns: the newly created #AutozGuiAuthorization object. */ -Authorization -*authorization_new (AutozGuiCommons *commons, gint id) +AutozGuiAuthorization +*autoz_gui_authorization_new (AutozGuiCommons *commons, gint id) { GError *error; - Authorization *a = AUTHORIZATION (g_object_new (authorization_get_type (), NULL)); + AutozGuiAuthorization *a = AUTOZ_GUI_AUTHORIZATION (g_object_new (autoz_gui_authorization_get_type (), NULL)); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (a); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (a); priv->commons = commons; @@ -132,14 +132,14 @@ Authorization priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_authorization")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button23"), - "clicked", G_CALLBACK (authorization_on_btn_role_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_authorization_on_btn_role_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button22"), - "clicked", G_CALLBACK (authorization_on_btn_resource_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_authorization_on_btn_resource_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button20"), - "clicked", G_CALLBACK (authorization_on_btn_cancel_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_authorization_on_btn_cancel_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button21"), - "clicked", G_CALLBACK (authorization_on_btn_save_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_authorization_on_btn_save_clicked), (gpointer)a); priv->id = id; if (priv->id == 0) @@ -150,30 +150,30 @@ Authorization { gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label12")), g_strdup_printf ("%d", priv->id)); - authorization_load (a); + autoz_gui_authorization_load (a); } return a; } /** - * authorization_get_widget: + * autoz_gui_authorization_get_widget: * @authorization: * */ GtkWidget -*authorization_get_widget (Authorization *authorization) +*autoz_gui_authorization_get_widget (AutozGuiAuthorization *authorization) { - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); return priv->w; } /* PRIVATE */ static void -authorization_load (Authorization *authorization) +autoz_gui_authorization_load (AutozGuiAuthorization *authorization) { - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); GError *error; gchar *sql; @@ -205,8 +205,8 @@ authorization_load (Authorization *authorization) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "radiobutton2")), TRUE); } - authorization_fill_role (authorization); - authorization_fill_resource (authorization); + autoz_gui_authorization_fill_role (authorization); + autoz_gui_authorization_fill_resource (authorization); } else { @@ -223,7 +223,7 @@ authorization_load (Authorization *authorization) } static void -authorization_save (Authorization *authorization) +autoz_gui_authorization_save (AutozGuiAuthorization *authorization) { const GdaDsnInfo *info; GError *error; @@ -234,9 +234,9 @@ authorization_save (Authorization *authorization) guint type; - AuthorizationClass *klass = AUTHORIZATION_GET_CLASS (authorization); + AutozGuiAuthorizationClass *klass = AUTOZ_GUI_AUTHORIZATION_GET_CLASS (authorization); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "radiobutton1")))) { @@ -295,7 +295,7 @@ authorization_save (Authorization *authorization) " SET" " id_roles = %d," " id_resources = %d," - " type = %d," + " type = %d" " WHERE id = %d", priv->commons->prefix, strtol (gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label15"))), NULL, 10), @@ -345,14 +345,14 @@ authorization_save (Authorization *authorization) } static void -authorization_fill_role (Authorization *authorization) +autoz_gui_authorization_fill_role (AutozGuiAuthorization *authorization) { GError *error; gchar *sql; GdaStatement *stmt; GdaDataModel *dm; - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); sql = g_strdup_printf ("SELECT role_id" " FROM %sroles" @@ -377,14 +377,14 @@ authorization_fill_role (Authorization *authorization) } static void -authorization_fill_resource (Authorization *authorization) +autoz_gui_authorization_fill_resource (AutozGuiAuthorization *authorization) { GError *error; gchar *sql; GdaStatement *stmt; GdaDataModel *dm; - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); sql = g_strdup_printf ("SELECT resource_id" " FROM %sresources" @@ -409,30 +409,34 @@ authorization_fill_resource (Authorization *authorization) } static void -authorization_on_role_selected (gpointer instance, guint id, gpointer user_data) +autoz_gui_authorization_on_role_selected (gpointer instance, guint id, gpointer user_data) { - Authorization *authorization = AUTHORIZATION (instance); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = AUTOZ_GUI_AUTHORIZATION (user_data); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label15")), g_strdup_printf ("%d", id)); + + autoz_gui_authorization_fill_role (authorization); } static void -authorization_on_resource_selected (gpointer instance, guint id, gpointer user_data) +autoz_gui_authorization_on_resource_selected (gpointer instance, guint id, gpointer user_data) { - Authorization *authorization = AUTHORIZATION (instance); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = AUTOZ_GUI_AUTHORIZATION (user_data); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label14")), g_strdup_printf ("%d", id)); + + autoz_gui_authorization_fill_resource (authorization); } static void -authorization_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_authorization_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Authorization *authorization = AUTHORIZATION (object); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = AUTOZ_GUI_AUTHORIZATION (object); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); switch (property_id) { @@ -443,10 +447,10 @@ authorization_set_property (GObject *object, guint property_id, const GValue *va } static void -authorization_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_authorization_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Authorization *authorization = AUTHORIZATION (object); - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = AUTOZ_GUI_AUTHORIZATION (object); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); switch (property_id) { @@ -458,57 +462,57 @@ authorization_get_property (GObject *object, guint property_id, GValue *value, G /* CALLBACK */ static void -authorization_on_btn_role_clicked (GtkButton *button, +autoz_gui_authorization_on_btn_role_clicked (GtkButton *button, gpointer user_data) { GtkWidget *w; - Authorization *authorization = (Authorization *)user_data; - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = (AutozGuiAuthorization *)user_data; + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); - Roles *c = roles_new (priv->commons, TRUE); + AutozGuiRoles *c = autoz_gui_roles_new (priv->commons, TRUE); - g_signal_connect (G_OBJECT (c), "selezionato", - G_CALLBACK (authorization_on_role_selected), user_data); + g_signal_connect (G_OBJECT (c), "selected", + G_CALLBACK (autoz_gui_authorization_on_role_selected), user_data); - w = roles_get_widget (c); + w = autoz_gui_roles_get_widget (c); gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w)); gtk_widget_show (w); } static void -authorization_on_btn_resource_clicked (GtkButton *button, +autoz_gui_authorization_on_btn_resource_clicked (GtkButton *button, gpointer user_data) { GtkWidget *w; - Authorization *authorization = (Authorization *)user_data; - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorization *authorization = (AutozGuiAuthorization *)user_data; + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); - Resources *c = resources_new (priv->commons, TRUE); + AutozGuiResources *c = autoz_gui_resources_new (priv->commons, TRUE); - g_signal_connect (G_OBJECT (c), "selezionato", - G_CALLBACK (authorization_on_resource_selected), user_data); + g_signal_connect (G_OBJECT (c), "selected", + G_CALLBACK (autoz_gui_authorization_on_resource_selected), user_data); - w = resources_get_widget (c); + w = autoz_gui_resources_get_widget (c); gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w)); gtk_widget_show (w); } static void -authorization_on_btn_cancel_clicked (GtkButton *button, +autoz_gui_authorization_on_btn_cancel_clicked (GtkButton *button, gpointer user_data) { - Authorization *authorization = (Authorization *)user_data; + AutozGuiAuthorization *authorization = (AutozGuiAuthorization *)user_data; - AuthorizationPrivate *priv = AUTHORIZATION_GET_PRIVATE (authorization); + AutozGuiAuthorizationPrivate *priv = AUTOZ_GUI_AUTHORIZATION_GET_PRIVATE (authorization); gtk_widget_destroy (priv->w); } static void -authorization_on_btn_save_clicked (GtkButton *button, +autoz_gui_authorization_on_btn_save_clicked (GtkButton *button, gpointer user_data) { - authorization_save ((Authorization *)user_data); + autoz_gui_authorization_save ((AutozGuiAuthorization *)user_data); } diff --git a/src/authorization.h b/src/authorization.h index 164505d..23578dc 100644 --- a/src/authorization.h +++ b/src/authorization.h @@ -17,8 +17,8 @@ * */ -#ifndef __AUTHORIZATION_H__ -#define __AUTHORIZATION_H__ +#ifndef __AUTOZ_GUI_AUTHORIZATION_H__ +#define __AUTOZ_GUI_AUTHORIZATION_H__ #include #include @@ -30,36 +30,36 @@ G_BEGIN_DECLS -#define TYPE_AUTHORIZATION (authorization_get_type ()) -#define AUTHORIZATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTHORIZATION, Authorization)) -#define AUTHORIZATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTHORIZATION, AuthorizationClass)) -#define IS_AUTHORIZATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTHORIZATION)) -#define IS_AUTHORIZATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTHORIZATION)) -#define AUTHORIZATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTHORIZATION, AuthorizationClass)) +#define TYPE_AUTOZ_GUI_AUTHORIZATION (autoz_gui_authorization_get_type ()) +#define AUTOZ_GUI_AUTHORIZATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_AUTHORIZATION, AutozGuiAuthorization)) +#define AUTOZ_GUI_AUTHORIZATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_AUTHORIZATION, AutozGuiAuthorizationClass)) +#define IS_AUTOZ_GUI_AUTHORIZATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_AUTHORIZATION)) +#define IS_AUTOZ_GUI_AUTHORIZATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_AUTHORIZATION)) +#define AUTOZ_GUI_AUTHORIZATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_AUTHORIZATION, AutozGuiAuthorizationClass)) -typedef struct _Authorization Authorization; -typedef struct _AuthorizationClass AuthorizationClass; +typedef struct _AutozGuiAuthorization AutozGuiAuthorization; +typedef struct _AutozGuiAuthorizationClass AutozGuiAuthorizationClass; -struct _Authorization +struct _AutozGuiAuthorization { GObject parent; }; -struct _AuthorizationClass +struct _AutozGuiAuthorizationClass { GObjectClass parent_class; guint updated_signal_id; }; -GType authorization_get_type (void) G_GNUC_CONST; +GType autoz_gui_authorization_get_type (void) G_GNUC_CONST; -Authorization *authorization_new (AutozGuiCommons *commons, gint id); +AutozGuiAuthorization *autoz_gui_authorization_new (AutozGuiCommons *commons, gint id); -GtkWidget *authorization_get_widget (Authorization *authorization); +GtkWidget *autoz_gui_authorization_get_widget (AutozGuiAuthorization *authorization); G_END_DECLS -#endif /* __AUTHORIZATION_H__ */ +#endif /* __AUTOZ_GUI_AUTHORIZATION_H__ */ diff --git a/src/authorizations.c b/src/authorizations.c index bc3b957..8e9226f 100644 --- a/src/authorizations.c +++ b/src/authorizations.c @@ -24,35 +24,35 @@ #include "authorizations.h" #include "authorization.h" -static void authorizations_class_init (AuthorizationsClass *klass); -static void authorizations_init (Authorizations *authorizations); +static void autoz_gui_authorizations_class_init (AutozGuiAuthorizationsClass *klass); +static void autoz_gui_authorizations_init (AutozGuiAuthorizations *authorizations); -static void authorizations_load (Authorizations *authorizations); -static void authorizations_edit (Authorizations *authorizations); +static void autoz_gui_authorizations_load (AutozGuiAuthorizations *authorizations); +static void autoz_gui_authorizations_edit (AutozGuiAuthorizations *authorizations); -static void authorizations_on_authorization_updated (gpointer instance, gpointer user_data); +static void autoz_gui_authorizations_on_authorization_updated (gpointer instance, gpointer user_data); -static void authorizations_set_property (GObject *object, +static void autoz_gui_authorizations_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void authorizations_get_property (GObject *object, +static void autoz_gui_authorizations_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void authorizations_on_btn_new_clicked (GtkButton *button, +static void autoz_gui_authorizations_on_btn_new_clicked (GtkButton *button, gpointer user_data); -static void authorizations_on_btn_edit_clicked (GtkButton *button, +static void autoz_gui_authorizations_on_btn_edit_clicked (GtkButton *button, gpointer user_data); -static void authorizations_on_btn_delete_clicked (GtkButton *button, +static void autoz_gui_authorizations_on_btn_delete_clicked (GtkButton *button, gpointer user_data); -static void authorizations_on_trv_authorizations_row_activated (GtkTreeView *tree_view, +static void autoz_gui_authorizations_on_trv_autoz_gui_authorizations_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data); -#define AUTHORIZATIONS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTHORIZATIONS, AuthorizationsPrivate)) +#define AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_AUTHORIZATIONS, AutozGuiAuthorizationsPrivate)) enum { @@ -62,8 +62,8 @@ enum COL_TYPE }; -typedef struct _AuthorizationsPrivate AuthorizationsPrivate; -struct _AuthorizationsPrivate +typedef struct _AutozGuiAuthorizationsPrivate AutozGuiAuthorizationsPrivate; +struct _AutozGuiAuthorizationsPrivate { AutozGuiCommons *commons; @@ -73,40 +73,40 @@ struct _AuthorizationsPrivate GtkListStore *lstore_authorizations; }; -G_DEFINE_TYPE (Authorizations, authorizations, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiAuthorizations, autoz_gui_authorizations, G_TYPE_OBJECT) static void -authorizations_class_init (AuthorizationsClass *klass) +autoz_gui_authorizations_class_init (AutozGuiAuthorizationsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (AuthorizationsPrivate)); + g_type_class_add_private (object_class, sizeof (AutozGuiAuthorizationsPrivate)); - object_class->set_property = authorizations_set_property; - object_class->get_property = authorizations_get_property; + object_class->set_property = autoz_gui_authorizations_set_property; + object_class->get_property = autoz_gui_authorizations_get_property; } static void -authorizations_init (Authorizations *authorizations) +autoz_gui_authorizations_init (AutozGuiAuthorizations *authorizations) { - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); } /** - * authorizations_new: + * autoz_gui_authorizations_new: * @commons: * @selection: * - * Returns: the newly created #Authorizations object. + * Returns: the newly created #AutozGuiAuthorizations object. */ -Authorizations -*authorizations_new (AutozGuiCommons *commons, gboolean selection) +AutozGuiAuthorizations +*autoz_gui_authorizations_new (AutozGuiCommons *commons, gboolean selection) { GError *error; - Authorizations *a = AUTHORIZATIONS (g_object_new (authorizations_get_type (), NULL)); + AutozGuiAuthorizations *a = AUTOZ_GUI_AUTHORIZATIONS (g_object_new (autoz_gui_authorizations_get_type (), NULL)); - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (a); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (a); priv->commons = commons; @@ -128,13 +128,13 @@ Authorizations priv->lstore_authorizations = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_authorizations")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button17"), - "clicked", G_CALLBACK (authorizations_on_btn_new_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_authorizations_on_btn_new_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button18"), - "clicked", G_CALLBACK (authorizations_on_btn_edit_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_authorizations_on_btn_edit_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button19"), - "clicked", G_CALLBACK (authorizations_on_btn_delete_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_authorizations_on_btn_delete_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview3"), - "row-activated", G_CALLBACK (authorizations_on_trv_authorizations_row_activated), (gpointer)a); + "row-activated", G_CALLBACK (autoz_gui_authorizations_on_trv_autoz_gui_authorizations_row_activated), (gpointer)a); if (!selection) { @@ -142,31 +142,31 @@ Authorizations gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button13")));*/ } - authorizations_load (a); + autoz_gui_authorizations_load (a); return a; } /** - * authorizations_get_widget: + * autoz_gui_authorizations_get_widget: * @authorizations: * */ GtkWidget -*authorizations_get_widget (Authorizations *authorizations) +*autoz_gui_authorizations_get_widget (AutozGuiAuthorizations *authorizations) { - AuthorizationsPrivate *priv; + AutozGuiAuthorizationsPrivate *priv; - g_return_val_if_fail (IS_AUTHORIZATIONS (authorizations), NULL); + g_return_val_if_fail (IS_AUTOZ_GUI_AUTHORIZATIONS (authorizations), NULL); - priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); return priv->widget; } /* PRIVATE */ static void -authorizations_load (Authorizations *authorizations) +autoz_gui_authorizations_load (AutozGuiAuthorizations *authorizations) { GtkTreeIter iter; @@ -179,7 +179,7 @@ authorizations_load (Authorizations *authorizations) gint rows; gint row; - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); gtk_list_store_clear (priv->lstore_authorizations); @@ -221,12 +221,12 @@ authorizations_load (Authorizations *authorizations) } static void -authorizations_edit (Authorizations *authorizations) +autoz_gui_authorizations_edit (AutozGuiAuthorizations *authorizations) { GtkTreeIter iter; guint id; - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) { @@ -236,12 +236,12 @@ authorizations_edit (Authorizations *authorizations) COL_ID, &id, -1); - Authorization *c = authorization_new (priv->commons, id); + AutozGuiAuthorization *c = autoz_gui_authorization_new (priv->commons, id); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (authorizations_on_authorization_updated), (gpointer)authorizations); + G_CALLBACK (autoz_gui_authorizations_on_authorization_updated), (gpointer)authorizations); - w = authorization_get_widget (c); + w = autoz_gui_authorization_get_widget (c); gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } @@ -258,16 +258,16 @@ authorizations_edit (Authorizations *authorizations) } static void -authorizations_on_authorization_updated (gpointer instance, gpointer user_data) +autoz_gui_authorizations_on_authorization_updated (gpointer instance, gpointer user_data) { - authorizations_load ((Authorizations *)user_data); + autoz_gui_authorizations_load ((AutozGuiAuthorizations *)user_data); } static void -authorizations_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_authorizations_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Authorizations *authorizations = AUTHORIZATIONS (object); - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizations *authorizations = AUTOZ_GUI_AUTHORIZATIONS (object); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); switch (property_id) { @@ -278,10 +278,10 @@ authorizations_set_property (GObject *object, guint property_id, const GValue *v } static void -authorizations_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_authorizations_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Authorizations *authorizations = AUTHORIZATIONS (object); - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizations *authorizations = AUTOZ_GUI_AUTHORIZATIONS (object); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); switch (property_id) { @@ -293,33 +293,33 @@ authorizations_get_property (GObject *object, guint property_id, GValue *value, /* CALLBACK */ static void -authorizations_on_btn_new_clicked (GtkButton *button, +autoz_gui_authorizations_on_btn_new_clicked (GtkButton *button, gpointer user_data) { GtkWidget *w; - Authorizations *authorizations = (Authorizations *)user_data; - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizations *authorizations = (AutozGuiAuthorizations *)user_data; + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); - Authorization *c = authorization_new (priv->commons, 0); + AutozGuiAuthorization *c = autoz_gui_authorization_new (priv->commons, 0); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (authorizations_on_authorization_updated), (gpointer)authorizations); + G_CALLBACK (autoz_gui_authorizations_on_authorization_updated), (gpointer)authorizations); - w = authorization_get_widget (c); + w = autoz_gui_authorization_get_widget (c); gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } static void -authorizations_on_btn_edit_clicked (GtkButton *button, +autoz_gui_authorizations_on_btn_edit_clicked (GtkButton *button, gpointer user_data) { - authorizations_edit ((Authorizations *)user_data); + autoz_gui_authorizations_edit ((AutozGuiAuthorizations *)user_data); } static void -authorizations_on_btn_delete_clicked (GtkButton *button, +autoz_gui_authorizations_on_btn_delete_clicked (GtkButton *button, gpointer user_data) { GtkWidget *dialog; @@ -328,8 +328,8 @@ authorizations_on_btn_delete_clicked (GtkButton *button, GtkTreeIter iter; guint id; - Authorizations *authorizations = (Authorizations *)user_data; - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE (authorizations); + AutozGuiAuthorizations *authorizations = (AutozGuiAuthorizations *)user_data; + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE (authorizations); if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) { @@ -380,7 +380,7 @@ authorizations_on_btn_delete_clicked (GtkButton *button, gtk_widget_destroy (dialog); } - authorizations_load (authorizations); + autoz_gui_authorizations_load (authorizations); } } else @@ -396,12 +396,12 @@ authorizations_on_btn_delete_clicked (GtkButton *button, } static void -authorizations_on_trv_authorizations_row_activated (GtkTreeView *tree_view, +autoz_gui_authorizations_on_trv_autoz_gui_authorizations_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data) { - AuthorizationsPrivate *priv = AUTHORIZATIONS_GET_PRIVATE ((Authorizations *)user_data); + AutozGuiAuthorizationsPrivate *priv = AUTOZ_GUI_AUTHORIZATIONS_GET_PRIVATE ((AutozGuiAuthorizations *)user_data); - authorizations_edit ((Authorizations *)user_data); + autoz_gui_authorizations_edit ((AutozGuiAuthorizations *)user_data); } diff --git a/src/authorizations.h b/src/authorizations.h index 2a962e6..92f0f91 100644 --- a/src/authorizations.h +++ b/src/authorizations.h @@ -17,8 +17,8 @@ * */ -#ifndef __AUTHORIZATIONS_H__ -#define __AUTHORIZATIONS_H__ +#ifndef __AUTOZ_GUI_AUTHORIZATIONS_H__ +#define __AUTOZ_GUI_AUTHORIZATIONS_H__ #include #include @@ -30,34 +30,34 @@ G_BEGIN_DECLS -#define TYPE_AUTHORIZATIONS (authorizations_get_type ()) -#define AUTHORIZATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTHORIZATIONS, Authorizations)) -#define AUTHORIZATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTHORIZATIONS, AuthorizationsClass)) -#define IS_AUTHORIZATIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTHORIZATIONS)) -#define IS_AUTHORIZATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTHORIZATIONS)) -#define AUTHORIZATIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTHORIZATIONS, AuthorizationsClass)) +#define TYPE_AUTOZ_GUI_AUTHORIZATIONS (autoz_gui_authorizations_get_type ()) +#define AUTOZ_GUI_AUTHORIZATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_AUTHORIZATIONS, AutozGuiAuthorizations)) +#define AUTOZ_GUI_AUTHORIZATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_AUTHORIZATIONS, AutozGuiAuthorizationsClass)) +#define IS_AUTOZ_GUI_AUTHORIZATIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_AUTHORIZATIONS)) +#define IS_AUTOZ_GUI_AUTHORIZATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_AUTHORIZATIONS)) +#define AUTOZ_GUI_AUTHORIZATIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_AUTHORIZATIONS, AutozGuiAuthorizationsClass)) -typedef struct _Authorizations Authorizations; -typedef struct _AuthorizationsClass AuthorizationsClass; +typedef struct _AutozGuiAuthorizations AutozGuiAuthorizations; +typedef struct _AutozGuiAuthorizationsClass AutozGuiAuthorizationsClass; -struct _Authorizations +struct _AutozGuiAuthorizations { GObject parent; }; -struct _AuthorizationsClass +struct _AutozGuiAuthorizationsClass { GObjectClass parent_class; }; -GType authorizations_get_type (void) G_GNUC_CONST; +GType autoz_gui_authorizations_get_type (void) G_GNUC_CONST; -Authorizations *authorizations_new (AutozGuiCommons *commons, gboolean selection); +AutozGuiAuthorizations *autoz_gui_authorizations_new (AutozGuiCommons *commons, gboolean selection); -GtkWidget *authorizations_get_widget (Authorizations *authorizations); +GtkWidget *autoz_gui_authorizations_get_widget (AutozGuiAuthorizations *authorizations); G_END_DECLS -#endif /* __AUTHORIZATIONS_H__ */ +#endif /* __AUTOZ_GUI_AUTHORIZATIONS_H__ */ diff --git a/src/main.c b/src/main.c index 10870ad..80b4b0d 100644 --- a/src/main.c +++ b/src/main.c @@ -129,9 +129,9 @@ on_mnu_file_open_audit_ds_activate (GtkMenuItem *menuitem, on_mnu_file_close_activate (NULL, user_data); } - OpenAuditDS *m = open_audit_ds_new (commons); + AutozGuiOpenAuditDS *m = autoz_gui_open_audit_ds_new (commons); - vbx = open_audit_ds_get_widget (m); + vbx = autoz_gui_open_audit_ds_get_widget (m); g_signal_connect (G_OBJECT (m), "opened", G_CALLBACK (main_on_ds_opened), NULL); @@ -157,9 +157,9 @@ on_mnu_view_roles_activate (GtkMenuItem *menuitem, { GtkWidget *vbx; - Roles *m = roles_new (commons, FALSE); + AutozGuiRoles *m = autoz_gui_roles_new (commons, FALSE); - vbx = roles_get_widget (m); + vbx = autoz_gui_roles_get_widget (m); main_set_vbx_body_child (vbx); } @@ -170,9 +170,9 @@ on_mnu_view_resources_activate (GtkMenuItem *menuitem, { GtkWidget *vbx; - Resources *m = resources_new (commons, FALSE); + AutozGuiResources *m = autoz_gui_resources_new (commons, FALSE); - vbx = resources_get_widget (m); + vbx = autoz_gui_resources_get_widget (m); main_set_vbx_body_child (vbx); } @@ -183,9 +183,9 @@ on_mnu_view_authorizations_activate (GtkMenuItem *menuitem, { GtkWidget *vbx; - Authorizations *m = authorizations_new (commons, FALSE); + AutozGuiAuthorizations *m = autoz_gui_authorizations_new (commons, FALSE); - vbx = authorizations_get_widget (m); + vbx = autoz_gui_authorizations_get_widget (m); main_set_vbx_body_child (vbx); } diff --git a/src/openauditds.c b/src/openauditds.c index 750ba37..a64df1b 100644 --- a/src/openauditds.c +++ b/src/openauditds.c @@ -21,31 +21,31 @@ #include "openauditds.h" -static void open_audit_ds_class_init (OpenAuditDSClass *klass); -static void open_audit_ds_init (OpenAuditDS *open_audit_ds); +static void autoz_gui_open_audit_ds_class_init (AutozGuiOpenAuditDSClass *klass); +static void autoz_gui_open_audit_ds_init (AutozGuiOpenAuditDS *open_audit_ds); -static void open_audit_ds_set_property (GObject *object, +static void autoz_gui_open_audit_ds_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void open_audit_ds_get_property (GObject *object, +static void autoz_gui_open_audit_ds_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, +static void autoz_gui_open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, gboolean arg1, gpointer user_data); -static void open_audit_ds_on_btn_cancel_clicked (GtkButton *button, +static void autoz_gui_open_audit_ds_on_btn_cancel_clicked (GtkButton *button, gpointer user_data); -static void open_audit_ds_on_btn_open_clicked (GtkButton *button, +static void autoz_gui_open_audit_ds_on_btn_open_clicked (GtkButton *button, gpointer user_data); -#define OPEN_AUDIT_DS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDSPrivate)) +#define AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS, AutozGuiOpenAuditDSPrivate)) -typedef struct _OpenAuditDSPrivate OpenAuditDSPrivate; -struct _OpenAuditDSPrivate +typedef struct _AutozGuiOpenAuditDSPrivate AutozGuiOpenAuditDSPrivate; +struct _AutozGuiOpenAuditDSPrivate { AutozGuiCommons *commons; @@ -53,20 +53,20 @@ struct _OpenAuditDSPrivate GtkWidget *wlogin; }; -G_DEFINE_TYPE (OpenAuditDS, open_audit_ds, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiOpenAuditDS, autoz_gui_open_audit_ds, G_TYPE_OBJECT) static void -open_audit_ds_class_init (OpenAuditDSClass *klass) +autoz_gui_open_audit_ds_class_init (AutozGuiOpenAuditDSClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (OpenAuditDSPrivate)); + g_type_class_add_private (object_class, sizeof (AutozGuiOpenAuditDSPrivate)); - object_class->set_property = open_audit_ds_set_property; - object_class->get_property = open_audit_ds_get_property; + object_class->set_property = autoz_gui_open_audit_ds_set_property; + object_class->get_property = autoz_gui_open_audit_ds_get_property; /** - * OpenAuditDS::opened: + * AutozGuiOpenAuditDS::opened: * @open_audit_ds: * */ @@ -82,28 +82,28 @@ open_audit_ds_class_init (OpenAuditDSClass *klass) } static void -open_audit_ds_init (OpenAuditDS *open_audit_ds) +autoz_gui_open_audit_ds_init (AutozGuiOpenAuditDS *open_audit_ds) { - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); } /** - * open_audit_ds_new: + * autoz_gui_open_audit_ds_new: * @commons: * @id: * - * Returns: the newly created #OpenAuditDS object. + * Returns: the newly created #AutozGuiOpenAuditDS object. */ -OpenAuditDS -*open_audit_ds_new (AutozGuiCommons *commons) +AutozGuiOpenAuditDS +*autoz_gui_open_audit_ds_new (AutozGuiCommons *commons) { GError *error; GdauiLoginMode mode; - OpenAuditDS *a = OPEN_AUDIT_DS (g_object_new (open_audit_ds_get_type (), NULL)); + AutozGuiOpenAuditDS *a = AUTOZ_GUI_OPEN_AUDIT_DS (g_object_new (autoz_gui_open_audit_ds_get_type (), NULL)); - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (a); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (a); priv->commons = commons; @@ -120,9 +120,9 @@ OpenAuditDS priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_open_autoz_datasource")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button1"), - "clicked", G_CALLBACK (open_audit_ds_on_btn_cancel_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_open_audit_ds_on_btn_cancel_clicked), (gpointer *)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button2"), - "clicked", G_CALLBACK (open_audit_ds_on_btn_open_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_open_audit_ds_on_btn_open_clicked), (gpointer *)a); /* creating login widget */ priv->wlogin = gdaui_login_new (NULL); @@ -132,7 +132,7 @@ OpenAuditDS gdaui_login_set_mode (GDAUI_LOGIN (priv->wlogin), mode); g_signal_connect (G_OBJECT (priv->wlogin), "changed", - G_CALLBACK (open_audit_ds_on_wlogin_changed), (gpointer *)a); + G_CALLBACK (autoz_gui_open_audit_ds_on_wlogin_changed), (gpointer *)a); gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->commons->gtkbuilder, "frame1")), priv->wlogin); @@ -143,24 +143,24 @@ OpenAuditDS } /** - * open_audit_ds_get_widget: + * autoz_gui_open_audit_ds_get_widget: * @open_audit_ds: * */ GtkWidget -*open_audit_ds_get_widget (OpenAuditDS *open_audit_ds) +*autoz_gui_open_audit_ds_get_widget (AutozGuiOpenAuditDS *open_audit_ds) { - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); return priv->w; } /* PRIVATE */ static void -open_audit_ds_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_open_audit_ds_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - OpenAuditDS *open_audit_ds = OPEN_AUDIT_DS (object); - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDS *open_audit_ds = AUTOZ_GUI_OPEN_AUDIT_DS (object); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); switch (property_id) { @@ -171,10 +171,10 @@ open_audit_ds_set_property (GObject *object, guint property_id, const GValue *va } static void -open_audit_ds_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_open_audit_ds_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OpenAuditDS *open_audit_ds = OPEN_AUDIT_DS (object); - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDS *open_audit_ds = AUTOZ_GUI_OPEN_AUDIT_DS (object); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); switch (property_id) { @@ -186,13 +186,13 @@ open_audit_ds_get_property (GObject *object, guint property_id, GValue *value, G /* CALLBACK */ static void -open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, +autoz_gui_open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, gboolean arg1, gpointer user_data) { - OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; + AutozGuiOpenAuditDS *open_audit_ds = (AutozGuiOpenAuditDS *)user_data; - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); gboolean is_valid; @@ -202,22 +202,22 @@ open_audit_ds_on_wlogin_changed (GdauiLogin *gdauilogin, } static void -open_audit_ds_on_btn_cancel_clicked (GtkButton *button, +autoz_gui_open_audit_ds_on_btn_cancel_clicked (GtkButton *button, gpointer user_data) { - OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDS *open_audit_ds = (AutozGuiOpenAuditDS *)user_data; + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); gtk_widget_destroy (priv->w); } static void -open_audit_ds_on_btn_open_clicked (GtkButton *button, +autoz_gui_open_audit_ds_on_btn_open_clicked (GtkButton *button, gpointer user_data) { - OpenAuditDS *open_audit_ds = (OpenAuditDS *)user_data; - OpenAuditDSPrivate *priv = OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); - OpenAuditDSClass *klass = OPEN_AUDIT_DS_GET_CLASS (open_audit_ds); + AutozGuiOpenAuditDS *open_audit_ds = (AutozGuiOpenAuditDS *)user_data; + AutozGuiOpenAuditDSPrivate *priv = AUTOZ_GUI_OPEN_AUDIT_DS_GET_PRIVATE (open_audit_ds); + AutozGuiOpenAuditDSClass *klass = AUTOZ_GUI_OPEN_AUDIT_DS_GET_CLASS (open_audit_ds); gchar *cncstring; diff --git a/src/openauditds.h b/src/openauditds.h index 763e719..aed7537 100644 --- a/src/openauditds.h +++ b/src/openauditds.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Andrea Zagli + * Copyright (C) 2010-2012 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,8 +17,8 @@ * */ -#ifndef __OPEN_AUDIT_DS_H__ -#define __OPEN_AUDIT_DS_H__ +#ifndef __AUTOZ_GUI_OPEN_AUDIT_DS_H__ +#define __AUTOZ_GUI_OPEN_AUDIT_DS_H__ #include #include @@ -30,36 +30,36 @@ G_BEGIN_DECLS -#define TYPE_OPEN_AUDIT_DS (open_audit_ds_get_type ()) -#define OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDS)) -#define OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPEN_AUDIT_DS, OpenAuditDSClass)) -#define IS_OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPEN_AUDIT_DS)) -#define IS_OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPEN_AUDIT_DS)) -#define OPEN_AUDIT_DS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPEN_AUDIT_DS, OpenAuditDSClass)) +#define TYPE_AUTOZ_GUI_OPEN_AUDIT_DS (autoz_gui_open_audit_ds_get_type ()) +#define AUTOZ_GUI_OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS, AutozGuiOpenAuditDS)) +#define AUTOZ_GUI_OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS, AutozGuiOpenAuditDSClass)) +#define IS_AUTOZ_GUI_OPEN_AUDIT_DS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS)) +#define IS_AUTOZ_GUI_OPEN_AUDIT_DS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS)) +#define AUTOZ_GUI_OPEN_AUDIT_DS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_OPEN_AUDIT_DS, AutozGuiOpenAuditDSClass)) -typedef struct _OpenAuditDS OpenAuditDS; -typedef struct _OpenAuditDSClass OpenAuditDSClass; +typedef struct _AutozGuiOpenAuditDS AutozGuiOpenAuditDS; +typedef struct _AutozGuiOpenAuditDSClass AutozGuiOpenAuditDSClass; -struct _OpenAuditDS +struct _AutozGuiOpenAuditDS { GObject parent; }; -struct _OpenAuditDSClass +struct _AutozGuiOpenAuditDSClass { GObjectClass parent_class; guint opened_signal_id; }; -GType open_audit_ds_get_type (void) G_GNUC_CONST; +GType autoz_gui_open_audit_ds_get_type (void) G_GNUC_CONST; -OpenAuditDS *open_audit_ds_new (AutozGuiCommons *commons); +AutozGuiOpenAuditDS *autoz_gui_open_audit_ds_new (AutozGuiCommons *commons); -GtkWidget *open_audit_ds_get_widget (OpenAuditDS *open_audit_ds); +GtkWidget *autoz_gui_open_audit_ds_get_widget (AutozGuiOpenAuditDS *open_audit_ds); G_END_DECLS -#endif /* __OPEN_AUDIT_DS_H__ */ +#endif /* __AUTOZ_GUI_OPEN_AUDIT_DS_H__ */ diff --git a/src/resource.c b/src/resource.c index a3c4768..2b9c0e3 100644 --- a/src/resource.c +++ b/src/resource.c @@ -22,30 +22,30 @@ #include "resource.h" -static void resource_class_init (ResourceClass *klass); -static void resource_init (Resource *resource); +static void autoz_gui_resource_class_init (AutozGuiResourceClass *klass); +static void autoz_gui_resource_init (AutozGuiResource *resource); -static void resource_load (Resource *resource); -static void resource_save (Resource *resource); +static void autoz_gui_resource_load (AutozGuiResource *resource); +static void autoz_gui_resource_save (AutozGuiResource *resource); -static void resource_set_property (GObject *object, +static void autoz_gui_resource_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void resource_get_property (GObject *object, +static void autoz_gui_resource_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void resource_on_btn_cancel_clicked (GtkButton *button, +static void autoz_gui_resource_on_btn_cancel_clicked (GtkButton *button, gpointer user_data); -static void resource_on_btn_save_clicked (GtkButton *button, +static void autoz_gui_resource_on_btn_save_clicked (GtkButton *button, gpointer user_data); -#define RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RESOURCE, ResourcePrivate)) +#define AUTOZ_GUI_RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_RESOURCE, AutozGuiResourcePrivate)) -typedef struct _ResourcePrivate ResourcePrivate; -struct _ResourcePrivate +typedef struct _AutozGuiResourcePrivate AutozGuiResourcePrivate; +struct _AutozGuiResourcePrivate { AutozGuiCommons *commons; @@ -54,20 +54,20 @@ struct _ResourcePrivate gint id; }; -G_DEFINE_TYPE (Resource, resource, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiResource, autoz_gui_resource, G_TYPE_OBJECT) static void -resource_class_init (ResourceClass *klass) +autoz_gui_resource_class_init (AutozGuiResourceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (ResourcePrivate)); + g_type_class_add_private (object_class, sizeof (AutozGuiResourcePrivate)); - object_class->set_property = resource_set_property; - object_class->get_property = resource_get_property; + object_class->set_property = autoz_gui_resource_set_property; + object_class->get_property = autoz_gui_resource_get_property; /** - * Resource::updated: + * AutozGuiResource::updated: * @resource: * */ @@ -83,26 +83,26 @@ resource_class_init (ResourceClass *klass) } static void -resource_init (Resource *resource) +autoz_gui_resource_init (AutozGuiResource *resource) { - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); } /** - * resource_new: + * autoz_gui_resource_new: * @commons: * @id: * - * Returns: the newly created #Resource object. + * Returns: the newly created #AutozGuiResource object. */ -Resource -*resource_new (AutozGuiCommons *commons, gint id) +AutozGuiResource +*autoz_gui_resource_new (AutozGuiCommons *commons, gint id) { GError *error; - Resource *a = RESOURCE (g_object_new (resource_get_type (), NULL)); + AutozGuiResource *a = AUTOZ_GUI_RESOURCE (g_object_new (autoz_gui_resource_get_type (), NULL)); - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (a); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (a); priv->commons = commons; @@ -119,9 +119,9 @@ Resource priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_resource")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button5"), - "clicked", G_CALLBACK (resource_on_btn_cancel_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_resource_on_btn_cancel_clicked), (gpointer *)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button6"), - "clicked", G_CALLBACK (resource_on_btn_save_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_resource_on_btn_save_clicked), (gpointer *)a); priv->id = id; if (priv->id == 0) @@ -131,30 +131,30 @@ Resource else { gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label5")), g_strdup_printf ("%d", priv->id)); - resource_load (a); + autoz_gui_resource_load (a); } return a; } /** - * resource_get_widget: + * autoz_gui_resource_get_widget: * @resource: * */ GtkWidget -*resource_get_widget (Resource *resource) +*autoz_gui_resource_get_widget (AutozGuiResource *resource) { - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); return priv->w; } /* PRIVATE */ static void -resource_load (Resource *resource) +autoz_gui_resource_load (AutozGuiResource *resource) { - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); GError *error; gchar *sql; @@ -188,7 +188,7 @@ resource_load (Resource *resource) } static void -resource_save (Resource *resource) +autoz_gui_resource_save (AutozGuiResource *resource) { const GdaDsnInfo *info; GError *error; @@ -197,9 +197,9 @@ resource_save (Resource *resource) GdaDataModel *dm; GtkWidget *dialog; - ResourceClass *klass = RESOURCE_GET_CLASS (resource); + AutozGuiResourceClass *klass = AUTOZ_GUI_RESOURCE_GET_CLASS (resource); - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->commons->gtkbuilder, "entry2"))), "") == 0) { @@ -292,10 +292,10 @@ resource_save (Resource *resource) } static void -resource_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_resource_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Resource *resource = RESOURCE (object); - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResource *resource = AUTOZ_GUI_RESOURCE (object); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); switch (property_id) { @@ -306,10 +306,10 @@ resource_set_property (GObject *object, guint property_id, const GValue *value, } static void -resource_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_resource_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Resource *resource = RESOURCE (object); - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResource *resource = AUTOZ_GUI_RESOURCE (object); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); switch (property_id) { @@ -321,19 +321,19 @@ resource_get_property (GObject *object, guint property_id, GValue *value, GParam /* CALLBACK */ static void -resource_on_btn_cancel_clicked (GtkButton *button, +autoz_gui_resource_on_btn_cancel_clicked (GtkButton *button, gpointer user_data) { - Resource *resource = (Resource *)user_data; + AutozGuiResource *resource = (AutozGuiResource *)user_data; - ResourcePrivate *priv = RESOURCE_GET_PRIVATE (resource); + AutozGuiResourcePrivate *priv = AUTOZ_GUI_RESOURCE_GET_PRIVATE (resource); gtk_widget_destroy (priv->w); } static void -resource_on_btn_save_clicked (GtkButton *button, +autoz_gui_resource_on_btn_save_clicked (GtkButton *button, gpointer user_data) { - resource_save ((Resource *)user_data); + autoz_gui_resource_save ((AutozGuiResource *)user_data); } diff --git a/src/resource.h b/src/resource.h index 9146314..8de0786 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2012 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,8 +17,8 @@ * */ -#ifndef __RESOURCE_H__ -#define __RESOURCE_H__ +#ifndef __AUTOZ_GUI_RESOURCE_H__ +#define __AUTOZ_GUI_RESOURCE_H__ #include #include @@ -30,36 +30,36 @@ G_BEGIN_DECLS -#define TYPE_RESOURCE (resource_get_type ()) -#define RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RESOURCE, Resource)) -#define RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RESOURCE, ResourceClass)) -#define IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RESOURCE)) -#define IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RESOURCE)) -#define RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RESOURCE, ResourceClass)) +#define TYPE_AUTOZ_GUI_RESOURCE (autoz_gui_resource_get_type ()) +#define AUTOZ_GUI_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_RESOURCE, AutozGuiResource)) +#define AUTOZ_GUI_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_RESOURCE, AutozGuiResourceClass)) +#define IS_AUTOZ_GUI_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_RESOURCE)) +#define IS_AUTOZ_GUI_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_RESOURCE)) +#define AUTOZ_GUI_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_RESOURCE, AutozGuiResourceClass)) -typedef struct _Resource Resource; -typedef struct _ResourceClass ResourceClass; +typedef struct _AutozGuiResource AutozGuiResource; +typedef struct _AutozGuiResourceClass AutozGuiResourceClass; -struct _Resource +struct _AutozGuiResource { GObject parent; }; -struct _ResourceClass +struct _AutozGuiResourceClass { GObjectClass parent_class; guint updated_signal_id; }; -GType resource_get_type (void) G_GNUC_CONST; +GType autoz_gui_resource_get_type (void) G_GNUC_CONST; -Resource *resource_new (AutozGuiCommons *commons, gint id); +AutozGuiResource *autoz_gui_resource_new (AutozGuiCommons *commons, gint id); -GtkWidget *resource_get_widget (Resource *resource); +GtkWidget *autoz_gui_resource_get_widget (AutozGuiResource *resource); G_END_DECLS -#endif /* __RESOURCE_H__ */ +#endif /* __AUTOZ_GUI_RESOURCE_H__ */ diff --git a/src/resources.c b/src/resources.c index 440241a..0fb8928 100644 --- a/src/resources.c +++ b/src/resources.c @@ -24,35 +24,36 @@ #include "resources.h" #include "resource.h" -static void resources_class_init (ResourcesClass *klass); -static void resources_init (Resources *resources); +static void autoz_gui_resources_class_init (AutozGuiResourcesClass *klass); +static void autoz_gui_resources_init (AutozGuiResources *resources); -static void resources_load (Resources *resources); -static void resources_edit (Resources *resources); +static void autoz_gui_resources_load (AutozGuiResources *resources); +static void autoz_gui_resources_edit (AutozGuiResources *resources); -static void resources_on_resource_updated (gpointer instance, gpointer user_data); +static void autoz_gui_resources_selected (AutozGuiResources *resources); +static void autoz_gui_resources_on_resource_updated (gpointer instance, gpointer user_data); -static void resources_set_property (GObject *object, +static void autoz_gui_resources_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void resources_get_property (GObject *object, +static void autoz_gui_resources_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void resources_on_btn_new_clicked (GtkButton *button, +static void autoz_gui_resources_on_btn_new_clicked (GtkButton *button, gpointer user_data); -static void resources_on_btn_edit_clicked (GtkButton *button, +static void autoz_gui_resources_on_btn_edit_clicked (GtkButton *button, gpointer user_data); -static void resources_on_btn_delete_clicked (GtkButton *button, +static void autoz_gui_resources_on_btn_delete_clicked (GtkButton *button, gpointer user_data); -static void resources_on_trv_resources_row_activated (GtkTreeView *tree_view, +static void autoz_gui_resources_on_trv_autoz_gui_resources_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data); -#define RESOURCES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_RESOURCES, ResourcesPrivate)) +#define AUTOZ_GUI_RESOURCES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_RESOURCES, AutozGuiResourcesPrivate)) enum { @@ -60,53 +61,71 @@ enum COL_NAME }; -typedef struct _ResourcesPrivate ResourcesPrivate; -struct _ResourcesPrivate +typedef struct _AutozGuiResourcesPrivate AutozGuiResourcesPrivate; +struct _AutozGuiResourcesPrivate { AutozGuiCommons *commons; GtkWidget *widget; - GtkTreeSelection *selection; + GtkTreeSelection *sel_selection; GtkListStore *lstore_resources; + + gboolean selection; }; -G_DEFINE_TYPE (Resources, resources, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiResources, autoz_gui_resources, G_TYPE_OBJECT) static void -resources_class_init (ResourcesClass *klass) +autoz_gui_resources_class_init (AutozGuiResourcesClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (ResourcesPrivate)); - - object_class->set_property = resources_set_property; - object_class->get_property = resources_get_property; + g_type_class_add_private (object_class, sizeof (AutozGuiResourcesPrivate)); + + object_class->set_property = autoz_gui_resources_set_property; + object_class->get_property = autoz_gui_resources_get_property; + + /** + * Resources::selected: + * @resources: + * + */ + klass->selected_signal_id = g_signal_new ("selected", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, G_TYPE_UINT); } static void -resources_init (Resources *resources) +autoz_gui_resources_init (AutozGuiResources *resources) { - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); } /** - * resources_new: + * autoz_gui_resources_new: * @commons: * @selection: * - * Returns: the newly created #Resources object. + * Returns: the newly created #AutozGuiResources object. */ -Resources -*resources_new (AutozGuiCommons *commons, gboolean selection) +AutozGuiResources +*autoz_gui_resources_new (AutozGuiCommons *commons, gboolean selection) { GError *error; - Resources *a = RESOURCES (g_object_new (resources_get_type (), NULL)); + AutozGuiResources *a = AUTOZ_GUI_RESOURCES (g_object_new (autoz_gui_resources_get_type (), NULL)); - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (a); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (a); priv->commons = commons; + priv->selection = selection; error = NULL; gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, @@ -122,17 +141,17 @@ Resources } priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, (selection ? "w_resources" : "vbox7"))); - priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview1"))); + priv->sel_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview1"))); priv->lstore_resources = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_resources")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button11"), - "clicked", G_CALLBACK (resources_on_btn_new_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_resources_on_btn_new_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button12"), - "clicked", G_CALLBACK (resources_on_btn_edit_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_resources_on_btn_edit_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button14"), - "clicked", G_CALLBACK (resources_on_btn_delete_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_resources_on_btn_delete_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview1"), - "row-activated", G_CALLBACK (resources_on_trv_resources_row_activated), (gpointer)a); + "row-activated", G_CALLBACK (autoz_gui_resources_on_trv_autoz_gui_resources_row_activated), (gpointer)a); if (!selection) { @@ -140,31 +159,31 @@ Resources gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button16"))); } - resources_load (a); + autoz_gui_resources_load (a); return a; } /** - * resources_get_widget: + * autoz_gui_resources_get_widget: * @resources: * */ GtkWidget -*resources_get_widget (Resources *resources) +*autoz_gui_resources_get_widget (AutozGuiResources *resources) { - ResourcesPrivate *priv; + AutozGuiResourcesPrivate *priv; - g_return_val_if_fail (IS_RESOURCES (resources), NULL); + g_return_val_if_fail (IS_AUTOZ_GUI_RESOURCES (resources), NULL); - priv = RESOURCES_GET_PRIVATE (resources); + priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); return priv->widget; } /* PRIVATE */ static void -resources_load (Resources *resources) +autoz_gui_resources_load (AutozGuiResources *resources) { GtkTreeIter iter; @@ -177,7 +196,7 @@ resources_load (Resources *resources) gint rows; gint row; - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); gtk_list_store_clear (priv->lstore_resources); @@ -210,14 +229,14 @@ resources_load (Resources *resources) } static void -resources_edit (Resources *resources) +autoz_gui_resources_edit (AutozGuiResources *resources) { GtkTreeIter iter; guint id; - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); - if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) { GtkWidget *w; @@ -225,18 +244,18 @@ resources_edit (Resources *resources) COL_ID, &id, -1); - Resource *c = resource_new (priv->commons, id); + AutozGuiResource *c = autoz_gui_resource_new (priv->commons, id); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (resources_on_resource_updated), (gpointer)resources); + G_CALLBACK (autoz_gui_resources_on_resource_updated), (gpointer)resources); - w = resource_get_widget (c); - gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + w = autoz_gui_resource_get_widget (c); + gtk_window_set_transient_for (GTK_WINDOW (w), priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } else { - GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GtkWidget *dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -247,16 +266,48 @@ resources_edit (Resources *resources) } static void -resources_on_resource_updated (gpointer instance, gpointer user_data) +autoz_gui_resources_on_resource_updated (gpointer instance, gpointer user_data) +{ + autoz_gui_resources_load ((AutozGuiResources *)user_data); +} + +static void +autoz_gui_resources_selected (AutozGuiResources *resources) { - resources_load ((Resources *)user_data); + GtkTreeIter iter; + guint id; + + AutozGuiResourcesClass *klass = AUTOZ_GUI_RESOURCES_GET_CLASS (resources); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); + + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_resources), &iter, + COL_ID, &id, + -1); + + g_signal_emit (G_OBJECT (resources), klass->selected_signal_id, 0, id); + + gtk_widget_destroy (priv->widget); + g_object_unref (G_OBJECT (resources)); + } + else + { + GtkWidget *dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Select a resource."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } } static void -resources_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_resources_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Resources *resources = RESOURCES (object); - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResources *resources = AUTOZ_GUI_RESOURCES (object); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); switch (property_id) { @@ -267,10 +318,10 @@ resources_set_property (GObject *object, guint property_id, const GValue *value, } static void -resources_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_resources_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Resources *resources = RESOURCES (object); - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResources *resources = AUTOZ_GUI_RESOURCES (object); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); switch (property_id) { @@ -282,33 +333,33 @@ resources_get_property (GObject *object, guint property_id, GValue *value, GPara /* CALLBACK */ static void -resources_on_btn_new_clicked (GtkButton *button, +autoz_gui_resources_on_btn_new_clicked (GtkButton *button, gpointer user_data) { GtkWidget *w; - Resources *resources = (Resources *)user_data; - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResources *resources = (AutozGuiResources *)user_data; + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); - Resource *c = resource_new (priv->commons, 0); + AutozGuiResource *c = autoz_gui_resource_new (priv->commons, 0); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (resources_on_resource_updated), (gpointer)resources); + G_CALLBACK (autoz_gui_resources_on_resource_updated), (gpointer)resources); - w = resource_get_widget (c); - gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + w = autoz_gui_resource_get_widget (c); + gtk_window_set_transient_for (GTK_WINDOW (w), priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } static void -resources_on_btn_edit_clicked (GtkButton *button, +autoz_gui_resources_on_btn_edit_clicked (GtkButton *button, gpointer user_data) { - resources_edit ((Resources *)user_data); + autoz_gui_resources_edit ((AutozGuiResources *)user_data); } static void -resources_on_btn_delete_clicked (GtkButton *button, +autoz_gui_resources_on_btn_delete_clicked (GtkButton *button, gpointer user_data) { GtkWidget *dialog; @@ -317,12 +368,12 @@ resources_on_btn_delete_clicked (GtkButton *button, GtkTreeIter iter; guint id; - Resources *resources = (Resources *)user_data; - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE (resources); + AutozGuiResources *resources = (AutozGuiResources *)user_data; + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE (resources); - if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, @@ -345,7 +396,7 @@ resources_on_btn_delete_clicked (GtkButton *button, if (stmt == NULL || error != NULL) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -359,7 +410,7 @@ resources_on_btn_delete_clicked (GtkButton *button, error = NULL; if (gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error) <= 0) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -369,12 +420,12 @@ resources_on_btn_delete_clicked (GtkButton *button, gtk_widget_destroy (dialog); } - resources_load (resources); + autoz_gui_resources_load (resources); } } else { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) :GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -385,12 +436,19 @@ resources_on_btn_delete_clicked (GtkButton *button, } static void -resources_on_trv_resources_row_activated (GtkTreeView *tree_view, +autoz_gui_resources_on_trv_autoz_gui_resources_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data) { - ResourcesPrivate *priv = RESOURCES_GET_PRIVATE ((Resources *)user_data); + AutozGuiResourcesPrivate *priv = AUTOZ_GUI_RESOURCES_GET_PRIVATE ((AutozGuiResources *)user_data); - resources_edit ((Resources *)user_data); + if (priv->selection) + { + autoz_gui_resources_selected ((AutozGuiResources *)user_data); + } + else + { + autoz_gui_resources_edit ((AutozGuiResources *)user_data); + } } diff --git a/src/resources.h b/src/resources.h index 1ce1abd..2fdb692 100644 --- a/src/resources.h +++ b/src/resources.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2012 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,8 +17,8 @@ * */ -#ifndef __RESOURCES_H__ -#define __RESOURCES_H__ +#ifndef __AUTOZ_GUI_RESOURCES_H__ +#define __AUTOZ_GUI_RESOURCES_H__ #include #include @@ -30,34 +30,36 @@ G_BEGIN_DECLS -#define TYPE_RESOURCES (resources_get_type ()) -#define RESOURCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RESOURCES, Resources)) -#define RESOURCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RESOURCES, ResourcesClass)) -#define IS_RESOURCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RESOURCES)) -#define IS_RESOURCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RESOURCES)) -#define RESOURCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RESOURCES, ResourcesClass)) +#define TYPE_AUTOZ_GUI_RESOURCES (autoz_gui_resources_get_type ()) +#define AUTOZ_GUI_RESOURCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_RESOURCES, AutozGuiResources)) +#define AUTOZ_GUI_RESOURCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_RESOURCES, AutozGuiResourcesClass)) +#define IS_AUTOZ_GUI_RESOURCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_RESOURCES)) +#define IS_AUTOZ_GUI_RESOURCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_RESOURCES)) +#define AUTOZ_GUI_RESOURCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_RESOURCES, AutozGuiResourcesClass)) -typedef struct _Resources Resources; -typedef struct _ResourcesClass ResourcesClass; +typedef struct _AutozGuiResources AutozGuiResources; +typedef struct _AutozGuiResourcesClass AutozGuiResourcesClass; -struct _Resources +struct _AutozGuiResources { GObject parent; }; -struct _ResourcesClass +struct _AutozGuiResourcesClass { GObjectClass parent_class; + + guint selected_signal_id; }; -GType resources_get_type (void) G_GNUC_CONST; +GType autoz_gui_resources_get_type (void) G_GNUC_CONST; -Resources *resources_new (AutozGuiCommons *commons, gboolean selection); +AutozGuiResources *autoz_gui_resources_new (AutozGuiCommons *commons, gboolean selection); -GtkWidget *resources_get_widget (Resources *resources); +GtkWidget *autoz_gui_resources_get_widget (AutozGuiResources *resources); G_END_DECLS -#endif /* __RESOURCES_H__ */ +#endif /* __AUTOZ_GUI_RESOURCES_H__ */ diff --git a/src/role.c b/src/role.c index 35ddc7e..4fde183 100644 --- a/src/role.c +++ b/src/role.c @@ -22,30 +22,30 @@ #include "role.h" -static void role_class_init (RoleClass *klass); -static void role_init (Role *role); +static void autoz_gui_role_class_init (AutozGuiRoleClass *klass); +static void autoz_gui_role_init (AutozGuiRole *role); -static void role_load (Role *role); -static void role_save (Role *role); +static void autoz_gui_role_load (AutozGuiRole *role); +static void autoz_gui_role_save (AutozGuiRole *role); -static void role_set_property (GObject *object, +static void autoz_gui_role_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void role_get_property (GObject *object, +static void autoz_gui_role_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void role_on_btn_cancel_clicked (GtkButton *button, +static void autoz_gui_role_on_btn_cancel_clicked (GtkButton *button, gpointer user_data); -static void role_on_btn_save_clicked (GtkButton *button, +static void autoz_gui_role_on_btn_save_clicked (GtkButton *button, gpointer user_data); -#define ROLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ROLE, RolePrivate)) +#define AUTOZ_GUI_ROLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_ROLE, AutozGuiRolePrivate)) -typedef struct _RolePrivate RolePrivate; -struct _RolePrivate +typedef struct _AutozGuiRolePrivate AutozGuiRolePrivate; +struct _AutozGuiRolePrivate { AutozGuiCommons *commons; @@ -54,20 +54,20 @@ struct _RolePrivate gint id; }; -G_DEFINE_TYPE (Role, role, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiRole, autoz_gui_role, G_TYPE_OBJECT) static void -role_class_init (RoleClass *klass) +autoz_gui_role_class_init (AutozGuiRoleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (RolePrivate)); + g_type_class_add_private (object_class, sizeof (AutozGuiRolePrivate)); - object_class->set_property = role_set_property; - object_class->get_property = role_get_property; + object_class->set_property = autoz_gui_role_set_property; + object_class->get_property = autoz_gui_role_get_property; /** - * Role::updated: + * AutozGuiRole::updated: * @role: * */ @@ -83,26 +83,26 @@ role_class_init (RoleClass *klass) } static void -role_init (Role *role) +autoz_gui_role_init (AutozGuiRole *role) { - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); } /** - * role_new: + * autoz_gui_role_new: * @commons: * @id: * - * Returns: the newly created #Role object. + * Returns: the newly created #AutozGuiRole object. */ -Role -*role_new (AutozGuiCommons *commons, gint id) +AutozGuiRole +*autoz_gui_role_new (AutozGuiCommons *commons, gint id) { GError *error; - Role *a = ROLE (g_object_new (role_get_type (), NULL)); + AutozGuiRole *a = AUTOZ_GUI_ROLE (g_object_new (autoz_gui_role_get_type (), NULL)); - RolePrivate *priv = ROLE_GET_PRIVATE (a); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (a); priv->commons = commons; @@ -119,9 +119,9 @@ Role priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_role")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button3"), - "clicked", G_CALLBACK (role_on_btn_cancel_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_role_on_btn_cancel_clicked), (gpointer *)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button4"), - "clicked", G_CALLBACK (role_on_btn_save_clicked), (gpointer *)a); + "clicked", G_CALLBACK (autoz_gui_role_on_btn_save_clicked), (gpointer *)a); priv->id = id; if (priv->id == 0) @@ -131,30 +131,30 @@ Role else { gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label2")), g_strdup_printf ("%d", priv->id)); - role_load (a); + autoz_gui_role_load (a); } return a; } /** - * role_get_widget: + * autoz_gui_role_get_widget: * @role: * */ GtkWidget -*role_get_widget (Role *role) +*autoz_gui_role_get_widget (AutozGuiRole *role) { - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); return priv->w; } /* PRIVATE */ static void -role_load (Role *role) +autoz_gui_role_load (AutozGuiRole *role) { - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); GError *error; gchar *sql; @@ -189,7 +189,7 @@ role_load (Role *role) } static void -role_save (Role *role) +autoz_gui_role_save (AutozGuiRole *role) { const GdaDsnInfo *info; GError *error; @@ -198,9 +198,9 @@ role_save (Role *role) GdaDataModel *dm; GtkWidget *dialog; - RoleClass *klass = ROLE_GET_CLASS (role); + AutozGuiRoleClass *klass = AUTOZ_GUI_ROLE_GET_CLASS (role); - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (priv->commons->gtkbuilder, "entry1"))), "") == 0) { @@ -293,10 +293,10 @@ role_save (Role *role) } static void -role_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_role_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - Role *role = ROLE (object); - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRole *role = AUTOZ_GUI_ROLE (object); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); switch (property_id) { @@ -307,10 +307,10 @@ role_set_property (GObject *object, guint property_id, const GValue *value, GPar } static void -role_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_role_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Role *role = ROLE (object); - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRole *role = AUTOZ_GUI_ROLE (object); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); switch (property_id) { @@ -322,19 +322,19 @@ role_get_property (GObject *object, guint property_id, GValue *value, GParamSpec /* CALLBACK */ static void -role_on_btn_cancel_clicked (GtkButton *button, +autoz_gui_role_on_btn_cancel_clicked (GtkButton *button, gpointer user_data) { - Role *role = (Role *)user_data; + AutozGuiRole *role = (AutozGuiRole *)user_data; - RolePrivate *priv = ROLE_GET_PRIVATE (role); + AutozGuiRolePrivate *priv = AUTOZ_GUI_ROLE_GET_PRIVATE (role); gtk_widget_destroy (priv->w); } static void -role_on_btn_save_clicked (GtkButton *button, +autoz_gui_role_on_btn_save_clicked (GtkButton *button, gpointer user_data) { - role_save ((Role *)user_data); + autoz_gui_role_save ((AutozGuiRole *)user_data); } diff --git a/src/role.h b/src/role.h index 10d3e1c..7bb5a11 100644 --- a/src/role.h +++ b/src/role.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2012 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,8 +17,8 @@ * */ -#ifndef __ROLE_H__ -#define __ROLE_H__ +#ifndef __AUTOZ_GUI_ROLE_H__ +#define __AUTOZ_GUI_ROLE_H__ #include #include @@ -30,36 +30,36 @@ G_BEGIN_DECLS -#define TYPE_ROLE (role_get_type ()) -#define ROLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ROLE, Role)) -#define ROLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ROLE, RoleClass)) -#define IS_ROLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ROLE)) -#define IS_ROLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ROLE)) -#define ROLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ROLE, RoleClass)) +#define TYPE_AUTOZ_GUI_ROLE (autoz_gui_role_get_type ()) +#define AUTOZ_GUI_ROLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_ROLE, AutozGuiRole)) +#define AUTOZ_GUI_ROLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_ROLE, AutozGuiRoleClass)) +#define IS_AUTOZ_GUI_ROLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_ROLE)) +#define IS_AUTOZ_GUI_ROLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_ROLE)) +#define AUTOZ_GUI_ROLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_ROLE, AutozGuiRoleClass)) -typedef struct _Role Role; -typedef struct _RoleClass RoleClass; +typedef struct _AutozGuiRole AutozGuiRole; +typedef struct _AutozGuiRoleClass AutozGuiRoleClass; -struct _Role +struct _AutozGuiRole { GObject parent; }; -struct _RoleClass +struct _AutozGuiRoleClass { GObjectClass parent_class; guint updated_signal_id; }; -GType role_get_type (void) G_GNUC_CONST; +GType autoz_gui_role_get_type (void) G_GNUC_CONST; -Role *role_new (AutozGuiCommons *commons, gint id); +AutozGuiRole *autoz_gui_role_new (AutozGuiCommons *commons, gint id); -GtkWidget *role_get_widget (Role *role); +GtkWidget *autoz_gui_role_get_widget (AutozGuiRole *role); G_END_DECLS -#endif /* __ROLE_H__ */ +#endif /* __AUTOZ_GUI_ROLE_H__ */ diff --git a/src/roles.c b/src/roles.c index bf8c46c..34bf6df 100644 --- a/src/roles.c +++ b/src/roles.c @@ -24,35 +24,36 @@ #include "roles.h" #include "role.h" -static void roles_class_init (RolesClass *klass); -static void roles_init (Roles *roles); +static void autoz_gui_roles_class_init (AutozGuiRolesClass *klass); +static void autoz_gui_roles_init (AutozGuiRoles *roles); -static void roles_load (Roles *roles); -static void roles_edit (Roles *roles); +static void autoz_gui_roles_load (AutozGuiRoles *roles); +static void autoz_gui_roles_edit (AutozGuiRoles *roles); -static void roles_on_role_updated (gpointer instance, gpointer user_data); +static void autoz_gui_roles_selected (AutozGuiRoles *roles); +static void autoz_gui_roles_on_role_updated (gpointer instance, gpointer user_data); -static void roles_set_property (GObject *object, +static void autoz_gui_roles_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void roles_get_property (GObject *object, +static void autoz_gui_roles_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void roles_on_btn_new_clicked (GtkButton *button, +static void autoz_gui_roles_on_btn_new_clicked (GtkButton *button, gpointer user_data); -static void roles_on_btn_edit_clicked (GtkButton *button, +static void autoz_gui_roles_on_btn_edit_clicked (GtkButton *button, gpointer user_data); -static void roles_on_btn_delete_clicked (GtkButton *button, +static void autoz_gui_roles_on_btn_delete_clicked (GtkButton *button, gpointer user_data); -static void roles_on_trv_roles_row_activated (GtkTreeView *tree_view, +static void autoz_gui_roles_on_trv_autoz_gui_roles_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data); -#define ROLES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ROLES, RolesPrivate)) +#define AUTOZ_GUI_ROLES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_AUTOZ_GUI_ROLES, AutozGuiRolesPrivate)) enum { @@ -60,53 +61,71 @@ enum COL_NAME }; -typedef struct _RolesPrivate RolesPrivate; -struct _RolesPrivate +typedef struct _AutozGuiRolesPrivate AutozGuiRolesPrivate; +struct _AutozGuiRolesPrivate { AutozGuiCommons *commons; GtkWidget *widget; - GtkTreeSelection *selection; + GtkTreeSelection *sel_selection; GtkListStore *lstore_roles; + + gboolean selection; }; -G_DEFINE_TYPE (Roles, roles, G_TYPE_OBJECT) +G_DEFINE_TYPE (AutozGuiRoles, autoz_gui_roles, G_TYPE_OBJECT) static void -roles_class_init (RolesClass *klass) +autoz_gui_roles_class_init (AutozGuiRolesClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (RolesPrivate)); - - object_class->set_property = roles_set_property; - object_class->get_property = roles_get_property; + g_type_class_add_private (object_class, sizeof (AutozGuiRolesPrivate)); + + object_class->set_property = autoz_gui_roles_set_property; + object_class->get_property = autoz_gui_roles_get_property; + + /** + * Roles::selected: + * @roles: + * + */ + klass->selected_signal_id = g_signal_new ("selected", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, + 1, G_TYPE_UINT); } static void -roles_init (Roles *roles) +autoz_gui_roles_init (AutozGuiRoles *roles) { - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); } /** - * roles_new: + * autoz_gui_roles_new: * @commons: * @selection: * - * Returns: the newly created #Roles object. + * Returns: the newly created #AutozGuiRoles object. */ -Roles -*roles_new (AutozGuiCommons *commons, gboolean selection) +AutozGuiRoles +*autoz_gui_roles_new (AutozGuiCommons *commons, gboolean selection) { GError *error; - Roles *a = ROLES (g_object_new (roles_get_type (), NULL)); + AutozGuiRoles *a = AUTOZ_GUI_ROLES (g_object_new (autoz_gui_roles_get_type (), NULL)); - RolesPrivate *priv = ROLES_GET_PRIVATE (a); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (a); priv->commons = commons; + priv->selection = selection; error = NULL; gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, @@ -122,17 +141,17 @@ Roles } priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, (selection ? "w_roles" : "vbox5"))); - priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"))); + priv->sel_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"))); priv->lstore_roles = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_roles")); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button7"), - "clicked", G_CALLBACK (roles_on_btn_new_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_roles_on_btn_new_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button9"), - "clicked", G_CALLBACK (roles_on_btn_edit_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_roles_on_btn_edit_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button8"), - "clicked", G_CALLBACK (roles_on_btn_delete_clicked), (gpointer)a); + "clicked", G_CALLBACK (autoz_gui_roles_on_btn_delete_clicked), (gpointer)a); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"), - "row-activated", G_CALLBACK (roles_on_trv_roles_row_activated), (gpointer)a); + "row-activated", G_CALLBACK (autoz_gui_roles_on_trv_autoz_gui_roles_row_activated), (gpointer)a); if (!selection) { @@ -140,31 +159,31 @@ Roles gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "button13"))); } - roles_load (a); + autoz_gui_roles_load (a); return a; } /** - * roles_get_widget: + * autoz_gui_roles_get_widget: * @roles: * */ GtkWidget -*roles_get_widget (Roles *roles) +*autoz_gui_roles_get_widget (AutozGuiRoles *roles) { - RolesPrivate *priv; + AutozGuiRolesPrivate *priv; - g_return_val_if_fail (IS_ROLES (roles), NULL); + g_return_val_if_fail (IS_AUTOZ_GUI_ROLES (roles), NULL); - priv = ROLES_GET_PRIVATE (roles); + priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); return priv->widget; } /* PRIVATE */ static void -roles_load (Roles *roles) +autoz_gui_roles_load (AutozGuiRoles *roles) { GtkTreeIter iter; @@ -177,7 +196,7 @@ roles_load (Roles *roles) gint rows; gint row; - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); gtk_list_store_clear (priv->lstore_roles); @@ -210,14 +229,14 @@ roles_load (Roles *roles) } static void -roles_edit (Roles *roles) +autoz_gui_roles_edit (AutozGuiRoles *roles) { GtkTreeIter iter; guint id; - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); - if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) { GtkWidget *w; @@ -225,18 +244,18 @@ roles_edit (Roles *roles) COL_ID, &id, -1); - Role *c = role_new (priv->commons, id); + AutozGuiRole *c = autoz_gui_role_new (priv->commons, id); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (roles_on_role_updated), (gpointer)roles); + G_CALLBACK (autoz_gui_roles_on_role_updated), (gpointer)roles); - w = role_get_widget (c); - gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + w = autoz_gui_role_get_widget (c); + gtk_window_set_transient_for (GTK_WINDOW (w), priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } else { - GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GtkWidget *dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -247,16 +266,48 @@ roles_edit (Roles *roles) } static void -roles_on_role_updated (gpointer instance, gpointer user_data) +autoz_gui_roles_on_role_updated (gpointer instance, gpointer user_data) { - roles_load ((Roles *)user_data); + autoz_gui_roles_load ((AutozGuiRoles *)user_data); } static void -roles_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +autoz_gui_roles_selected (AutozGuiRoles *roles) { - Roles *roles = ROLES (object); - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + GtkTreeIter iter; + guint id; + + AutozGuiRolesClass *klass = AUTOZ_GUI_ROLES_GET_CLASS (roles); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); + + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_roles), &iter, + COL_ID, &id, + -1); + + g_signal_emit (G_OBJECT (roles), klass->selected_signal_id, 0, id); + + gtk_widget_destroy (priv->widget); + g_object_unref (G_OBJECT (roles)); + } + else + { + GtkWidget *dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Select a role."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +autoz_gui_roles_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + AutozGuiRoles *roles = AUTOZ_GUI_ROLES (object); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); switch (property_id) { @@ -267,10 +318,10 @@ roles_set_property (GObject *object, guint property_id, const GValue *value, GPa } static void -roles_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +autoz_gui_roles_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - Roles *roles = ROLES (object); - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRoles *roles = AUTOZ_GUI_ROLES (object); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); switch (property_id) { @@ -282,33 +333,33 @@ roles_get_property (GObject *object, guint property_id, GValue *value, GParamSpe /* CALLBACK */ static void -roles_on_btn_new_clicked (GtkButton *button, +autoz_gui_roles_on_btn_new_clicked (GtkButton *button, gpointer user_data) { GtkWidget *w; - Roles *roles = (Roles *)user_data; - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRoles *roles = (AutozGuiRoles *)user_data; + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); - Role *c = role_new (priv->commons, 0); + AutozGuiRole *c = autoz_gui_role_new (priv->commons, 0); g_signal_connect (G_OBJECT (c), "updated", - G_CALLBACK (roles_on_role_updated), (gpointer)roles); + G_CALLBACK (autoz_gui_roles_on_role_updated), (gpointer)roles); - w = role_get_widget (c); - gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); + w = autoz_gui_role_get_widget (c); + gtk_window_set_transient_for (GTK_WINDOW (w), priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); gtk_widget_show_all (w); } static void -roles_on_btn_edit_clicked (GtkButton *button, +autoz_gui_roles_on_btn_edit_clicked (GtkButton *button, gpointer user_data) { - roles_edit ((Roles *)user_data); + autoz_gui_roles_edit ((AutozGuiRoles *)user_data); } static void -roles_on_btn_delete_clicked (GtkButton *button, +autoz_gui_roles_on_btn_delete_clicked (GtkButton *button, gpointer user_data) { GtkWidget *dialog; @@ -317,12 +368,12 @@ roles_on_btn_delete_clicked (GtkButton *button, GtkTreeIter iter; guint id; - Roles *roles = (Roles *)user_data; - RolesPrivate *priv = ROLES_GET_PRIVATE (roles); + AutozGuiRoles *roles = (AutozGuiRoles *)user_data; + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE (roles); - if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter)) + if (gtk_tree_selection_get_selected (priv->sel_selection, NULL, &iter)) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, @@ -345,7 +396,7 @@ roles_on_btn_delete_clicked (GtkButton *button, if (stmt == NULL || error != NULL) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -359,7 +410,7 @@ roles_on_btn_delete_clicked (GtkButton *button, error = NULL; if (gda_connection_statement_execute_non_select (priv->commons->gdacon, stmt, NULL, NULL, &error) <= 0) { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -369,12 +420,12 @@ roles_on_btn_delete_clicked (GtkButton *button, gtk_widget_destroy (dialog); } - roles_load (roles); + autoz_gui_roles_load (roles); } } else { - dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), + dialog = gtk_message_dialog_new (priv->selection ? GTK_WINDOW (priv->widget) : GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -385,12 +436,19 @@ roles_on_btn_delete_clicked (GtkButton *button, } static void -roles_on_trv_roles_row_activated (GtkTreeView *tree_view, +autoz_gui_roles_on_trv_autoz_gui_roles_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *column, gpointer user_data) { - RolesPrivate *priv = ROLES_GET_PRIVATE ((Roles *)user_data); + AutozGuiRolesPrivate *priv = AUTOZ_GUI_ROLES_GET_PRIVATE ((AutozGuiRoles *)user_data); - roles_edit ((Roles *)user_data); + if (priv->selection) + { + autoz_gui_roles_selected ((AutozGuiRoles *)user_data); + } + else + { + autoz_gui_roles_edit ((AutozGuiRoles *)user_data); + } } diff --git a/src/roles.h b/src/roles.h index ddae38b..6234584 100644 --- a/src/roles.h +++ b/src/roles.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Andrea Zagli + * Copyright (C) 2011-2012 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -17,8 +17,8 @@ * */ -#ifndef __ROLES_H__ -#define __ROLES_H__ +#ifndef __AUTOZ_GUI_ROLES_H__ +#define __AUTOZ_GUI_ROLES_H__ #include #include @@ -30,34 +30,36 @@ G_BEGIN_DECLS -#define TYPE_ROLES (roles_get_type ()) -#define ROLES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ROLES, Roles)) -#define ROLES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ROLES, RolesClass)) -#define IS_ROLES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ROLES)) -#define IS_ROLES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ROLES)) -#define ROLES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ROLES, RolesClass)) +#define TYPE_AUTOZ_GUI_ROLES (autoz_gui_roles_get_type ()) +#define AUTOZ_GUI_ROLES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AUTOZ_GUI_ROLES, AutozGuiRoles)) +#define AUTOZ_GUI_ROLES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AUTOZ_GUI_ROLES, AutozGuiRolesClass)) +#define IS_AUTOZ_GUI_ROLES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AUTOZ_GUI_ROLES)) +#define IS_AUTOZ_GUI_ROLES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AUTOZ_GUI_ROLES)) +#define AUTOZ_GUI_ROLES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AUTOZ_GUI_ROLES, AutozGuiRolesClass)) -typedef struct _Roles Roles; -typedef struct _RolesClass RolesClass; +typedef struct _AutozGuiRoles AutozGuiRoles; +typedef struct _AutozGuiRolesClass AutozGuiRolesClass; -struct _Roles +struct _AutozGuiRoles { GObject parent; }; -struct _RolesClass +struct _AutozGuiRolesClass { GObjectClass parent_class; + + guint selected_signal_id; }; -GType roles_get_type (void) G_GNUC_CONST; +GType autoz_gui_roles_get_type (void) G_GNUC_CONST; -Roles *roles_new (AutozGuiCommons *commons, gboolean selection); +AutozGuiRoles *autoz_gui_roles_new (AutozGuiCommons *commons, gboolean selection); -GtkWidget *roles_get_widget (Roles *roles); +GtkWidget *autoz_gui_roles_get_widget (AutozGuiRoles *roles); G_END_DECLS -#endif /* __ROLES_H__ */ +#endif /* __AUTOZ_GUI_ROLES_H__ */ diff --git a/tests/db.db b/tests/db.db index 14be4bf..1e554ee 100644 Binary files a/tests/db.db and b/tests/db.db differ