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,
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;
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;
"",
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));
}
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)
{
return priv->dialog;
}
+/**
+ * solipa_mail_ui_get_widget:
+ * @solipa:
+ *
+ * Returns: the vbox inside the dialog.
+ */
GtkWidget
*solipa_mail_ui_get_widget (SolipaMailUI *mailui)
{
GParamSpec *pspec)
{
SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)object;
-
SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
switch (property_id)
GParamSpec *pspec)
{
SolipaMailUI *solipa_mail_ui = (SolipaMailUI *)object;
-
SolipaMailUIPrivate *priv = SOLIPA_MAIL_UI_GET_PRIVATE (solipa_mail_ui);
switch (property_id)
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
#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;
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;
#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,
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 ();