From 5277c90009df4557a24cfefede7328d85e399711 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 20 Jul 2006 14:24:13 +0000 Subject: [PATCH] * add some new windows to the gtk2 backend. very experimental pmo-trunk-r400 --- src/gtk2/modest-account-view-window.c | 298 +++++++++++++++++++++++++++++++++ src/gtk2/modest-account-view-window.h | 45 +++++ src/gtk2/modest-account-wizard.c | 132 +++++++++++++++ src/gtk2/modest-account-wizard.h | 49 ++++++ src/gtk2/modest-msg-window.c | 163 ++++++++++++++++++ src/gtk2/modest-msg-window.h | 83 +++++++++ 6 files changed, 770 insertions(+) create mode 100644 src/gtk2/modest-account-view-window.c create mode 100644 src/gtk2/modest-account-view-window.h create mode 100644 src/gtk2/modest-account-wizard.c create mode 100644 src/gtk2/modest-account-wizard.h create mode 100644 src/gtk2/modest-msg-window.c create mode 100644 src/gtk2/modest-msg-window.h diff --git a/src/gtk2/modest-account-view-window.c b/src/gtk2/modest-account-view-window.c new file mode 100644 index 0000000..37be559 --- /dev/null +++ b/src/gtk2/modest-account-view-window.c @@ -0,0 +1,298 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "modest-account-view-window.h" +#include "modest-account-wizard.h" + +/* 'private'/'protected' functions */ +static void modest_account_view_window_class_init (ModestAccountViewWindowClass *klass); +static void modest_account_view_window_init (ModestAccountViewWindow *obj); +static void modest_account_view_window_finalize (GObject *obj); + +/* list my signals */ +enum { + /* MY_SIGNAL_1, */ + /* MY_SIGNAL_2, */ + LAST_SIGNAL +}; + + +typedef struct _ModestAccountViewWindowPrivate ModestAccountViewWindowPrivate; +struct _ModestAccountViewWindowPrivate { + ModestConf *conf; + ModestWidgetFactory *widget_factory; + GtkWidget *edit_button, *remove_button; +}; +#define MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + MODEST_TYPE_ACCOUNT_VIEW_WINDOW, \ + ModestAccountViewWindowPrivate)) +/* globals */ +static GtkWindowClass *parent_class = NULL; + +/* uncomment the following if you have defined any signals */ +/* static guint signals[LAST_SIGNAL] = {0}; */ + +GType +modest_account_view_window_get_type (void) +{ + static GType my_type = 0; + if (!my_type) { + static const GTypeInfo my_info = { + sizeof(ModestAccountViewWindowClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_account_view_window_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestAccountViewWindow), + 1, /* n_preallocs */ + (GInstanceInitFunc) modest_account_view_window_init, + }; + my_type = g_type_register_static (GTK_TYPE_WINDOW, + "ModestAccountViewWindow", + &my_info, 0); + } + return my_type; +} + +static void +modest_account_view_window_class_init (ModestAccountViewWindowClass *klass) +{ + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_account_view_window_finalize; + + g_type_class_add_private (gobject_class, sizeof(ModestAccountViewWindowPrivate)); + + /* signal definitions go here, e.g.: */ +/* signals[MY_SIGNAL_1] = */ +/* g_signal_new ("my_signal_1",....); */ +/* signals[MY_SIGNAL_2] = */ +/* g_signal_new ("my_signal_2",....); */ +/* etc. */ +} + +static void +modest_account_view_window_init (ModestAccountViewWindow *obj) +{ + +} + +static void +modest_account_view_window_finalize (GObject *obj) +{ + ModestAccountViewWindowPrivate *priv; + + priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj); + + if (priv->conf) { + g_object_unref (G_OBJECT(priv->conf)); + priv->conf = NULL; + } + + if (priv->widget_factory) { + g_object_unref (G_OBJECT(priv->widget_factory)); + priv->widget_factory = NULL; + } +} + + +static void +on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self) +{ + ModestAccountViewWindowPrivate *priv; + GtkTreeModel *model; + GtkTreeIter iter; + gboolean has_selection; + + priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); + + has_selection = + gtk_tree_selection_get_selected (sel, &model, &iter); + + gtk_widget_set_sensitive (priv->edit_button, has_selection); + gtk_widget_set_sensitive (priv->remove_button, has_selection); +} + + + +static void +on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +{ + g_message (__FUNCTION__); +} + +static void +on_edit_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +{ + g_message (__FUNCTION__); +} + +static void +on_add_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +{ + GtkWidget *wizard; + + wizard = modest_account_wizard_new (); + + gtk_widget_show (GTK_WIDGET(wizard)); +} + + +static void +on_close_button_clicked (GtkWidget *button, ModestAccountViewWindow *self) +{ + gtk_widget_destroy (GTK_WIDGET(self)); +} + + + +static GtkWidget* +button_box_new (ModestAccountViewWindow *self) +{ + + GtkWidget *button_box; + GtkWidget *add_button, *remove_button, *edit_button, *close_button; + ModestAccountViewWindowPrivate *priv; + + priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); + + button_box = gtk_vbutton_box_new (); + + add_button = gtk_button_new_from_stock(GTK_STOCK_ADD); + remove_button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); + edit_button = gtk_button_new_from_stock(GTK_STOCK_EDIT); + + g_signal_connect (G_OBJECT(add_button), "clicked", + G_CALLBACK(on_add_button_clicked), + self); + g_signal_connect (G_OBJECT(remove_button), "clicked", + G_CALLBACK(on_remove_button_clicked), + self); + g_signal_connect (G_OBJECT(edit_button), "clicked", + G_CALLBACK(on_edit_button_clicked), + self); + + gtk_box_pack_start (GTK_BOX(button_box), add_button, FALSE, FALSE,2); + gtk_box_pack_start (GTK_BOX(button_box), remove_button, FALSE, FALSE,2); + gtk_box_pack_start (GTK_BOX(button_box), edit_button, FALSE, FALSE,2); + + gtk_widget_set_sensitive (edit_button, FALSE); + gtk_widget_set_sensitive (remove_button, FALSE); + + /* remember these, so we can deactivate them when nothing i + * selected */ + priv->remove_button = remove_button; + priv->edit_button = edit_button; + + return button_box; +} + + +static GtkWidget* +window_vbox_new (ModestAccountViewWindow *self) +{ + ModestAccountViewWindowPrivate *priv; + GtkTreeSelection *sel; + GtkWidget *main_hbox, *main_vbox, *button_box; + GtkWidget *close_button; + GtkWidget *close_hbox; + ModestAccountView *account_view; + + priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self); + + main_vbox = gtk_vbox_new (FALSE, 6); + main_hbox = gtk_hbox_new (FALSE, 6); + + account_view = modest_widget_factory_get_account_view_widget (priv->widget_factory); + + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(account_view)); + g_signal_connect (G_OBJECT(sel), "changed", G_CALLBACK(on_selection_changed), + self); + + button_box = button_box_new (self); + + gtk_box_pack_start (GTK_BOX(main_hbox), GTK_WIDGET(account_view), TRUE, TRUE, 2); + gtk_box_pack_start (GTK_BOX(main_hbox), button_box, FALSE, FALSE,2); + + gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 2); + + + close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); + g_signal_connect (G_OBJECT(close_button), "clicked", + G_CALLBACK(on_close_button_clicked), + self); + + close_hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_end (GTK_BOX(close_hbox), + close_button, FALSE, FALSE,2); + gtk_box_pack_end (GTK_BOX(main_vbox), close_hbox, FALSE, FALSE,2); + + gtk_widget_show_all (main_vbox); + return main_vbox; +} + + +GtkWidget* +modest_account_view_window_new (ModestConf *conf, ModestWidgetFactory *factory) +{ + GObject *obj; + ModestAccountViewWindowPrivate *priv; + + g_return_val_if_fail (conf, NULL); + g_return_val_if_fail (factory, NULL); + + obj = g_object_new(MODEST_TYPE_ACCOUNT_VIEW_WINDOW, NULL); + priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj); + + g_object_ref (G_OBJECT(conf)); + priv->conf = conf; + + g_object_ref (G_OBJECT(factory)); + priv->widget_factory = factory; + + gtk_window_set_resizable (GTK_WINDOW(obj), TRUE); + gtk_window_set_default_size (GTK_WINDOW(obj), + MODEST_ACCOUNT_VIEW_WINDOW_WIDTH_DEFAULT, + MODEST_ACCOUNT_VIEW_WINDOW_HEIGHT_DEFAULT); + gtk_window_set_resizable (GTK_WINDOW(obj), FALSE); + + gtk_window_set_title (GTK_WINDOW(obj), _("Accounts")); + gtk_window_set_type_hint (GTK_WINDOW(obj), GDK_WINDOW_TYPE_HINT_DIALOG); + + gtk_window_set_modal (GTK_WINDOW(obj), TRUE); + + + gtk_container_add (GTK_CONTAINER(obj), + window_vbox_new (MODEST_ACCOUNT_VIEW_WINDOW(obj))); + + return GTK_WIDGET(obj); +} diff --git a/src/gtk2/modest-account-view-window.h b/src/gtk2/modest-account-view-window.h new file mode 100644 index 0000000..12bd393 --- /dev/null +++ b/src/gtk2/modest-account-view-window.h @@ -0,0 +1,45 @@ +/* modest-account-view-window.h */ +/* insert (c)/licensing information) */ + +#ifndef __MODEST_ACCOUNT_VIEW_WINDOW_H__ +#define __MODEST_ACCOUNT_VIEW_WINDOW_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_ACCOUNT_VIEW_WINDOW (modest_account_view_window_get_type()) +#define MODEST_ACCOUNT_VIEW_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_VIEW_WINDOW,ModestAccountViewWindow)) +#define MODEST_ACCOUNT_VIEW_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_VIEW_WINDOW,GtkWindow)) +#define MODEST_IS_ACCOUNT_VIEW_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_VIEW_WINDOW)) +#define MODEST_IS_ACCOUNT_VIEW_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_VIEW_WINDOW)) +#define MODEST_ACCOUNT_VIEW_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_VIEW_WINDOW,ModestAccountViewWindowClass)) + +typedef struct _ModestAccountViewWindow ModestAccountViewWindow; +typedef struct _ModestAccountViewWindowClass ModestAccountViewWindowClass; + +struct _ModestAccountViewWindow { + GtkWindow parent; + /* insert public members, if any */ +}; + +struct _ModestAccountViewWindowClass { + GtkWindowClass parent_class; + /* insert signal callback declarations, eg. */ + /* void (* my_event) (ModestAccountViewWindow* obj); */ +}; + +/* member functions */ +GType modest_account_view_window_get_type (void) G_GNUC_CONST; + + +GtkWidget* modest_account_view_window_new (ModestConf *conf, + ModestWidgetFactory *factory); + +G_END_DECLS + +#endif /* __MODEST_ACCOUNT_VIEW_WINDOW_H__ */ + diff --git a/src/gtk2/modest-account-wizard.c b/src/gtk2/modest-account-wizard.c new file mode 100644 index 0000000..fe7df51 --- /dev/null +++ b/src/gtk2/modest-account-wizard.c @@ -0,0 +1,132 @@ +/* modest-account-wizard.c */ + +/* insert (c)/licensing information) */ + +#include "modest-account-wizard.h" +/* include other impl specific header files */ + +/* 'private'/'protected' functions */ +static void modest_account_wizard_class_init (ModestAccountWizardClass *klass); +static void modest_account_wizard_init (ModestAccountWizard *obj); +static void modest_account_wizard_finalize (GObject *obj); + +/* list my signals */ +enum { + /* MY_SIGNAL_1, */ + /* MY_SIGNAL_2, */ + LAST_SIGNAL +}; + +typedef struct _ModestAccountWizardPrivate ModestAccountWizardPrivate; +struct _ModestAccountWizardPrivate { + /* my private members go here, eg. */ + /* gboolean frobnicate_mode; */ +}; +#define MODEST_ACCOUNT_WIZARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + MODEST_TYPE_ACCOUNT_WIZARD, \ + ModestAccountWizardPrivate)) +/* globals */ +static GtkAssistantClass *parent_class = NULL; + +/* uncomment the following if you have defined any signals */ +/* static guint signals[LAST_SIGNAL] = {0}; */ + +GType +modest_account_wizard_get_type (void) +{ + static GType my_type = 0; + if (!my_type) { + static const GTypeInfo my_info = { + sizeof(ModestAccountWizardClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_account_wizard_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestAccountWizard), + 1, /* n_preallocs */ + (GInstanceInitFunc) modest_account_wizard_init, + }; + my_type = g_type_register_static (GTK_TYPE_ASSISTANT, + "ModestAccountWizard", + &my_info, 0); + } + return my_type; +} + +static void +modest_account_wizard_class_init (ModestAccountWizardClass *klass) +{ + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_account_wizard_finalize; + + g_type_class_add_private (gobject_class, sizeof(ModestAccountWizardPrivate)); + + /* signal definitions go here, e.g.: */ +/* signals[MY_SIGNAL_1] = */ +/* g_signal_new ("my_signal_1",....); */ +/* signals[MY_SIGNAL_2] = */ +/* g_signal_new ("my_signal_2",....); */ +/* etc. */ +} + + + +static GtkWidget* +first_page () +{ + GtkWidget *label; + + const gchar* txt = + _("Welcome to the Modest Setup Wizard\n\n" + "This wizard will help you to set up email accounts.\n" + "Push the 'Next'-button to start"); + + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL(label), txt); + + return label; +} + + + + +static void +modest_account_wizard_init (ModestAccountWizard *obj) +{ + GtkWidget *page1; + int pageno; + + page1 = first_page (); + pageno = gtk_assistant_append_page (GTK_ASSISTANT(obj), page1); + + gtk_assistant_set_page_type (GTK_ASSISTANT(obj), + page1, + GTK_ASSISTANT_PAGE_INTRO); + gtk_assistant_set_page_title (GTK_ASSISTANT(obj), + page1, _("Account Wizard")); + + gtk_assistant_set_page_complete (GTK_ASSISTANT(obj), page1, TRUE); + + /* without this next one, we crash... + * http://bugzilla.gnome.org/show_bug.cgi?id=347048 + */ + //k_assistant_set_current_page (GTK_ASSISTANT(obj), pageno); + + +} + +static void +modest_account_wizard_finalize (GObject *obj) +{ +/* free/unref instance resources here */ +} + +GtkWidget* +modest_account_wizard_new (void) +{ + return GTK_WIDGET(g_object_new(MODEST_TYPE_ACCOUNT_WIZARD, NULL)); +} diff --git a/src/gtk2/modest-account-wizard.h b/src/gtk2/modest-account-wizard.h new file mode 100644 index 0000000..2462d3a --- /dev/null +++ b/src/gtk2/modest-account-wizard.h @@ -0,0 +1,49 @@ +/* modest-account-wizard.h */ +/* insert (c)/licensing information) */ + +#ifndef __MODEST_ACCOUNT_WIZARD_H__ +#define __MODEST_ACCOUNT_WIZARD_H__ + +#include +#include + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_ACCOUNT_WIZARD (modest_account_wizard_get_type()) +#define MODEST_ACCOUNT_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_WIZARD,ModestAccountWizard)) +#define MODEST_ACCOUNT_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_WIZARD,GtkAssistant)) +#define MODEST_IS_ACCOUNT_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_WIZARD)) +#define MODEST_IS_ACCOUNT_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_WIZARD)) +#define MODEST_ACCOUNT_WIZARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_WIZARD,ModestAccountWizardClass)) + +typedef struct _ModestAccountWizard ModestAccountWizard; +typedef struct _ModestAccountWizardClass ModestAccountWizardClass; + +struct _ModestAccountWizard { + GtkAssistant parent; + /* insert public members, if any */ +}; + +struct _ModestAccountWizardClass { + GtkAssistantClass parent_class; + /* insert signal callback declarations, eg. */ + /* void (* my_event) (ModestAccountWizard* obj); */ +}; + +/* member functions */ +GType modest_account_wizard_get_type (void) G_GNUC_CONST; + +/* typical parameter-less _new function */ +/* if this is a kind of GtkWidget, it should probably return at GtkWidget* */ +GtkWidget* modest_account_wizard_new (void); + +/* fill in other public functions, eg.: */ +/* void modest_account_wizard_do_something (ModestAccountWizard *self, const gchar* param); */ +/* gboolean modest_account_wizard_has_foo (ModestAccountWizard *self, gint value); */ + + +G_END_DECLS + +#endif /* __MODEST_ACCOUNT_WIZARD_H__ */ + diff --git a/src/gtk2/modest-msg-window.c b/src/gtk2/modest-msg-window.c new file mode 100644 index 0000000..072c704 --- /dev/null +++ b/src/gtk2/modest-msg-window.c @@ -0,0 +1,163 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include "modest-msg-window.h" + +/* 'private'/'protected' functions */ +static void modest_msg_window_class_init (ModestMsgWindowClass *klass); +static void modest_msg_window_init (ModestMsgWindow *obj); +static void modest_msg_window_finalize (GObject *obj); + +/* list my signals */ +enum { + /* MY_SIGNAL_1, */ + /* MY_SIGNAL_2, */ + LAST_SIGNAL +}; + +typedef struct _ModestMsgWindowPrivate ModestMsgWindowPrivate; +struct _ModestMsgWindowPrivate { + /* my private members go here, eg. */ + /* gboolean frobnicate_mode; */ +}; +#define MODEST_MSG_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + MODEST_TYPE_MSG_WINDOW, \ + ModestMsgWindowPrivate)) +/* globals */ +static GtkWindowClass *parent_class = NULL; + +/* uncomment the following if you have defined any signals */ +/* static guint signals[LAST_SIGNAL] = {0}; */ + +GType +modest_msg_window_get_type (void) +{ + static GType my_type = 0; + if (!my_type) { + static const GTypeInfo my_info = { + sizeof(ModestMsgWindowClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_msg_window_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestMsgWindow), + 1, /* n_preallocs */ + (GInstanceInitFunc) modest_msg_window_init, + }; + my_type = g_type_register_static (GTK_TYPE_WINDOW, + "ModestMsgWindow", + &my_info, 0); + } + return my_type; +} + +static void +modest_msg_window_class_init (ModestMsgWindowClass *klass) +{ + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_msg_window_finalize; + + g_type_class_add_private (gobject_class, sizeof(ModestMsgWindowPrivate)); + + /* signal definitions go here, e.g.: */ +/* signals[MY_SIGNAL_1] = */ +/* g_signal_new ("my_signal_1",....); */ +/* signals[MY_SIGNAL_2] = */ +/* g_signal_new ("my_signal_2",....); */ +/* etc. */ +} + +static void +modest_msg_window_init (ModestMsgWindow *obj) +{ + GtkWidget *to_button, *cc_button, *bcc_button, *subject_label; + GtkWidget *to_field, *cc_field, *bcc_field, *subject_field; + GtkWidget *header_table; + GtkWidget *main_vbox; + GtkWidget *msg_field; + + ModestMsgWindowPrivate *priv; + priv = MODEST_MSG_WINDOW_GET_PRIVATE(obj); + + to_button = gtk_button_new_with_label (_("To...")); + cc_button = gtk_button_new_with_label (_("Cc...")); + bcc_button = gtk_button_new_with_label (_("Bcc...")); + subject_label = gtk_label_new (_("Subject:")); + + to_field = gtk_entry_new (); + cc_field = gtk_entry_new (); + bcc_field = gtk_entry_new (); + subject_field = gtk_entry_new (); + + header_table = gtk_table_new (4,2, FALSE); + gtk_table_attach_defaults (GTK_TABLE(header_table), to_button, 0,1,0,1); + gtk_table_attach_defaults (GTK_TABLE(header_table), cc_button, 0,1,1,2); + gtk_table_attach_defaults (GTK_TABLE(header_table), bcc_button, 0,1,2,3); + gtk_table_attach_defaults (GTK_TABLE(header_table), subject_label, 0,1,3,4); + + gtk_table_attach_defaults (GTK_TABLE(header_table), to_field, 1,2,0,1); + gtk_table_attach_defaults (GTK_TABLE(header_table), cc_field, 1,2,1,2); + gtk_table_attach_defaults (GTK_TABLE(header_table), bcc_field, 1,2,2,3); + gtk_table_attach_defaults (GTK_TABLE(header_table), subject_field, 1,2,3,4); + + msg_field = modest_tny_msg_view_new (NULL); + + main_vbox = gtk_vbox_new (FALSE, 6); + + gtk_box_pack_start (GTK_BOX(main_vbox), header_table, FALSE, FALSE, 6); + gtk_box_pack_start (GTK_BOX(main_vbox), msg_field, TRUE, TRUE, 6); + + gtk_widget_show_all (GTK_WIDGET(main_vbox)); + + gtk_container_add (GTK_CONTAINER(obj), main_vbox); +} + +static void +modest_msg_window_finalize (GObject *obj) +{ +/* free/unref instance resources here */ +} + +GtkWidget* +modest_msg_window_new (ModestMsgWindowType type, TnyMsgIface *msg) +{ + GObject *obj; + + g_return_val_if_fail ((type >= 1 && type <= MODEST_MSG_WINDOW_TYPE_NUM), NULL); + + obj = g_object_new(MODEST_TYPE_MSG_WINDOW, NULL); + + return GTK_WIDGET (obj); +} + diff --git a/src/gtk2/modest-msg-window.h b/src/gtk2/modest-msg-window.h new file mode 100644 index 0000000..cc280a9 --- /dev/null +++ b/src/gtk2/modest-msg-window.h @@ -0,0 +1,83 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_MSG_WINDOW_H__ +#define __MODEST_MSG_WINDOW_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_MSG_WINDOW (modest_msg_window_get_type()) +#define MODEST_MSG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_WINDOW,ModestMsgWindow)) +#define MODEST_MSG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_WINDOW,GtkWindow)) +#define MODEST_IS_MSG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_WINDOW)) +#define MODEST_IS_MSG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_WINDOW)) +#define MODEST_MSG_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_WINDOW,ModestMsgWindowClass)) + +typedef struct _ModestMsgWindow ModestMsgWindow; +typedef struct _ModestMsgWindowClass ModestMsgWindowClass; + +struct _ModestMsgWindow { + GtkWindow parent; + /* insert public members, if any */ +}; + +struct _ModestMsgWindowClass { + GtkWindowClass parent_class; + /* insert signal callback declarations, eg. */ + /* void (* my_event) (ModestMsgWindow* obj); */ +}; + + +enum _ModestMsgWindowType { + MODEST_MSG_WINDOW_TYPE_VIEW, + MODEST_MSG_WINDOW_TYPE_NEW, + MODEST_MSG_WINDOW_TYPE_REPLY, + MODEST_MSG_WINDOW_TYPE_FORWARD, + + MODEST_MSG_WINDOW_TYPE_NUM +}; + +typedef enum _ModestMsgWindowType ModestMsgWindowType; + + +/* member functions */ +GType modest_msg_window_get_type (void) G_GNUC_CONST; + +GtkWidget* modest_msg_window_new (ModestMsgWindowType type, + TnyMsgIface *msg); + +G_END_DECLS + +#endif /* __MODEST_MSG_WINDOW_H__ */ + -- 1.7.9.5