aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/memo-editor.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2008-07-19 00:23:26 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-07-19 00:23:26 +0800
commit0597b877c5bf4d21ac4048742ddf6b11e24877ba (patch)
tree74501a98fdec4d2c11d26a1f1d7d43a3058ad6f5 /calendar/gui/dialogs/memo-editor.c
parent68d73b10b22a2ba0e022b812321bc435e04c4867 (diff)
downloadgsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.gz
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.bz2
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.lz
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.xz
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.tar.zst
gsoc2013-evolution-0597b877c5bf4d21ac4048742ddf6b11e24877ba.zip
** Fixes bug #542125
2008-07-18 Matthew Barnes <mbarnes@redhat.com> ** Fixes bug #542125 ** This set of changes migrates CompEditor, CompEditorPage and the various subclasses from using BonoboUI to GtkUIManager for menus and toolbars. It also substantially cleans up the code and streamlines the CompEditorPage API, making more effective use of GObject properties. Core changes: * gui/dialogs/comp-editor-page.c: * gui/dialogs/comp-editor-page.h: * gui/dialogs/comp-editor.c: * gui/dialogs/comp-editor.h: * gui/dialogs/event-editor.c: * gui/dialogs/event-editor.h: * gui/dialogs/event-page.c: * gui/dialogs/event-page.h: * gui/dialogs/memo-editor.c: * gui/dialogs/memo-editor.h: * gui/dialogs/memo-page.c: * gui/dialogs/memo-page.h: * gui/dialogs/recurrence-page.c: * gui/dialogs/recurrence-page.h: * gui/dialogs/schedule-page.c: * gui/dialogs/schedule-page.h: * gui/dialogs/task-details-page.c: * gui/dialogs/task-details-page.h: * gui/dialogs/task-editor.c: * gui/dialogs/task-editor.h: * gui/dialogs/task-page.c: * gui/dialogs/task-page.h: Supporting changes: * gui/calendar-component.c: * gui/comp-editor-factory.c: * gui/e-cal-popup.c: * gui/e-calendar-table.c: * gui/e-calendar-view.c: * gui/e-comp-editor-registry.c: * gui/e-memo-table.c: * gui/e-tasks.c: * gui/gnome-cal.c: * gui/memos-component.c: * gui/tasks-component.c: * gui/dialogs/alarm-dialog.c: * gui/dialogs/comp-editor-util.c: * art/Makefile.am: Move query-free-busy.png to data/icons. svn path=/trunk/; revision=35753
Diffstat (limited to 'calendar/gui/dialogs/memo-editor.c')
-rw-r--r--calendar/gui/dialogs/memo-editor.c276
1 files changed, 68 insertions, 208 deletions
diff --git a/calendar/gui/dialogs/memo-editor.c b/calendar/gui/dialogs/memo-editor.c
index f3f211d430..a4c73e8dee 100644
--- a/calendar/gui/dialogs/memo-editor.c
+++ b/calendar/gui/dialogs/memo-editor.c
@@ -32,252 +32,113 @@
#include <glade/glade.h>
#include <glib/gi18n.h>
-#include <evolution-shell-component-utils.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 "../calendar-config.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;
};
-static void memo_editor_set_e_cal (CompEditor *editor, ECal *client);
-static void memo_editor_edit_comp (CompEditor *editor, ECalComponent *comp);
-static gboolean memo_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method);
-static void memo_editor_finalize (GObject *object);
+/* 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)
-
-
-/**
- * memo_editor_get_type:
- *
- * Registers the #MemoEditor class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #MemoEditor class.
- **/
-
-/* Class initialization function for the event editor */
static void
-memo_editor_class_init (MemoEditorClass *klass)
+memo_editor_show_categories (CompEditor *editor,
+ gboolean visible)
{
- GObjectClass *object_class;
- CompEditorClass *editor_class;
-
- object_class = (GObjectClass *) klass;
- editor_class = (CompEditorClass *) klass;
-
- editor_class->set_e_cal = memo_editor_set_e_cal;
- editor_class->edit_comp = memo_editor_edit_comp;
- editor_class->send_comp = memo_editor_send_comp;
+ MemoEditorPrivate *priv;
- object_class->finalize = memo_editor_finalize;
-}
+ priv = MEMO_EDITOR_GET_PRIVATE (editor);
-static void
-init_widgets (MemoEditor *me)
-{
+ memo_page_set_show_categories (priv->memo_page, visible);
}
static void
-client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data)
+memo_editor_dispose (GObject *object)
{
-/* set_menu_sens (MEMO_EDITOR (user_data)); */
-}
-
-static void
-menu_show_categories_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- MemoEditor *me = (MemoEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
-
- memo_page_set_show_categories (me->priv->memo_page, atoi(state));
- calendar_config_set_show_categories (atoi(state));
-}
+ MemoEditorPrivate *priv;
-static void
-menu_class_public_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- MemoEditor *me = (MemoEditor *) user_data;
+ priv = MEMO_EDITOR_GET_PRIVATE (object);
- if (state[0] == '0')
- return;
+ if (priv->memo_page) {
+ g_object_unref (priv->memo_page);
+ priv->memo_page = NULL;
+ }
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (me->priv->memo_page));
- memo_page_set_classification (me->priv->memo_page, E_CAL_COMPONENT_CLASS_PUBLIC);
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (memo_editor_parent_class)->dispose (object);
}
static void
-menu_class_private_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+memo_editor_class_init (MemoEditorClass *class)
{
- MemoEditor *me = (MemoEditor *) user_data;
- if (state[0] == '0')
- return;
+ GObjectClass *object_class;
+ CompEditorClass *editor_class;
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (me->priv->memo_page));
- memo_page_set_classification (me->priv->memo_page, E_CAL_COMPONENT_CLASS_PRIVATE);
-}
+ g_type_class_add_private (class, sizeof (MemoEditorPrivate));
-static void
-menu_class_confidential_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- MemoEditor *me = (MemoEditor *) user_data;
- if (state[0] == '0')
- return;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = memo_editor_dispose;
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (me->priv->memo_page));
- memo_page_set_classification (me->priv->memo_page, E_CAL_COMPONENT_CLASS_CONFIDENTIAL);
+ /* 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)
{
- MemoEditorPrivate *priv;
- CompEditor *editor = COMP_EDITOR(me);
- gboolean status;
- char *xmlfile;
-
- priv = g_new0 (MemoEditorPrivate, 1);
- me->priv = priv;
-
- priv->updating = FALSE;
-
- bonobo_ui_component_freeze (editor->uic, NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR, "evolution-memo-editor.xml", NULL);
- bonobo_ui_util_set_ui (editor->uic, PREFIX,
- xmlfile,
- "evolution-memo-editor", NULL);
- g_free (xmlfile);
-
- status = calendar_config_get_show_categories ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewCategories",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewCategories",
- menu_show_categories_cb, editor);
-
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ActionClassPublic",
- "state", "1", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassPublic",
- menu_class_public_cb, editor);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassPrivate",
- menu_class_private_cb, editor);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassConfidential",
- menu_class_confidential_cb, editor);
-
- bonobo_ui_component_thaw (editor->uic, NULL);
-
- /* TODO add help stuff */
-/* comp_editor_set_help_section (COMP_EDITOR (me), "usage-calendar-memo"); */
-}
-
-MemoEditor *
-memo_editor_construct (MemoEditor *me, ECal *client)
-{
- MemoEditorPrivate *priv;
CompEditor *editor = COMP_EDITOR (me);
- gboolean read_only = FALSE;
- guint32 flags = comp_editor_get_flags (editor);
-
- priv = me->priv;
-
- priv->memo_page = memo_page_new (editor->uic, flags);
- g_object_ref_sink (priv->memo_page);
- comp_editor_append_page (COMP_EDITOR (me),
- COMP_EDITOR_PAGE (priv->memo_page),
- _("Memo"), TRUE);
- g_signal_connect (G_OBJECT (priv->memo_page), "client_changed",
- G_CALLBACK (client_changed_cb), me);
-
- if (!e_cal_is_read_only (client, &read_only, NULL))
- read_only = TRUE;
-
- bonobo_ui_component_set_prop (editor->uic, "/Toolbar/ecal3", "hidden", "1", NULL);
- comp_editor_set_e_cal (COMP_EDITOR (me), client);
-
-
-
- init_widgets (me);
-
- return me;
-}
-
-static void
-memo_editor_set_e_cal (CompEditor *editor, ECal *client)
-{
- if (COMP_EDITOR_CLASS (memo_editor_parent_class)->set_e_cal)
- COMP_EDITOR_CLASS (memo_editor_parent_class)->set_e_cal (editor, client);
-}
-
-static void
-memo_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
-{
- if (COMP_EDITOR_CLASS (memo_editor_parent_class)->edit_comp)
- COMP_EDITOR_CLASS (memo_editor_parent_class)->edit_comp (editor, comp);
-}
-
-static gboolean
-memo_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method)
-{
- if (COMP_EDITOR_CLASS (memo_editor_parent_class)->send_comp)
- return COMP_EDITOR_CLASS (memo_editor_parent_class)->send_comp (editor, method);
-
- return FALSE;
-}
-
-/* Destroy handler for the event editor */
-static void
-memo_editor_finalize (GObject *object)
-{
- MemoEditor *me;
- MemoEditorPrivate *priv;
+ GtkUIManager *manager;
+ GError *error = NULL;
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_MEMO_EDITOR (object));
+ me->priv = MEMO_EDITOR_GET_PRIVATE (me);
+ me->priv->updating = FALSE;
- me = MEMO_EDITOR (object);
- priv = me->priv;
+ 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 (priv->memo_page) {
- g_object_unref (priv->memo_page);
- priv->memo_page = NULL;
+ if (error != NULL) {
+ g_critical ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
}
- g_free (priv);
-
- if (G_OBJECT_CLASS (memo_editor_parent_class)->finalize)
- (* G_OBJECT_CLASS (memo_editor_parent_class)->finalize) (object);
+ me->priv->memo_page = memo_page_new (editor);
+ g_object_ref_sink (me->priv->memo_page);
+ comp_editor_append_page (
+ COMP_EDITOR (me),
+ COMP_EDITOR_PAGE (me->priv->memo_page),
+ _("Memo"), TRUE);
}
/**
@@ -289,13 +150,12 @@ memo_editor_finalize (GObject *object)
* Return value: A newly-created event editor dialog, or NULL if the event
* editor could not be created.
**/
-MemoEditor *
+CompEditor *
memo_editor_new (ECal *client, CompEditorFlags flags)
{
- MemoEditor *me;
+ g_return_val_if_fail (E_IS_CAL (client), NULL);
- me = g_object_new (TYPE_MEMO_EDITOR, NULL);
- comp_editor_set_flags (COMP_EDITOR (me), flags);
- return memo_editor_construct (me, client);
+ return g_object_new (
+ TYPE_MEMO_EDITOR,
+ "flags", flags, "client", client, NULL);
}
-