aboutsummaryrefslogtreecommitdiffstats
path: root/notes
diff options
context:
space:
mode:
Diffstat (limited to 'notes')
-rw-r--r--notes/GNOME_Evolution_Notes.oaf.in54
-rw-r--r--notes/GNOME_Evolution_Notes.oafinfo54
-rw-r--r--notes/Makefile.am58
-rw-r--r--notes/component-factory.c150
-rw-r--r--notes/component-factory.h7
-rw-r--r--notes/e-bevel-button-util.c189
-rw-r--r--notes/e-bevel-button-util.h12
-rw-r--r--notes/e-bevel-button.c175
-rw-r--r--notes/e-bevel-button.h37
-rw-r--r--notes/e-note.c380
-rw-r--r--notes/e-note.h37
-rw-r--r--notes/evolution-notes.oafinfo54
-rw-r--r--notes/main.c52
-rw-r--r--notes/test-notes.c34
14 files changed, 1293 insertions, 0 deletions
diff --git a/notes/GNOME_Evolution_Notes.oaf.in b/notes/GNOME_Evolution_Notes.oaf.in
new file mode 100644
index 0000000000..704b4028d8
--- /dev/null
+++ b/notes/GNOME_Evolution_Notes.oaf.in
@@ -0,0 +1,54 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Notes control"/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:control:evolution-notes:8e3fb723-aada-4112-99db-d51779e35a2a"
+ type="factory"
+ location="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Control:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="A sample Bonobo control which displays an addressbook."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Evolution notes component."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component:evolution-notes:92d95b91-3655-4746-ac68-01b21e2c5e44"
+ type="factory"
+ location="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution/ShellComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution component for handling mail."/>
+
+</oaf_server>
+
+</oaf_info>
diff --git a/notes/GNOME_Evolution_Notes.oafinfo b/notes/GNOME_Evolution_Notes.oafinfo
new file mode 100644
index 0000000000..704b4028d8
--- /dev/null
+++ b/notes/GNOME_Evolution_Notes.oafinfo
@@ -0,0 +1,54 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Notes control"/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:control:evolution-notes:8e3fb723-aada-4112-99db-d51779e35a2a"
+ type="factory"
+ location="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Control:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="A sample Bonobo control which displays an addressbook."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Evolution notes component."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component:evolution-notes:92d95b91-3655-4746-ac68-01b21e2c5e44"
+ type="factory"
+ location="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution/ShellComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution component for handling mail."/>
+
+</oaf_server>
+
+</oaf_info>
diff --git a/notes/Makefile.am b/notes/Makefile.am
new file mode 100644
index 0000000000..c24c2590ce
--- /dev/null
+++ b/notes/Makefile.am
@@ -0,0 +1,58 @@
+bin_PROGRAMS = evolution-notes
+
+noinst_PROGRAMS = notes-test
+
+INCLUDES = \
+ -I$(top_builddir)/shell \
+ -I$(top_srcdir)/shell \
+ -I$(top_srcdir)/widgets/e-text \
+ $(BONOBO_HTML_GNOME_CFLAGS) \
+ -DEVOLUTION_VERSION=\""$(VERSION)"\" \
+ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
+ -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \
+ -DEVOLUTION_LOCALEDIR=\""$(datadir)/locale"\" \
+ -DEVOLUTION_DATADIR=\""$(datadir)"\" \
+ -DG_LOG_DOMAIN=\"evolution-notes\"
+
+# FIXME We should make a libeshell library instead of this gross hack.
+SHELL_OBJS = \
+ $(top_builddir)/shell/Evolution-common.o \
+ $(top_builddir)/shell/Evolution-stubs.o \
+ $(top_builddir)/shell/Evolution-skels.o \
+ $(top_builddir)/shell/evolution-shell-component.o \
+ $(top_builddir)/shell/evolution-storage.o
+
+evolution_notes_SOURCES = \
+ component-factory.c \
+ main.c \
+ notes.c
+
+notes_test_SOURCES = \
+ e-bevel-button.c \
+ e-bevel-button.h \
+ e-bevel-button-util.c \
+ e-bevel-button-util.h \
+ e-note.c \
+ e-note.h \
+ test-notes.c
+
+OAF_FILES = evolution-notes.oafinfo
+
+if USING_OAF
+oafdir = $(datadir)/oaf
+oaf_DATA = $(OAF_FILES)
+endif
+
+notes_test_LDADD = \
+ $(top_builddir)/widgets/e-text/libetext.a \
+ ../e-util/libeutil.la \
+ $(BONOBO_HTML_GNOME_LIBS)
+
+evolution_notes_LDADD = \
+ ../e-util/libeutil.la \
+ $(SHELL_OBJS) \
+ $(BONOBO_HTML_GNOME_LIBS)
+
+
+
+
diff --git a/notes/component-factory.c b/notes/component-factory.c
new file mode 100644
index 0000000000..5e9cae24f5
--- /dev/null
+++ b/notes/component-factory.c
@@ -0,0 +1,150 @@
+#include <config.h>
+
+#include <gnome.h>
+#include <bonobo.h>
+
+#include "Evolution.h"
+#include "evolution-storage.h"
+
+#include "evolution-shell-component.h"
+
+#include "e-util/e-gui-utils.h"
+
+#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772"
+
+static const EvolutionShellComponentFolderType folder_types[] = {
+ { "notes", "evolution-notes.png" },
+ { NULL, NULL }
+};
+
+static void
+new_note_cb (BonoboUIHandler *uih, void *user_data, const char *path)
+{
+ g_print ("new note!\n");
+}
+
+static GnomeUIInfo gnome_toolbar [] = {
+ GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new note"), new_note_cb, GNOME_STOCK_PIXMAP_NEW),
+ GNOMEUIINFO_END
+};
+
+static void
+control_deactivate (BonoboControl *control, BonoboUIHandler *uih)
+{
+ bonobo_ui_handler_dock_remove (uih, "/Toolbar");
+}
+
+static void
+control_activate (BonoboControl *control, BonoboUIHandler *uih)
+{
+ Bonobo_UIHandler remote_uih;
+ GtkWidget *toolbar, *toolbar_frame;
+ BonoboControl *toolbar_control ;
+
+ remote_uih = bonobo_control_get_remote_ui_handler (control);
+ bonobo_ui_handler_set_container (uih, remote_uih);
+
+ toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL,
+ GTK_TOOLBAR_BOTH);
+
+ gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar),
+ gnome_toolbar,
+ NULL, NULL);
+
+ toolbar_frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (toolbar_frame), GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (toolbar_frame), toolbar);
+ gtk_widget_show (toolbar_frame);
+
+ gtk_widget_show_all (toolbar_frame);
+
+ toolbar_control = bonobo_control_new (toolbar_frame);
+ bonobo_ui_handler_dock_add (
+ uih, "/Toolbar",
+ bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)),
+ GNOME_DOCK_ITEM_BEH_EXCLUSIVE,
+ GNOME_DOCK_TOP,
+ 1, 1, 0);
+}
+
+
+static void
+control_activate_cb (BonoboControl *control,
+ gboolean activate)
+{
+ BonoboUIHandler *uih;
+
+ uih = bonobo_control_get_ui_handler (control);
+ g_assert (uih);
+
+ if (activate)
+ control_activate (control, uih);
+ else
+ control_deactivate (control, uih);
+}
+
+
+static BonoboControl *
+create_view (EvolutionShellComponent *shell_component,
+ const char *physical_uri,
+ void *closure)
+{
+ BonoboControl * control;
+
+ control = notes_factory_new_control ();
+
+ gtk_signal_connect (GTK_OBJECT (control), "activate",
+ control_activate_cb, NULL);
+
+
+ return control;
+}
+
+static void
+owner_set_cb (EvolutionShellComponent *shell_component,
+ Evolution_Shell shell_interface,
+ gpointer user_data)
+{
+ g_print ("evolution-notes: Yeeeh! We have an owner!\n"); /* FIXME */
+}
+
+static void
+owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data)
+{
+ g_print ("No owner anymore\n");
+}
+
+/* The factory function */
+static BonoboObject *
+notes_component_factory (BonoboGenericFactory *factory,
+ void *closure)
+{
+ EvolutionShellComponent *shell_component;
+
+ shell_component = evolution_shell_component_new (folder_types, create_view, NULL);
+
+ gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set",
+ GTK_SIGNAL_FUNC (owner_set_cb), NULL);
+ gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset",
+ GTK_SIGNAL_FUNC (owner_unset_cb), NULL);
+
+ return BONOBO_OBJECT (shell_component);
+}
+
+
+void
+component_factory_init (void)
+{
+ static BonoboGenericFactory *factory = NULL;
+
+ if (factory != NULL)
+ return;
+
+ factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, notes_component_factory, NULL);
+
+ if (factory == NULL) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot initialize Evolution's notes component."));
+ exit (1);
+ }
+}
diff --git a/notes/component-factory.h b/notes/component-factory.h
new file mode 100644
index 0000000000..9535ccc4ae
--- /dev/null
+++ b/notes/component-factory.h
@@ -0,0 +1,7 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+#ifndef COMPONENT_FACTORY_H
+#define COMPONENT_FACTORY_H
+
+void component_factory_init (void);
+
+#endif
diff --git a/notes/e-bevel-button-util.c b/notes/e-bevel-button-util.c
new file mode 100644
index 0000000000..cfa01f71a2
--- /dev/null
+++ b/notes/e-bevel-button-util.c
@@ -0,0 +1,189 @@
+#include <gtk/gtk.h>
+#include "e-bevel-button-util.h"
+
+static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
+static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
+
+void
+e_bevel_button_util_shade (GdkColor *a,
+ GdkColor *b,
+ gdouble k)
+{
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+
+ red = (gdouble) a->red / 65535.0;
+ green = (gdouble) a->green / 65535.0;
+ blue = (gdouble) a->blue / 65535.0;
+
+ rgb_to_hls (&red, &green, &blue);
+
+ green *= k;
+ if (green > 1.0)
+ green = 1.0;
+ else if (green < 0.0)
+ green = 0.0;
+
+ blue *= k;
+ if (blue > 1.0)
+ blue = 1.0;
+ else if (blue < 0.0)
+ blue = 0.0;
+
+ hls_to_rgb (&red, &green, &blue);
+
+ b->red = red * 65535.0;
+ b->green = green * 65535.0;
+ b->blue = blue * 65535.0;
+}
+
+static void
+rgb_to_hls (gdouble *r,
+ gdouble *g,
+ gdouble *b)
+{
+ gdouble min;
+ gdouble max;
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+ gdouble h, l, s;
+ gdouble delta;
+
+ red = *r;
+ green = *g;
+ blue = *b;
+
+ if (red > green)
+ {
+ if (red > blue)
+ max = red;
+ else
+ max = blue;
+
+ if (green < blue)
+ min = green;
+ else
+ min = blue;
+ }
+ else
+ {
+ if (green > blue)
+ max = green;
+ else
+ max = blue;
+
+ if (red < blue)
+ min = red;
+ else
+ min = blue;
+ }
+
+ l = (max + min) / 2;
+ s = 0;
+ h = 0;
+
+ if (max != min)
+ {
+ if (l <= 0.5)
+ s = (max - min) / (max + min);
+ else
+ s = (max - min) / (2 - max - min);
+
+ delta = max -min;
+ if (red == max)
+ h = (green - blue) / delta;
+ else if (green == max)
+ h = 2 + (blue - red) / delta;
+ else if (blue == max)
+ h = 4 + (red - green) / delta;
+
+ h *= 60;
+ if (h < 0.0)
+ h += 360;
+ }
+
+ *r = h;
+ *g = l;
+ *b = s;
+}
+
+static void
+hls_to_rgb (gdouble *h,
+ gdouble *l,
+ gdouble *s)
+{
+ gdouble hue;
+ gdouble lightness;
+ gdouble saturation;
+ gdouble m1, m2;
+ gdouble r, g, b;
+
+ lightness = *l;
+ saturation = *s;
+
+ if (lightness <= 0.5)
+ m2 = lightness * (1 + saturation);
+ else
+ m2 = lightness + saturation - lightness * saturation;
+ m1 = 2 * lightness - m2;
+
+ if (saturation == 0)
+ {
+ *h = lightness;
+ *l = lightness;
+ *s = lightness;
+ }
+ else
+ {
+ hue = *h + 120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ r = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ r = m2;
+ else if (hue < 240)
+ r = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ r = m1;
+
+ hue = *h;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ g = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ g = m2;
+ else if (hue < 240)
+ g = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ g = m1;
+
+ hue = *h - 120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ b = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ b = m2;
+ else if (hue < 240)
+ b = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ b = m1;
+
+ *h = r;
+ *l = g;
+ *s = b;
+ }
+}
diff --git a/notes/e-bevel-button-util.h b/notes/e-bevel-button-util.h
new file mode 100644
index 0000000000..759a9025cc
--- /dev/null
+++ b/notes/e-bevel-button-util.h
@@ -0,0 +1,12 @@
+#ifndef __E_BEVEL_BUTTON_UTIL_H__
+#define __E_BEVEL_BUTTON_UTIL_H__
+
+#define LIGHTNESS_MULT 1.3
+#define DARKNESS_MULT 0.7
+
+void
+e_bevel_button_util_shade (GdkColor *a,
+ GdkColor *b,
+ gdouble k);
+
+#endif /* __E_BEVEL_BUTTON_UTIL_H__ */
diff --git a/notes/e-bevel-button.c b/notes/e-bevel-button.c
new file mode 100644
index 0000000000..480a430516
--- /dev/null
+++ b/notes/e-bevel-button.c
@@ -0,0 +1,175 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#include <config.h>
+#include <gtk/gtkbutton.h>
+
+#include "e-util/e-util.h"
+
+#include "e-bevel-button.h"
+#include "e-bevel-button-util.h"
+
+#define PARENT_TYPE GTK_TYPE_BUTTON
+
+static GtkButtonClass *parent_class = NULL;
+
+struct _EBevelButtonPrivate {
+ GdkColor base_color;
+ GdkColor dark_color;
+ GdkColor light_color;
+ GdkGC *gc;
+};
+
+static void
+e_bevel_button_paint (GtkWidget *widget, GdkRectangle *area)
+{
+ EBevelButton *button;
+
+ button = E_BEVEL_BUTTON (widget);
+
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+
+ gdk_gc_set_foreground (button->priv->gc, &button->priv->base_color);
+ gdk_draw_rectangle (widget->window,
+ button->priv->gc,
+ TRUE,
+ 0, 0,
+ widget->allocation.width, widget->allocation.height);
+
+ if (GTK_BUTTON (button)->in_button) {
+ gdk_gc_set_foreground (button->priv->gc,
+ GTK_BUTTON (button)->button_down ?
+ &button->priv->dark_color :
+ &button->priv->light_color);
+ gdk_draw_line (widget->window, button->priv->gc,
+ 0, 0, 0, widget->allocation.height - 2);
+ gdk_draw_line (widget->window, button->priv->gc,
+ 0, 0, widget->allocation.width - 2, 0);
+
+ gdk_gc_set_foreground (button->priv->gc,
+ GTK_BUTTON (button)->button_down ?
+ &button->priv->light_color :
+ &button->priv->dark_color);
+ gdk_draw_line (widget->window, button->priv->gc,
+ widget->allocation.width - 1 , 1,
+ widget->allocation.width - 1, widget->allocation.height - 1);
+ gdk_draw_line (widget->window, button->priv->gc,
+ 1, widget->allocation.height - 1,
+ widget->allocation.width - 1, widget->allocation.height - 1);
+ }
+ }
+}
+
+static gint
+e_bevel_button_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+ GtkBin *bin;
+ GdkEventExpose child_event;
+
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ bin = GTK_BIN (widget);
+
+ e_bevel_button_paint (widget, &event->area);
+
+ child_event = *event;
+ if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) &&
+ gtk_widget_intersect (bin->child, &event->area, &child_event.area))
+ gtk_widget_event (bin->child, (GdkEvent*) &child_event);
+ }
+
+ return FALSE;
+}
+
+static void
+e_bevel_button_draw (GtkWidget *widget, GdkRectangle *area)
+{
+ GdkRectangle child_area;
+ GdkRectangle tmp_area;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (E_IS_BEVEL_BUTTON (widget));
+ g_return_if_fail (area != NULL);
+
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ tmp_area = *area;
+ tmp_area.x -= GTK_CONTAINER (widget)->border_width;
+ tmp_area.y -= GTK_CONTAINER (widget)->border_width;
+
+ e_bevel_button_paint (widget, &tmp_area);
+
+ if (GTK_BIN (widget)->child && gtk_widget_intersect (GTK_BIN (widget)->child, &tmp_area, &child_area))
+ gtk_widget_draw (GTK_BIN (widget)->child, &child_area);
+ }
+}
+
+static void
+e_bevel_button_realize (GtkWidget *widget)
+{
+ EBevelButton *button = E_BEVEL_BUTTON (widget);
+
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
+
+ button->priv->gc = gdk_gc_new (widget->window);
+
+ gdk_color_parse ("#d0d888", &button->priv->base_color);
+ e_bevel_button_util_shade (&button->priv->base_color,
+ &button->priv->light_color,
+ LIGHTNESS_MULT);
+ e_bevel_button_util_shade (&button->priv->base_color,
+ &button->priv->dark_color,
+ DARKNESS_MULT);
+ gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->base_color, FALSE, TRUE);
+ gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->light_color, FALSE, TRUE);
+ gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->dark_color, FALSE, TRUE);
+}
+
+static void
+e_bevel_button_class_init (EBevelButtonClass *klass)
+{
+ GtkWidgetClass *widget_class;
+
+ widget_class = (GtkWidgetClass *)klass;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ widget_class->draw = e_bevel_button_draw;
+ widget_class->expose_event = e_bevel_button_expose;
+ widget_class->realize = e_bevel_button_realize;
+}
+
+static void
+e_bevel_button_init (EBevelButton *button)
+{
+ EBevelButtonPrivate *priv;
+
+ GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
+
+ priv = g_new (EBevelButtonPrivate, 1);
+
+ button->priv = priv;
+}
+
+GtkWidget *
+e_bevel_button_new (void)
+{
+ EBevelButton *button;
+
+ button = gtk_type_new (E_TYPE_BEVEL_BUTTON);
+
+ return GTK_WIDGET (button);
+}
+
+E_MAKE_TYPE (e_bevel_button, "EBevelButton", EBevelButton, e_bevel_button_class_init, e_bevel_button_init, PARENT_TYPE);
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/notes/e-bevel-button.h b/notes/e-bevel-button.h
new file mode 100644
index 0000000000..333c317b43
--- /dev/null
+++ b/notes/e-bevel-button.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+#ifndef __E_BEVEL_BUTTON_H__
+#define __E_BEVEL_BUTTON_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtkbutton.h>
+
+#define E_TYPE_BEVEL_BUTTON (e_bevel_button_get_type ())
+#define E_BEVEL_BUTTON(obj) (GTK_CHECK_CAST ((obj), E_TYPE_BEVEL_BUTTON, EBevelButton))
+#define E_BEVEL_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_BEVEL_BUTTON, EBevelButtonClass))
+#define E_IS_BEVEL_BUTTON(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_BEVEL_BUTTON))
+#define E_IS_BEVEL_BUTTON_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_BEVEL_BUTTON))
+
+typedef struct _EBevelButton EBevelButton;
+typedef struct _EBevelButtonPrivate EBevelButtonPrivate;
+typedef struct _EBevelButtonClass EBevelButtonClass;
+
+struct _EBevelButton {
+ GtkButton parent;
+
+ EBevelButtonPrivate *priv;
+};
+
+struct _EBevelButtonClass {
+ GtkButtonClass parent_class;
+};
+
+GtkType e_bevel_button_get_type (void);
+
+GtkWidget *e_bevel_button_new (void);
+void e_bevel_button_set_base_color (EBevelButton *button, GdkColor *color);
+
+#endif /* __E_BEVEL_BUTTON_H__ */
+
diff --git a/notes/e-note.c b/notes/e-note.c
new file mode 100644
index 0000000000..ea3fd2ebdd
--- /dev/null
+++ b/notes/e-note.c
@@ -0,0 +1,380 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#include <config.h>
+#include <gnome.h>
+#include <gdk/gdkx.h>
+
+#include "e-util/e-canvas.h"
+#include "e-util/e-util.h"
+#include "widgets/e-text/e-text.h"
+
+#include "e-note.h"
+#include "e-bevel-button.h"
+#include "e-bevel-button-util.h"
+
+#define PARENT_TYPE GTK_TYPE_WINDOW
+
+enum {
+ E_NOTE_TEXT_CHANGED,
+ E_NOTE_LAST_SIGNAL
+};
+
+static guint e_note_signals [E_NOTE_LAST_SIGNAL] = { 0 };
+
+static GtkWindowClass *parent_class = NULL;
+
+struct _ENotePrivate {
+ GtkWidget *canvas;
+
+ GnomeCanvasItem *frame;
+ GnomeCanvasItem *rect;
+
+ GnomeCanvasItem *text_item;
+
+ GnomeCanvasItem *move_button;
+ GnomeCanvasItem *close_button;
+ GnomeCanvasItem *resize_button;
+
+ /* Used for moving and resizing */
+ gint press_x, press_y;
+ gint resize_width, resize_height;
+ gboolean in_drag;
+};
+
+static void
+e_note_text_changed (ETextModel *model, gpointer data)
+{
+ gtk_signal_emit (GTK_OBJECT (data),
+ e_note_signals [E_NOTE_TEXT_CHANGED]);
+}
+
+static gint
+e_note_resize_button_changed (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ ENote *note = E_NOTE (data);
+
+ if (event->type == GDK_BUTTON_PRESS) {
+ note->priv->press_x = event->x_root;
+ note->priv->press_y = event->y_root;
+
+ gdk_window_get_geometry (GTK_WIDGET (note)->window, NULL, NULL,
+ &note->priv->resize_width, &note->priv->resize_height, NULL);
+
+ gdk_pointer_grab (widget->window,
+ FALSE,
+ (GDK_BUTTON1_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_RELEASE_MASK),
+ NULL,
+ NULL,
+ GDK_CURRENT_TIME);
+ note->priv->in_drag = TRUE;
+
+ }
+ else {
+ if (note->priv->in_drag) {
+ if (event->window != widget->window)
+ return FALSE;
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ note->priv->in_drag = FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static gint
+e_note_resize_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
+{
+ GtkWidget *window = GTK_WIDGET (data);
+ ENote *note = E_NOTE (data);
+ gint new_x, new_y;
+ gint width, height;
+
+ if (note->priv->in_drag) {
+ gdk_window_get_pointer (GDK_ROOT_PARENT (), &new_x, &new_y, NULL);
+
+ width = note->priv->resize_width + new_x - note->priv->press_x;
+ if (width < 60)
+ width = 60;
+
+ height = note->priv->resize_height + new_y - note->priv->press_y;
+ if (height < 60)
+ height = 60;
+
+ gdk_window_resize (window->window, width, height);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gint
+e_note_move_button_changed (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ ENote *note = E_NOTE (data);
+
+ if (event->button != 1)
+ return FALSE;
+
+ if (event->type == GDK_BUTTON_PRESS) {
+ gint root_x, root_y;
+
+ gdk_window_get_origin (widget->window, &root_x, &root_y);
+ note->priv->press_x = root_x - event->x_root;
+ note->priv->press_y = root_y - event->y_root;
+
+ gdk_pointer_grab (widget->window,
+ FALSE,
+ (GDK_BUTTON1_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_RELEASE_MASK),
+ NULL,
+ NULL,
+ GDK_CURRENT_TIME);
+
+ note->priv->in_drag = TRUE;
+ }
+ else {
+ if (note->priv->in_drag) {
+ if (event->window != widget->window)
+ return FALSE;
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ note->priv->in_drag = FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static gint
+e_note_move_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
+{
+ gint new_x, new_y;
+ ENote *note = E_NOTE (data);
+ GtkWidget *window = GTK_WIDGET (data);
+
+ if (note->priv->in_drag) {
+ gdk_window_get_pointer (GDK_ROOT_PARENT (), &new_x, &new_y, NULL);
+
+ new_x += note->priv->press_x;
+ new_y += note->priv->press_y;
+
+ gdk_window_move (window->window, new_x, new_y);
+ }
+
+ return TRUE;
+}
+
+static void
+e_note_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
+{
+ ENote *note;
+ gdouble height;
+
+ note = E_NOTE (data);
+
+ gnome_canvas_item_set (note->priv->text_item,
+ "width", (gdouble) allocation->width - 10,
+ NULL);
+ gtk_object_get (GTK_OBJECT (note->priv->text_item),
+ "height", &height,
+ NULL);
+ height = MAX (height, allocation->height);
+ gnome_canvas_set_scroll_region (GNOME_CANVAS (note->priv->canvas), 0, 0,
+ allocation->width, height);
+ gnome_canvas_item_set (note->priv->frame,
+ "x2", (gdouble) allocation->width - 1,
+ "y2", (gdouble) allocation->height - 1,
+ NULL);
+ gnome_canvas_item_set (note->priv->rect,
+ "x2", (gdouble) allocation->width - 1,
+ "y2", (gdouble) allocation->height - 1,
+ NULL);
+ gnome_canvas_item_set (note->priv->move_button,
+ "width", (gdouble) allocation->width - 29,
+ NULL);
+ gnome_canvas_item_set (note->priv->resize_button,
+ "x", (gdouble) allocation->width - 23,
+ "y", (gdouble) allocation->height - 23,
+ NULL);
+ gnome_canvas_item_set (note->priv->close_button,
+ "x", (gdouble) allocation->width - 23,
+ NULL);
+}
+
+static void
+e_note_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
+
+ gdk_window_set_decorations (widget->window, 0);
+}
+
+static void
+e_note_class_init (ENoteClass *klass)
+{
+ GtkWidgetClass *widget_class;
+ GtkObjectClass *object_class;
+
+ object_class = (GtkObjectClass *)klass;
+ widget_class = (GtkWidgetClass *)klass;
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ widget_class->realize = e_note_realize;
+
+ e_note_signals [E_NOTE_TEXT_CHANGED] =
+ gtk_signal_new ("changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ENoteClass, text_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, e_note_signals, E_NOTE_LAST_SIGNAL);
+}
+
+static void
+e_note_init (ENote *note)
+{
+ ENotePrivate *priv;
+ GtkWidget *button;
+
+ priv = g_new (ENotePrivate, 1);
+
+ note->priv = priv;
+
+ gtk_widget_push_visual (gdk_rgb_get_visual ());
+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+
+ priv->canvas = e_canvas_new ();
+
+ gtk_widget_pop_visual ();
+ gtk_widget_pop_colormap ();
+
+ gtk_signal_connect (GTK_OBJECT (priv->canvas), "size_allocate",
+ GTK_SIGNAL_FUNC (e_note_canvas_size_allocate), note);
+ gtk_widget_show (priv->canvas);
+ gtk_container_add (GTK_CONTAINER (note), priv->canvas);
+
+ priv->rect = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ gnome_canvas_rect_get_type (),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", 100.0,
+ "y2", 100.0,
+ "fill_color_rgba", 0xf5ffa0ff,
+ NULL);
+ priv->frame = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ gnome_canvas_rect_get_type (),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", 100.0,
+ "y2", 100.0,
+ "outline_color", "black",
+ NULL);
+
+ priv->text_item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ e_text_get_type (),
+ "x", 5.0,
+ "y", 25.0,
+ "text", "",
+ "font_gdk", priv->canvas->style->font,
+ "fill_color", "black",
+ "anchor", GTK_ANCHOR_NW,
+ "clip", TRUE,
+ "editable", TRUE,
+ "line_wrap", TRUE,
+ "width", 150.0,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (E_TEXT (priv->text_item)->model), "changed",
+ GTK_SIGNAL_FUNC (e_note_text_changed), note);
+
+ button = e_bevel_button_new ();
+ gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
+ GTK_SIGNAL_FUNC (e_note_move_button_changed), note);
+ gtk_signal_connect (GTK_OBJECT (button), "button_release_event",
+ GTK_SIGNAL_FUNC (e_note_move_button_changed), note);
+ gtk_signal_connect (GTK_OBJECT (button), "motion_notify_event",
+ GTK_SIGNAL_FUNC (e_note_move_motion_event), note);
+ gtk_widget_show (button);
+ priv->move_button = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ gnome_canvas_widget_get_type (),
+ "widget", button,
+ "x", 3.0,
+ "y", 3.0,
+ "width", 20.0,
+ "height", 20.0,
+ NULL);
+ button = e_bevel_button_new ();
+ gtk_widget_show (button);
+ priv->close_button = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ gnome_canvas_widget_get_type (),
+ "widget", button,
+ "x", 3.0,
+ "y", 3.0,
+ "width", 20.0,
+ "height", 20.0,
+ NULL);
+
+ button = e_bevel_button_new ();
+ gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
+ GTK_SIGNAL_FUNC (e_note_resize_button_changed), note);
+ gtk_signal_connect (GTK_OBJECT (button), "button_release_event",
+ GTK_SIGNAL_FUNC (e_note_resize_button_changed), note);
+ gtk_signal_connect (GTK_OBJECT (button), "motion_notify_event",
+ GTK_SIGNAL_FUNC (e_note_resize_motion_event), note);
+ gtk_widget_show (button);
+ priv->resize_button = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (priv->canvas)),
+ gnome_canvas_widget_get_type (),
+ "widget", button,
+ "x", 3.0,
+ "y", 3.0,
+ "width", 20.0,
+ "height", 20.0,
+ NULL);
+}
+
+void
+e_note_set_text (ENote *note, gchar *text)
+{
+ g_return_if_fail (note != NULL);
+ g_return_if_fail (E_IS_NOTE (note));
+ g_return_if_fail (text != NULL);
+
+ gnome_canvas_item_set (note->priv->text_item,
+ "text", text,
+ NULL);
+}
+
+gchar *
+e_note_get_text (ENote *note)
+{
+ gchar *text;
+
+ g_return_val_if_fail (note != NULL, NULL);
+ g_return_val_if_fail (E_IS_NOTE (note), NULL);
+ g_return_val_if_fail (text != NULL, NULL);
+
+ gtk_object_get (GTK_OBJECT (note->priv->text_item),
+ "text", &text,
+ NULL);
+
+ return text;
+}
+
+
+GtkWidget *
+e_note_new (void)
+{
+ ENote *note;
+
+ note = gtk_type_new (E_TYPE_NOTE);
+
+ return GTK_WIDGET (note);
+}
+
+E_MAKE_TYPE (e_note, "ENote", ENote, e_note_class_init, e_note_init, PARENT_TYPE);
diff --git a/notes/e-note.h b/notes/e-note.h
new file mode 100644
index 0000000000..d7d4c63b95
--- /dev/null
+++ b/notes/e-note.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#ifndef __E_NOTE_H__
+#define __E_NOTE_H__
+
+#include <config.h>
+#include <gnome.h>
+#include "e-bevel-button.h"
+
+#define E_TYPE_NOTE (e_note_get_type ())
+#define E_NOTE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_NOTE, ENote))
+#define E_NOTE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_NOTE, ENoteClass))
+#define E_IS_NOTE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_NOTE))
+#define E_IS_NOTE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_NOTE))
+
+typedef struct _ENote ENote;
+typedef struct _ENotePrivate ENotePrivate;
+typedef struct _ENoteClass ENoteClass;
+
+struct _ENote {
+ GtkWindow parent;
+
+ ENotePrivate *priv;
+};
+
+struct _ENoteClass {
+ GtkWindowClass parent_class;
+
+ void (* text_changed) (ENote *note);
+};
+
+GtkType e_note_get_type (void);
+GtkWidget *e_note_new (void);
+void e_note_set_text (ENote *note, gchar *text);
+gchar *e_note_get_text (ENote *note);
+
+#endif /* __E_NOTE_H__ */
diff --git a/notes/evolution-notes.oafinfo b/notes/evolution-notes.oafinfo
new file mode 100644
index 0000000000..704b4028d8
--- /dev/null
+++ b/notes/evolution-notes.oafinfo
@@ -0,0 +1,54 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Notes control"/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:control:evolution-notes:8e3fb723-aada-4112-99db-d51779e35a2a"
+ type="factory"
+ location="OAFIID:control-factory:evolution-notes:e2471f2d-0589-4861-a25d-c21818f531d5">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Control:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="A sample Bonobo control which displays an addressbook."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772"
+ type="exe"
+ location="evolution-notes">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Evolution notes component."/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:evolution-shell-component:evolution-notes:92d95b91-3655-4746-ac68-01b21e2c5e44"
+ type="factory"
+ location="OAFIID:evolution-shell-component-factory:evolution-notes:f2f0f57f-27d9-4498-b54b-248f223ee772">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution/ShellComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution component for handling mail."/>
+
+</oaf_server>
+
+</oaf_info>
diff --git a/notes/main.c b/notes/main.c
new file mode 100644
index 0000000000..f3198c0d63
--- /dev/null
+++ b/notes/main.c
@@ -0,0 +1,52 @@
+/*
+ *
+ * Author:
+ * Anders Carlsson (andersca@gnu.org)
+ *
+ * (C) 2000 Helix Code, Inc.
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include <bonobo.h>
+#include <liboaf/liboaf.h>
+
+#include "e-util/e-gui-utils.h"
+#include "component-factory.h"
+
+static void
+init_corba (gint argc, gchar **argv)
+{
+ gnome_init_with_popt_table ("evolution-notes-component", VERSION, argc, argv,
+ oaf_popt_options, 0, NULL);
+ oaf_init (argc, argv);
+}
+
+static void
+init_bonobo (void)
+{
+ if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Notes Component: Could not initialize bonobo"));
+ exit (1);
+ }
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
+ textdomain (PACKAGE);
+
+ init_corba (argc, argv);
+ init_bonobo ();
+
+ e_setup_base_dir ();
+
+ notes_factory_init ();
+ component_factory_init ();
+
+ bonobo_main ();
+
+ return 0;
+}
diff --git a/notes/test-notes.c b/notes/test-notes.c
new file mode 100644
index 0000000000..8352ea789f
--- /dev/null
+++ b/notes/test-notes.c
@@ -0,0 +1,34 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+#include <config.h>
+#include <gnome.h>
+#include <gdk/gdkx.h>
+
+#include "e-util/e-canvas.h"
+#include "widgets/e-text/e-text.h"
+
+#include "e-note.h"
+
+void
+text_changed (GtkWidget *widget, gpointer data)
+{
+ g_print ("Text changed!\n");
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ GtkWidget *note;
+
+ gnome_init ("NotesTest", "0.0.1", argc, argv);
+
+ note = e_note_new ();
+ e_note_set_text (E_NOTE (note), "This is a text note widget");
+ gtk_signal_connect (GTK_OBJECT (note), "changed",
+ GTK_SIGNAL_FUNC (text_changed), NULL);
+
+ gtk_widget_show (note);
+ gtk_main ();
+
+ return 0;
+}