* create new object class modest-editor-window as abstraction for the editor sub...
authorNils Faerber <nils@kernelconcepts.de>
Thu, 8 Jun 2006 12:19:43 +0000 (12:19 +0000)
committerNils Faerber <nils@kernelconcepts.de>
Thu, 8 Jun 2006 12:19:43 +0000 (12:19 +0000)
pmo-trunk-r182

src/Makefile.am
src/gtk-glade/modest-ui.c
src/modest-editor-window.c [new file with mode: 0644]
src/modest-editor-window.h [new file with mode: 0644]
src/modest-ui.h

index 7129270..488d087 100644 (file)
@@ -8,7 +8,8 @@ INCLUDES=\
        $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) \
        $(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \
        -I$(MODEST_UI_DIR)\
-       -DPREFIX=\"@prefix@\"
+       -DPREFIX=\"@prefix@\" \
+       -Wall
 
 bin_PROGRAMS=\
        modest
@@ -47,6 +48,8 @@ modest_SOURCES=\
        modest-tny-stream-gtkhtml.c\
        modest-tny-transport-actions.c\
        modest-tny-transport-actions.h\
+       modest-editor-window.c\
+       modest-editor-window.h\
        modest-ui.h
 
 modest_LDADD = \
index 784eda5..74f27da 100644 (file)
@@ -29,6 +29,8 @@
 #include "../modest-text-utils.h"
 #include "../modest-tny-msg-actions.h"
 
+#include "../modest-editor-window.h"
+
 #include "modest-ui-glade.h"
 #include "modest-ui-wizard.h"
 
@@ -319,11 +321,11 @@ modest_ui_show_main_window (ModestUI *modest_ui)
                g_warning ("The new account item isn't available!\n");
                return FALSE;
        }
-
+/*
         g_signal_connect (new_account_item, "activate",
-                          G_CALLBACK(new_wizard_account),
+                          G_CALLBACK(on_new_account1_activate),
                           modest_ui);
-
+*/
        delete_item = glade_xml_get_widget (priv->glade_xml, "delete1");
        if (!delete_item)
        {
@@ -413,6 +415,52 @@ hide_edit_window (GtkWidget *win, GdkEvent *event, gpointer data)
 }
 
 
+GtkContainer
+*modest_ui_new_editor_window (ModestUI *modest_ui, gpointer *user_data)
+{
+       GtkWidget       *top_container, *to_entry, *subject_entry, *body_view;
+
+       ModestUIPrivate *priv;
+       GladeXML                *ui_ref;
+       GtkWidget       *btn, *dummy;
+       GtkTextBuffer   *buf;
+
+       priv = MODEST_UI_GET_PRIVATE(modest_ui);
+       int height = modest_conf_get_int (priv->modest_conf,
+                                         MODEST_CONF_EDIT_WINDOW_HEIGHT,NULL);
+       int width  = modest_conf_get_int (priv->modest_conf,
+                                         MODEST_CONF_EDIT_WINDOW_WIDTH,NULL);
+
+       ui_ref = glade_xml_new(MODEST_GLADE, "new_mail", NULL);
+       if (!ui_ref)
+               return NULL;
+
+       *user_data = ui_ref;
+
+       top_container = glade_xml_get_widget(ui_ref, "new_mail_top_container");
+       if (!top_container) {
+               g_object_unref(G_OBJECT(ui_ref));
+               return NULL;
+       }
+
+       return GTK_CONTAINER(top_container);
+}
+
+
+gboolean
+modest_ui_editor_window_set_to_header(ModestEditorWindow *edit_win, gchar *to)
+{
+       GladeXML *glade_xml;
+       GtkWidget *w;
+
+       glade_xml = (GladeXML *)modest_editor_window_get_data(edit_win);
+       w = glade_xml_get_widget(glade_xml, "to_entry");
+       gtk_entry_set_text(GTK_ENTRY(w), to);
+
+       return TRUE;
+}
+
+
 gboolean
 modest_ui_new_edit_window (ModestUI *modest_ui, const gchar* to,
                            const gchar* cc, const gchar* bcc,
@@ -443,7 +491,7 @@ modest_ui_new_edit_window (ModestUI *modest_ui, const gchar* to,
                modest_window_mgr_register (priv->modest_window_mgr,
                                                                        G_OBJECT(win), MODEST_EDIT_WINDOW, 0);
        }
-
+       
        to_entry      = glade_xml_get_widget (priv->glade_xml, "to_entry");
        subject_entry = glade_xml_get_widget (priv->glade_xml, "subject_entry");
        body_view     = glade_xml_get_widget (priv->glade_xml, "body_view");
diff --git a/src/modest-editor-window.c b/src/modest-editor-window.c
new file mode 100644 (file)
index 0000000..d499ac6
--- /dev/null
@@ -0,0 +1,135 @@
+/* modest-editor-window.c */
+
+/* insert (c)/licensing information) */
+
+#include "modest-editor-window.h"
+
+/* 'private'/'protected' functions */
+static void                      modest_editor_window_class_init    (ModestEditorWindowClass *klass);
+static void                      modest_editor_window_init          (ModestEditorWindow *obj);
+static void                      modest_editor_window_finalize      (GObject *obj);
+
+/* list my signals */
+enum {
+       /* MY_SIGNAL_1, */
+       /* MY_SIGNAL_2, */
+       LAST_SIGNAL
+};
+
+typedef struct _ModestEditorWindowPrivate ModestEditorWindowPrivate;
+struct _ModestEditorWindowPrivate {
+       gpointer user_data;
+};
+#define MODEST_EDITOR_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                                  MODEST_TYPE_EDITOR_WINDOW, \
+                                                  ModestEditorWindowPrivate))
+/* globals */
+static GtkWindowClass *parent_class = NULL;
+
+/* uncomment the following if you have defined any signals */
+/* static guint signals[LAST_SIGNAL] = {0}; */
+
+GType
+modest_editor_window_get_type (void)
+{
+       static GType my_type = 0;
+       if (!my_type) {
+               static const GTypeInfo my_info = {
+                       sizeof(ModestEditorWindowClass),
+                       NULL,           /* base init */
+                       NULL,           /* base finalize */
+                       (GClassInitFunc) modest_editor_window_class_init,
+                       NULL,           /* class finalize */
+                       NULL,           /* class data */
+                       sizeof(ModestEditorWindow),
+                       1,              /* n_preallocs */
+                       (GInstanceInitFunc) modest_editor_window_init,
+               };
+               my_type = g_type_register_static (GTK_TYPE_WINDOW,
+                                                 "ModestEditorWindow",
+                                                 &my_info, 0);
+       }
+       return my_type;
+}
+
+static void
+modest_editor_window_class_init (ModestEditorWindowClass *klass)
+{
+       GObjectClass *gobject_class;
+       gobject_class = (GObjectClass*) klass;
+
+       parent_class            = g_type_class_peek_parent (klass);
+       gobject_class->finalize = modest_editor_window_finalize;
+
+       g_type_class_add_private (gobject_class, sizeof(ModestEditorWindowPrivate));
+
+       /* 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_editor_window_init (ModestEditorWindow *obj)
+{
+       ModestEditorWindowPrivate *priv = MODEST_EDITOR_WINDOW_GET_PRIVATE(obj);
+
+       priv->user_data = NULL;
+}
+
+static void
+modest_editor_window_finalize (GObject *obj)
+{
+       ModestEditorWindowPrivate *priv;
+
+       priv = MODEST_EDITOR_WINDOW_GET_PRIVATE(obj);
+
+       /* FIXME: free GladeXML */
+}
+
+GtkWindow*
+modest_editor_window_new (ModestUI *ui)
+{
+       GObject *self;
+       ModestEditorWindowPrivate *priv;
+       GtkWidget *w;
+       gpointer data;
+
+       self = G_OBJECT(g_object_new(MODEST_TYPE_EDITOR_WINDOW, NULL));
+       priv = MODEST_EDITOR_WINDOW_GET_PRIVATE(self);
+
+       /* for now create a local test-window */
+
+       data = NULL;
+       w = GTK_WIDGET(modest_ui_new_editor_window(ui, &data));
+       if (!w)
+               return NULL;
+
+       gtk_container_add(GTK_CONTAINER(self), w);
+       priv->user_data = data;
+       
+       return GTK_WINDOW(self);
+}
+
+
+gpointer modest_editor_window_get_data(ModestEditorWindow *edit_win)
+{
+       GObject *self;
+       ModestEditorWindowPrivate *priv;
+
+       
+       if (!edit_win)
+               return NULL;
+       self = G_OBJECT(g_object_new(MODEST_TYPE_EDITOR_WINDOW, NULL));
+       priv = MODEST_EDITOR_WINDOW_GET_PRIVATE(self);
+
+       return priv->user_data;
+}
+
+
+gboolean modest_editor_window_set_to_header(ModestEditorWindow *edit_win, gchar *to)
+{
+       return modest_ui_editor_window_set_to_header(edit_win, to);
+}
diff --git a/src/modest-editor-window.h b/src/modest-editor-window.h
new file mode 100644 (file)
index 0000000..b9a04d6
--- /dev/null
@@ -0,0 +1,51 @@
+/* modest-editor-window.h */
+/* insert (c)/licensing information) */
+
+#ifndef __MODEST_EDITOR_WINDOW_H__
+#define __MODEST_EDITOR_WINDOW_H__
+
+#include <glib-object.h>
+#include <gtk/gtkwindow.h>
+
+#include "modest-ui.h"
+
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_EDITOR_WINDOW             (modest_editor_window_get_type())
+#define MODEST_EDITOR_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_EDITOR_WINDOW,ModestEditorWindow))
+#define MODEST_EDITOR_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_EDITOR_WINDOW,GtkWindow))
+#define MODEST_IS_EDITOR_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_EDITOR_WINDOW))
+#define MODEST_IS_EDITOR_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_EDITOR_WINDOW))
+#define MODEST_EDITOR_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_EDITOR_WINDOW,ModestEditorWindowClass))
+
+typedef struct _ModestEditorWindow      ModestEditorWindow;
+typedef struct _ModestEditorWindowClass ModestEditorWindowClass;
+
+struct _ModestEditorWindow {
+        GtkWindow parent;
+       /* insert public members, if any */
+};
+
+struct _ModestEditorWindowClass {
+       GtkWindowClass parent_class;
+       /* insert signal callback declarations, eg. */
+       /* void (* my_event) (ModestEditorWindow* obj); */
+};
+
+/* member functions */
+GType        modest_editor_window_get_type    (void) G_GNUC_CONST;
+
+
+GtkWindow *modest_editor_window_new         (ModestUI *ui);
+
+/* fill in other public functions, eg.: */
+/*     void       modest_editor_window_do_something (ModestEditorWindow *self, const gchar* param); */
+/*     gboolean   modest_editor_window_has_foo      (ModestEditorWindow *self, gint value); */
+
+gboolean modest_editor_window_set_to_header(ModestEditorWindow *edit_win, gchar *to);
+
+G_END_DECLS
+
+#endif /* __MODEST_EDITOR_WINDOW_H__ */
index d564f35..9731eb1 100644 (file)
@@ -5,7 +5,9 @@
 #define __MODEST_UI_H__
 
 #include <glib-object.h>
+#include <gtk/gtkcontainer.h>
 #include "modest-conf.h"
+// #include "modest-editor-window.h"
 
 G_BEGIN_DECLS
 
@@ -83,6 +85,11 @@ gboolean     modest_ui_new_edit_window (ModestUI *ui,
                                         const gchar* body,
                                         const GSList* att);
 
+
+GtkContainer *modest_ui_new_editor_window (ModestUI *modest_ui, gpointer *user_data);
+
+//gboolean modest_ui_editor_window_set_to_header(ModestEditorWindow *edit_win, gchar *to);
+
 G_END_DECLS
 
 #endif /* __MODEST_UI_H__ */