/* TMut * Copyright (C) 2006-2007 Philip Van Hoof * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with self library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #if HAVE_CONFIG_H #include "config.h" #endif #include #include "tmut-header-view.h" #include "tmut-shell-window.h" #include "tmut-shell-child.h" #include static GObjectClass *parent_class = NULL; typedef struct _TMutHeaderViewPriv TMutHeaderViewPriv; struct _TMutHeaderViewPriv { TMutShellWindow *shell; TnyHeaderView *header_view; GtkScrolledWindow *sw; GtkWidget *expander, *subject; }; #define TMUT_HEADER_VIEW_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), TMUT_TYPE_HEADER_VIEW, TMutHeaderViewPriv)) static void tmut_header_view_set_header (TnyHeaderView *self, TnyHeader *header) { TMutHeaderViewPriv *priv = TMUT_HEADER_VIEW_GET_PRIVATE (self); if (header) { gchar *str = tny_header_dup_subject (header); gtk_label_set_text (GTK_LABEL (priv->subject), str); g_free (str); } else gtk_label_set_text (GTK_LABEL (priv->subject), ""); tny_header_view_set_header (priv->header_view, header); return; } static void tmut_header_view_clear (TnyHeaderView *self) { TMutHeaderViewPriv *priv = TMUT_HEADER_VIEW_GET_PRIVATE (self); gtk_label_set_text (GTK_LABEL (priv->subject), ""); tny_header_view_clear (priv->header_view); return; } /** * tmut_header_view_new: * Create a GtkWindow that implements #TnyHeaderView * * Return value: a new #TnyHeaderView instance implemented for Gtk+ **/ TnyHeaderView* tmut_header_view_new (void) { TMutHeaderView *self = g_object_new (TMUT_TYPE_HEADER_VIEW, NULL); return TNY_HEADER_VIEW (self); } static void tmut_header_view_instance_init (GTypeInstance *instance, gpointer g_class) { TMutHeaderViewPriv *priv = TMUT_HEADER_VIEW_GET_PRIVATE (instance); GtkWidget *label = gtk_label_new (_("Subject:")); GtkWidget *hbox = gtk_hbox_new (FALSE, 0); priv->expander = gtk_expander_new (""); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); priv->subject = gtk_label_new (""); gtk_box_pack_start (GTK_BOX (hbox), priv->subject, FALSE, TRUE, 0); gtk_expander_set_label_widget (GTK_EXPANDER (priv->expander), hbox); gtk_widget_show (priv->expander); gtk_widget_show (hbox); gtk_widget_show (label); gtk_widget_show (priv->subject); gtk_box_pack_start (GTK_BOX (instance), GTK_WIDGET (priv->expander), TRUE, TRUE, 0); priv->header_view = tny_gtk_header_view_new (); gtk_container_add (GTK_CONTAINER (priv->expander), GTK_WIDGET (priv->header_view)); gtk_widget_show (GTK_WIDGET (priv->header_view)); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (priv->subject), 0, 0.5); return; } static void tmut_header_view_finalize (GObject *object) { (*parent_class->finalize) (object); return; } static void tmut_header_view_class_init (TMutHeaderViewClass *class) { GObjectClass *object_class; parent_class = g_type_class_peek_parent (class); object_class = (GObjectClass*) class; object_class->finalize = tmut_header_view_finalize; g_type_class_add_private (object_class, sizeof (TMutHeaderViewPriv)); return; } static void tny_header_view_init (gpointer g, gpointer iface_data) { TnyHeaderViewIface *klass = (TnyHeaderViewIface *)g; klass->set_header= tmut_header_view_set_header; klass->clear= tmut_header_view_clear; return; } GType tmut_header_view_get_type (void) { static GType type = 0; if (G_UNLIKELY(type == 0)) { static const GTypeInfo info = { sizeof (TMutHeaderViewClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) tmut_header_view_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ sizeof (TMutHeaderView), 0, /* n_preallocs */ tmut_header_view_instance_init, /* instance_init */ NULL }; static const GInterfaceInfo tny_header_view_info = { (GInterfaceInitFunc) tny_header_view_init, /* interface_init */ NULL, /* interface_finalize */ NULL /* interface_data */ }; type = g_type_register_static (GTK_TYPE_VBOX, "TMutHeaderView", &info, 0); g_type_add_interface_static (type, TNY_TYPE_HEADER_VIEW, &tny_header_view_info); } return type; }