diff options
author | Federico Mena Quintero <federico@src.gnome.org> | 2001-05-31 03:55:26 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-05-31 03:55:26 +0800 |
commit | 859c5d4573a55bc23492076068489e52a1f2debd (patch) | |
tree | c85a59f02fe373651d7b21f49d3a2510ea4ba569 /calendar/gui | |
parent | 225120f19f7e03a09f1ff899e747e68ccc41a93e (diff) | |
download | gsoc2013-evolution-859c5d4573a55bc23492076068489e52a1f2debd.tar.gz gsoc2013-evolution-859c5d4573a55bc23492076068489e52a1f2debd.tar.zst gsoc2013-evolution-859c5d4573a55bc23492076068489e52a1f2debd.zip |
For JPR - Federico
svn path=/trunk/; revision=10053
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 195 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.h | 61 |
2 files changed, 256 insertions, 0 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c new file mode 100644 index 0000000000..f101bfa15a --- /dev/null +++ b/calendar/gui/dialogs/comp-editor.c @@ -0,0 +1,195 @@ +/* Evolution calendar - Framework for a calendar component editor dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Author: Federico Mena-Quintero <federico@ximian.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "comp-editor.h" + + + +/* Private part of the CompEditor structure */ +struct _CompEditorPrivate { + /* The pages we have */ + GList *pages; + + /* Toplevel window for the dialog */ + GtkWidget *window; + + /* Notebook to hold the pages */ + GtkNotebook *notebook; +}; + + + +static void comp_editor_class_init (CompEditorClass *class); +static void comp_editor_init (CompEditor *editor); +static void comp_editor_destroy (GtkObject *object); + +static GtkObjectClass *parent_class; + + + +GtkType +comp_editor_get_type (void) +{ + static GtkType comp_editor_type; + + if (!comp_editor_type) { + static const GtkTypeInfo comp_editor_info = { + "CompEditor", + sizeof (CompEditor), + sizeof (CompEditorClass), + (GtkClassInitFunc) comp_editor_class_init, + (GtkObjectInitfunc) comp_editor_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + } + + comp_editor_type = gtk_type_unique (GTK_TYPE_OBJECT, &comp_editor_info); + } + + return comp_editor_type; +} + +/* Class initialization function for the calendar component editor */ +static void +comp_editor_class_init (CompEditorClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *) class; + + parent_class = gtk_type_class (GTK_TYPE_OBJECT); + + object_class->destroy = comp_editor_destroy; +} + +/* Creates the basic in the editor */ +static void +setup_widgets (CompEditor *editor) +{ + CompEditorPrivate *priv; + GtkWidget *vbox; + GtkWidget *bbox; + GtkWidget *pixmap; + GtkWidget *button; + + priv = editor->priv; + + /* Window and basic vbox */ + + priv->window = gtk_window_new (GTK_WINDOW_DIALOG); + gtk_signal_connect (GTK_OBJECT (priv->window), "delete_event", + GTK_SIGNAL_FUNC (delete_event_cb), editor); + + vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); + gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); + gtk_container_add (GTK_CONTAINER (priv->window), vbox); + + /* Notebook */ + + priv->notebook = GTK_NOTEBOOK (gtk_notebook_new ()); + gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0); + + /* Buttons */ + + bbox = gtk_hbutton_box_new (); + gtk_hbutton_box_set_layout_default (GTK_HBUTTON_BOX (bbox), GTK_BUTTONBOX_END); + gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); + + pixmap = gnome_stock_pixmap_widget (NULL, GNOME_STOCK_PIXMAP_SAVE); + button = gnome_pixmap_button (pixmap, _("Save")); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); + + button = gnome_stock_button (GNOME_STOCK_BUTTON_CLOSE); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); + + button = gnome_stock_button (GNOME_STOCK_BUTTON_HELP); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); +} + +/* Object initialization function for the calendar component editor */ +static void +comp_editor_init (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = g_new0 (CompEditorPrivate, 1); + editor->priv = priv; + + setup_widgets (editor); + + priv->pages = NULL; +} + +/* Destroy handler for the calendar component editor */ +static void +comp_editor_destroy (GtkObject *object) +{ + CompEditor *editor; + CompEditorPrivate *priv; + + editor = COMP_EDITOR (object); + priv = editor->priv; + + if (priv->window) { + gtk_widget_destroy (priv->window); + priv->window = NULL; + } + + g_free (priv); + editor->priv = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + + +void +comp_editor_append_page (CompEditor *editor, EditorPage *page, const char *label) +{ + CompEditorPrivate *priv; + GtkWidget *page_widget; + GtkWidget *label_widget; + + g_return_if_fail (editor != NULL); + g_return_if_fail (IS_COMP_EDITOR (editor)); + g_return_if_fail (page != NULL); + g_return_if_fail (IS_EDITOR_PAGE (page)); + g_return_if_fail (label != NULL); + + priv = editor->priv; + + /* Only allow adding the pages while a component has not been set */ + g_return_if_fail (priv->comp == NULL); + + page_widget = editor_page_get_widget (page); + g_assert (page_widget != NULL); + + label_widget = gtk_label_new (label); + + priv->pages = g_list_append (priv->pages, page); + gtk_notebook_append_page (priv->notebook, page_widget, label_widget); +} diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h new file mode 100644 index 0000000000..2362c1d012 --- /dev/null +++ b/calendar/gui/dialogs/comp-editor.h @@ -0,0 +1,61 @@ +/* Evolution calendar - Framework for a calendar component editor dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Author: Federico Mena-Quintero <federico@ximian.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef COMP_EDITOR_H +#define COMP_EDITOR_H + +#include "editor-page.h" + +BEGIN_GNOME_DECLS + + + +#define TYPE_COMP_EDITOR (comp_editor_get_type ()) +#define COMP_EDITOR(obj) (GTK_CHECK_CAST ((obj), TYPE_COMP_EDITOR, CompEditor)) +#define COMP_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_COMP_EDITOR, \ + CompEditorClass)) +#define IS_COMP_EDITOR(obj) (GTK_CHECK_TYPE ((obj), TYPE_COMP_EDITOR)) +#define IS_COMP_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_COMP_EDITOR)) + +typedef struct _CompEditorPrivate CompEditorPrivate; + +typedef struct { + GtkObject object; + + /* Private data */ + CompEditorPrivate *priv; +} CompEditor; + +typedef struct { + GtkObjectClass parent_class; +} CompEditorClass; + +GtkType comp_editor_get_type (void); + +CompEditor *comp_editor_new (void); + +void comp_editor_add_page (CompEditor *editor, EditorPage *page); + + + +END_GNOME_DECLS + +#endif |