/*
* This program 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) version 3.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see
*
*
* Authors:
* Miguel de Icaza
* Federico Mena-Quintero
* Seth Alves
* JP Rosevear
* Nathan Owens
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include
#include
#include "memo-page.h"
#include "cancel-comp.h"
#include "memo-editor.h"
struct _MemoEditorPrivate {
MemoPage *memo_page;
gboolean updating;
};
/* Extends the UI definition in CompEditor */
static const gchar *ui =
""
" "
" "
" "
" "
"";
G_DEFINE_TYPE (MemoEditor, memo_editor, TYPE_COMP_EDITOR)
static void
memo_editor_show_categories (CompEditor *editor,
gboolean visible)
{
MemoEditorPrivate *priv;
priv = MEMO_EDITOR (editor)->priv;
memo_page_set_show_categories (priv->memo_page, visible);
}
static void
memo_editor_dispose (GObject *object)
{
MemoEditorPrivate *priv;
priv = MEMO_EDITOR (object)->priv;
if (priv->memo_page) {
g_object_unref (priv->memo_page);
priv->memo_page = NULL;
}
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (memo_editor_parent_class)->dispose (object);
}
static void
memo_editor_constructed (GObject *object)
{
MemoEditorPrivate *priv;
CompEditor *editor;
priv = MEMO_EDITOR (object)->priv;
editor = COMP_EDITOR (object);
priv->memo_page = memo_page_new (editor);
comp_editor_append_page (
editor, COMP_EDITOR_PAGE (priv->memo_page),
_("Memo"), TRUE);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (memo_editor_parent_class)->constructed (object);
}
static void
memo_editor_class_init (MemoEditorClass *class)
{
GObjectClass *object_class;
CompEditorClass *editor_class;
g_type_class_add_private (class, sizeof (MemoEditorPrivate));
object_class = G_OBJECT_CLASS (class);
object_class->dispose = memo_editor_dispose;
object_class->constructed = memo_editor_constructed;
/* TODO Add a help section for memos. */
editor_class = COMP_EDITOR_CLASS (class);
/*editor_class->help_section = "usage-calendar-memo";*/
editor_class->show_categories = memo_editor_show_categories;
}
/* Object initialization function for the memo editor */
static void
memo_editor_init (MemoEditor *me)
{
CompEditor *editor = COMP_EDITOR (me);
GtkUIManager *ui_manager;
GtkAction *action;
const gchar *id;
GError *error = NULL;
me->priv = G_TYPE_INSTANCE_GET_PRIVATE (
me, TYPE_MEMO_EDITOR, MemoEditorPrivate);
me->priv->updating = FALSE;
ui_manager = comp_editor_get_ui_manager (editor);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
id = "org.gnome.evolution.memo-editor";
e_plugin_ui_register_manager (ui_manager, id, me);
e_plugin_ui_enable_manager (ui_manager, id);
if (error != NULL) {
g_critical ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
}
action = comp_editor_get_action (editor, "print");
gtk_action_set_tooltip (action, _("Print this memo"));
}
/**
* memo_editor_new:
* @client: an #ECalClient
*
* Creates a new event editor dialog.
*
* Return value: A newly-created event editor dialog, or NULL if the event
* editor could not be created.
**/
CompEditor *
memo_editor_new (ECalClient *client,
EShell *shell,
CompEditorFlags flags)
{
g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
return g_object_new (
TYPE_MEMO_EDITOR,
"client", client, "flags", flags, "shell", shell, NULL);
}