]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunti i segnali SolipaMailUI::btn-cancel-clicked e
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 5 May 2011 14:24:19 +0000 (16:24 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 5 May 2011 14:24:19 +0000 (16:24 +0200)
SolipaMailUI::btn-ok-clicked.

data/libsolipa/gui/libsolipa.ui
src/mailui.c
src/mailui.h
tests/mailui.c

index 3dde99d4e1ec94879573f117b5ceecfcd3a353cf..8abed8c53a6dfda49d22bfe29121c2633d6fdb30 100644 (file)
     <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">normal</property>
+    <property name="has_separator">True</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox2">
         <property name="visible">True</property>
index faa3243faeb6b8f628565300bb4f846da75f5142..526b5757d51c680b811ba0cfbcb92e46f6b1d41d 100644 (file)
@@ -35,7 +35,7 @@ enum
        PROP_BODY
 };
 
-static void solipa_mail_ui_class_init (SolipaMailUIClass *class);
+static void solipa_mail_ui_class_init (SolipaMailUIClass *klass);
 static void solipa_mail_ui_init (SolipaMailUI *solipa_mail_ui);
 
 static void solipa_mail_ui_set_property (GObject *object,
@@ -47,6 +47,11 @@ static void solipa_mail_ui_get_property (GObject *object,
                                GValue *value,
                                GParamSpec *pspec);
 
+static void solipa_mail_ui_on_cancel_clicked (GtkButton *button,
+                                              gpointer user_data);
+static void solipa_mail_ui_on_ok_clicked (GtkButton *button,
+                                          gpointer user_data);
+
 #define SOLIPA_MAIL_UI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_SOLIPA_MAIL_UI, SolipaMailUIPrivate))
 
 typedef struct _SolipaMailUIPrivate SolipaMailUIPrivate;
@@ -71,9 +76,9 @@ struct _SolipaMailUIPrivate
 G_DEFINE_TYPE (SolipaMailUI, solipa_mail_ui, G_TYPE_OBJECT)
 
 static void
-solipa_mail_ui_class_init (SolipaMailUIClass *class)
+solipa_mail_ui_class_init (SolipaMailUIClass *klass)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
        object_class->set_property = solipa_mail_ui_set_property;
        object_class->get_property = solipa_mail_ui_get_property;
@@ -127,6 +132,36 @@ solipa_mail_ui_class_init (SolipaMailUIClass *class)
                                                              "",
                                                              G_PARAM_READWRITE));
 
+       /**
+        * SolipaMailUI::btn_cancel_clicked:
+        * @solipa_mail_ui:
+        *
+        */
+       klass->btn_cancel_clicked_signal_id = g_signal_new ("btn-cancel-clicked",
+                                                           G_TYPE_FROM_CLASS (object_class),
+                                                           G_SIGNAL_RUN_LAST,
+                                                           0,
+                                                           NULL,
+                                                           NULL,
+                                                           g_cclosure_marshal_BOOLEAN__FLAGS,
+                                                           G_TYPE_BOOLEAN,
+                                                           1, G_TYPE_INT);
+
+       /**
+        * SolipaMailUI::btn_ok_clicked:
+        * @solipa_mail_ui:
+        *
+        */
+       klass->btn_ok_clicked_signal_id = g_signal_new ("btn-ok-clicked",
+                                                           G_TYPE_FROM_CLASS (object_class),
+                                                           G_SIGNAL_RUN_LAST,
+                                                           0,
+                                                           NULL,
+                                                           NULL,
+                                                           g_cclosure_marshal_BOOLEAN__FLAGS,
+                                                           G_TYPE_BOOLEAN,
+                                                           1, G_TYPE_INT);
+
        g_type_class_add_private (object_class, sizeof (SolipaMailUIPrivate));
 }
 
@@ -191,9 +226,20 @@ SolipaMailUI
        priv->subject = GTK_WIDGET (gtk_builder_get_object (builder, "entry5"));
        priv->body = GTK_WIDGET (gtk_builder_get_object (builder, "textview1"));
 
+       g_signal_connect (gtk_builder_get_object (builder, "button6"), "clicked",
+                         G_CALLBACK (solipa_mail_ui_on_cancel_clicked), (gpointer)solipa_mail_ui);
+       g_signal_connect (gtk_builder_get_object (builder, "button7"), "clicked",
+                         G_CALLBACK (solipa_mail_ui_on_ok_clicked), (gpointer)solipa_mail_ui);
+
        return solipa_mail_ui;
 }
 
+/**
+ * solipa_mail_ui_get_dialog:
+ * @solipa:
+ *
+ * Returns: the dialog.
+ */
 GtkWidget
 *solipa_mail_ui_get_dialog (SolipaMailUI *mailui)
 {
@@ -207,6 +253,12 @@ GtkWidget
        return priv->dialog;
 }
 
+/**
+ * solipa_mail_ui_get_widget:
+ * @solipa:
+ *
+ * Returns: the vbox inside the dialog.
+ */
 GtkWidget
 *solipa_mail_ui_get_widget (SolipaMailUI *mailui)
 {
@@ -229,7 +281,6 @@ solipa_mail_ui_set_property (GObject *object,
                    GParamSpec *pspec)
 {
        SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)object;
-
        SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
 
        switch (property_id)
@@ -275,7 +326,6 @@ solipa_mail_ui_get_property (GObject *object,
                    GParamSpec *pspec)
 {
        SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)object;
-
        SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
 
        switch (property_id)
@@ -313,3 +363,44 @@ solipa_mail_ui_get_property (GObject *object,
                                break;
                }
 }
+
+/* CALLBACK */
+static void
+solipa_mail_ui_on_cancel_clicked (GtkButton *button,
+                                  gpointer user_data)
+{
+       gboolean ret;
+
+       SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)user_data;
+       SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
+       SolipaMailUIClass *klass = SOLIPA_MAIL_UI_GET_CLASS (solipa_mail_ui);
+
+       ret = FALSE;
+       g_signal_emit (G_OBJECT (user_data), klass->btn_cancel_clicked_signal_id, 0, 0, &ret);
+
+       if (!ret && gtk_widget_get_parent (priv->widget) == NULL)
+               {
+                       /* close the dialog */
+                       gtk_widget_destroy (priv->widget);
+                       g_object_unref (user_data);
+               }
+}
+
+static void
+solipa_mail_ui_on_ok_clicked (GtkButton *button,
+                              gpointer user_data)
+{
+       gboolean ret;
+
+       SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)user_data;
+       SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
+       SolipaMailUIClass *klass = SOLIPA_MAIL_UI_GET_CLASS (solipa_mail_ui);
+
+       ret = FALSE;
+       g_signal_emit (G_OBJECT (user_data), klass->btn_ok_clicked_signal_id, 0, 0, &ret);
+
+       if (!ret)
+               {
+                       /* send email */
+               }
+}
\ No newline at end of file
index e531990c3f04291b97f0c33138f6c036848bfc7a..e906cbc63da54511b0fd735924b51f136bfa0c74 100644 (file)
@@ -30,10 +30,10 @@ G_BEGIN_DECLS
 
 #define TYPE_SOLIPA_MAIL_UI                 (solipa_mail_ui_get_type ())
 #define SOLIPA_MAIL_UI(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SOLIPA_MAIL_UI, SolipaMailUI))
-#define SOLIPA_MAIL_UI_UI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOLIPA_MAIL_UI, SolipaMailUIClass))
+#define SOLIPA_MAIL_UI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SOLIPA_MAIL_UI, SolipaMailUIClass))
 #define IS_SOLIPA_MAIL_UI(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SOLIPA_MAIL_UI))
-#define IS_SOLIPA_MAIL_UI_UI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOLIPA_MAIL_UI))
-#define SOLIPA_MAIL_UI_UI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOLIPA_MAIL_UI, SolipaMailUIClass))
+#define IS_SOLIPA_MAIL_UI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SOLIPA_MAIL_UI))
+#define SOLIPA_MAIL_UI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SOLIPA_MAIL_UI, SolipaMailUIClass))
 
 typedef struct _SolipaMailUI SolipaMailUI;
 typedef struct _SolipaMailUIClass SolipaMailUIClass;
@@ -46,6 +46,9 @@ struct _SolipaMailUI
 struct _SolipaMailUIClass
        {
                GObjectClass parent_class;
+
+               guint btn_cancel_clicked_signal_id;
+               guint btn_ok_clicked_signal_id;
        };
 
 GType solipa_mail_ui_get_type (void) G_GNUC_CONST;
index e27bb66d4a01b183187e3e199cc1aaff8b5d72d6..ad036426029b946aef658dabc136a04caf783163 100644 (file)
 #include <mailui.h>
 
 GtkWidget *w;
+GtkWidget *mailui_w;
+
+static void
+on_btn_cancel_clicked (gpointer instance, gpointer user_data)
+{
+       g_debug ("Cancel clicked");
+       gtk_widget_destroy (w);
+}
+
+static void
+on_btn_ok_clicked (gpointer instance, gpointer user_data)
+{
+       g_debug ("OK clicked");
+}
 
 gboolean
 on_w_delete_event (GtkWidget *widget,
@@ -71,10 +85,16 @@ main (int argc, char *argv[])
        w = GTK_WIDGET (gtk_builder_get_object (builder, "w_mail"));
        g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), (gpointer)solipa);
 
+       mailui_w = solipa_mail_ui_get_widget (mailui);
        gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "vbox3")),
-                           solipa_mail_ui_get_widget (mailui),
+                           mailui_w,
                            TRUE, TRUE, 5);
 
+       g_signal_connect (gtk_builder_get_object (builder, "button1"), "clicked",
+                         G_CALLBACK (on_btn_cancel_clicked), NULL);
+       g_signal_connect (gtk_builder_get_object (builder, "button2"), "clicked",
+                         G_CALLBACK (on_btn_ok_clicked), NULL);
+
        gtk_widget_show (w);
 
        gtk_main ();