aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/memo-editor.c
blob: 4fbf35d91615d1b8de9aa5f95b373dc833f365c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * 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 <http://www.gnu.org/licenses/>  
 *
 *
 * Authors:
 *      Miguel de Icaza <miguel@ximian.com>
 *      Federico Mena-Quintero <federico@ximian.com>
 *      Seth Alves <alves@hungry.com>
 *      JP Rosevear <jpr@ximian.com>
 *      Nathan Owens <pianocomp81@yahoo.com>
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <glade/glade.h>
#include <glib/gi18n.h>

#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
#include <evolution-shell-component-utils.h>

#include "memo-page.h"
#include "cancel-comp.h"
#include "memo-editor.h"

#define MEMO_EDITOR_GET_PRIVATE(obj) \
    (G_TYPE_INSTANCE_GET_PRIVATE \
    ((obj), TYPE_MEMO_EDITOR, MemoEditorPrivate))

struct _MemoEditorPrivate {
    MemoPage *memo_page;

    gboolean updating;
};

/* Extends the UI definition in CompEditor */
static const gchar *ui =
"<ui>"
"  <menubar action='main-menu'>"
"    <menu action='view-menu'>"
"      <menuitem action='view-categories'/>"
"    </menu>"
"    <menu action='options-menu'>"
"      <menu action='classification-menu'>"
"        <menuitem action='classify-public'/>"
"        <menuitem action='classify-private'/>"
"        <menuitem action='classify-confidential'/>"
"      </menu>"
"    </menu>"
"  </menubar>"
"</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_GET_PRIVATE (editor);

    memo_page_set_show_categories (priv->memo_page, visible);
}

static void
memo_editor_dispose (GObject *object)
{
    MemoEditorPrivate *priv;

    priv = MEMO_EDITOR_GET_PRIVATE (object);

    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_GET_PRIVATE (object);
    editor = COMP_EDITOR (object);

    priv->memo_page = memo_page_new (editor);
    comp_editor_append_page (
        editor, COMP_EDITOR_PAGE (priv->memo_page),
        _("Memo"), TRUE);
}

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 *manager;
    GError *error = NULL;

    me->priv = MEMO_EDITOR_GET_PRIVATE (me);
    me->priv->updating = FALSE;

    manager = comp_editor_get_ui_manager (editor);
    gtk_ui_manager_add_ui_from_string (manager, ui, -1, &error);
    e_plugin_ui_register_manager ("memo-editor", manager, me);

    if (error != NULL) {
        g_critical ("%s: %s", G_STRFUNC, error->message);
        g_error_free (error);
    }
}

/**
 * memo_editor_new:
 * @client: an ECal
 *
 * 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 (ECal *client, CompEditorFlags flags)
{
    g_return_val_if_fail (E_IS_CAL (client), NULL);

    return g_object_new (
        TYPE_MEMO_EDITOR,
        "flags", flags, "client", client, NULL);
}