/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ #include #include #include #include #include #include #include #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, ¬e->priv->resize_width, ¬e->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 (), "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); e_canvas_item_move_absolute(priv->text_item, 5.0, 25.0); 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); '>KDE FreeBSD team presents KDE SC 4.5.1.makc2010-09-036-1002/+312 * Update KOffice l10n ports to 2.2.2makc2010-08-286-28/+12 * Update distinfo. The distfiles have been re-rolled for some reason.hrs2010-08-161-3/+3 * Deprecate ports that have been unfetchable for so long that theydougb2010-08-091-0/+3 * Present KDE SC 4.4.5 for FreeBSD.makc2010-06-303-11/+6 * - Update KOffice (and its l10n packs) to 2.2.0 releasefluffy2010-06-198-52/+84 * Present KDE SC 4.4.4 for FreeBSD.makc2010-06-023-6/+10 * Bounce PORTREVISION for gettext-related ports. Have fun, ya'll.ade2010-05-314-4/+4 * - Update KOffice to 2.1.2 releasefluffy2010-05-1110-120/+12 * - The FreeBSD KDE team is pleased to announce KDE SC 4.4.3 for FreeBSDfluffy2010-05-118-387/+422 * - update to 1.4.1dinoex2010-03-2810-8/+10 * Update to version 2010.1.0 of the 2010 fiscal yearlioux2010-03-022-17/+18 * Presenting KDE 4.3.5 for FreeBSD. The official release notes for thismiwi2010-02-074-8/+6 * - update to jpeg-8dinoex2010-02-0510-4/+10 * The KDE FreeBSD team is proud to announce the release of KOffice2 suite for F...fluffy2009-12-2213-960/+172 * The FreeBSD KDE is please to announce the release of KDE 4.3.4,miwi2009-12-022-6/+6 * The KDE FreeBSD team is proud to announce the release of KDE 4.3.3miwi2009-11-275-73/+23 * Update to 8.1.7. Multiple vulnerabilities which could cause thehrs2009-10-151-3/+3 * The FreeBSD KDE is please to announce the release of KDE 4.3.1,tabthorpe2009-09-025-9/+9 * clean upmakc2009-08-082-6/+0 * The KDE FreeBSD team is proud to announce the release of KDE 4.3.0miwi2009-08-058-82/+473 * - bump all port that indirectly depends on libjpeg and have not yet been bump...dinoex2009-07-3110-0/+10 * Upgrade to 20090702-0.thierry2009-07-082-5/+4 * Update to 8.1.6 and 9.1.2.hrs2009-06-181-3/+3 * The KDE FreeBSD team is pleased to announce KDE 4.2.4, the last bugfixmiwi2009-06-033-8/+6 * Update to 8.1.5. Two critical vulnerabilities have been fixed:hrs2009-05-131-3/+3 * Update KDE ports to 4.2.3makc2009-05-104-6/+12 * - Distfile updated without a version bump.araujo2009-04-192-6/+4 * The KDE FreeBSD team is proud to announce the release of KDE 4.2.2miwi2009-04-024-26/+33 * Update to 8.1.4. This version includes serious security fixes.hrs2009-03-291-3/+3 * Welcome to the new linux ports infrastructure which allows usingbsam2009-03-201-1/+1 * Update KDE to 4.2.1.makc2009-03-096-158/+676 * o Add DESKTOP_ENTRIES with entrylioux2009-03-031-1/+9 * o Do not rely on PORTDATA construct when the data files are notlioux2009-03-031-3/+9 * Update to version 2009.1.0 of the 2009 fiscal yearlioux2009-03-034-48/+97 * - Add all manpages for kde4-l10n*miwi2009-02-092-0/+70 * The KDE FreeBSD team is proud to announce the release of KDE 4.2.0miwi2009-02-096-140/+258 * kde@freebsd team is pleased to announce KDE 4.1.4, the last bugfix release in...makc2009-01-146-19/+19 * o Remove after repocopy/move tolioux2008-12-084-31/+0 * o Commit after repocopy.lioux2008-12-081-1/+1 * - Improve package naming according to language category naminglioux2008-12-081-1/+2 * - Improve package naming according to language category naminglioux2008-12-021-2/+3 * Update to Adobe Reader 8.1.3.hrs2008-11-081-3/+3 * Remove ports of Adobe Reader 7 and the localized versions because ofhrs2008-09-063-22/+0 * The KDE FreeBSD team is proud to announce the release of KDE 4.1.1miwi2008-09-034-18/+9 * The KDE FreeBSD team is proud to announce the releasemiwi2008-08-292-6/+6 * The KDE FreeBSD team is proud to announce the releasemiwi2008-08-184-20/+237 * The KDE FreeBSD team is proud to announce the release of KDE 4.1.0miwi2008-08-109-1869/+597 * Upgrade to 20080707.thierry2008-07-252-4/+4 * Update to 8.1.2 Security Update 1. Quoted from the advisory:hrs2008-07-211-3/+3 * Bump portrevision due to upgrade of devel/gettext.edwin2008-06-064-1/+4 * - Remove unneeded dependency from gtk12/gtk20 [1]miwi2008-04-201-1/+1 * Upgrade Esperanto (eo), Spanish (es), Galician (gl), Romanian (ro),thierry2008-04-173-4/+5 * Update to 8.1.2. Bug fixes and enhancements can be found athrs2008-04-141-3/+3 * - Distfile updated without a version bump.araujo2008-04-092-6/+4 * - Mark BROKEN: checksum mismatchpav2008-04-091-0/+2 * Distfile version update without a version bump. Update distinfo andlioux2008-03-162-3/+4 * Upgrade to 20080221-0.thierry2008-03-062-4/+4 * Update to version 2008.1.0 of the 2008 fiscal yearlioux2008-03-042-7/+7 * Add Adobe Reader 8.1.1 and localized versions (total 15hrs2008-01-053-0/+20 * Fix install target: add correct WRKSRClioux2007-12-161-1/+1 * Update to version 2.0lioux2007-12-122-8/+5 * Update to KDE 3.5.8lofi2007-10-308-20/+28 * Update to KDE 3.5.7 / KOffice 1.6.3lofi2007-07-0424-80/+40 * Upgrade to 20070510-0.thierry2007-06-274-8/+8 * - Upgrade to 20070411-0;thierry2007-06-134-7/+6 * - Welcome X.org 7.2 \o/.flz2007-05-2012-2/+12 * BROKEN: Size mismatchkris2007-04-201-0/+2 * - Remove FreeBSD 4.X support from unmaintained ports in categories startinggabor2007-04-201-13/+0 * Update to KDE 3.5.6 / KOffice 1.6.2lofi2007-03-1426-80/+82 * o Update DISTINFO sinze distfile has changed without a version bump:lioux2007-03-132-4/+4 * o Improve wrapper.sh script: remove jars after we have used themlioux2007-03-062-3/+15 * New port irpf version 2007.1.0: Programa do Imposto de Renda Pessoalioux2007-03-066-0/+154 * Upgrade to 20070206-0.thierry2007-02-138-36/+20 * Add Aspell Brazilian Portuguese dictionary.thierry2007-02-135-0/+30 * Update to 7.0.9. Various security vulnerabilities have been fixed.hrs2007-01-182-4/+4 * Update to KDE 3.5.5 / KOffice 1.6.1lofi2006-12-2026-144/+1279 * Remove expired www/frontpage and all frontpage ports:vd2006-12-133-26/+0 * Update localized Adobe Reader to 7.0.8.hrs2006-09-232-5/+5 * KDE 3.5.4 / KOffice 1.5.2lofi2006-09-1321-38/+48 * All dictionaries can be installed separately:thierry2006-07-158-14/+42 * - Update to 5.0.2.4803pav2006-06-262-4/+3 * Update to KDE 3.5.3lofi2006-06-068-44/+70 * Update to KOffice 1.5.1lofi2006-05-2715-24/+177 * Fix MASTER_SITES and make it fetchable againgarga2006-05-221-1/+1 * Bump PORTREVISION to reflect the fact that the .desktop file is nojylefort2006-05-211-1/+1 * Bump PORTREVISION to reflect the fact that these ports may nowjylefort2006-05-191-1/+1 * Update to KOffice 1.5.0lofi2006-04-2918-33/+39 * Reset mbr due to no answer to an email inquiry about his status, andlinimon2006-04-151-1/+1 * Update to KDE 3.5.2lofi2006-03-318-270/+46 * - Use a distfile in tarball instead of one in rpm.hrs2006-02-223-18/+8 * Update to KDE 3.5.1.lofi2006-02-016-12/+14 * SHA256ifyedwin2006-01-247-0/+7 * Update to KDE 3.5.0lofi2006-01-098-238/+382 * Hash with SHA-256.trevor2006-01-081-0/+1 * - Add SHA256pav2005-11-261-0/+1 * Update to KDE 3.4.3 / KOffice 1.4.2lofi2005-11-0526-48/+26 * Remove all the secondary port of editors/ooodict-allmaho2005-11-013-42/+0 * localized versions of Adobe Reader (formerly Acrobat Reader)trevor2005-10-084-0/+31 * Forgot to remove ooo ports in portuguese categorymaho2005-09-073-67/+0 * Fix index build by moving openoffice.org-1.1 ports.maho2005-08-292-2/+2 * Update to KDE 3.4.2 / KOffice 1.4.1lofi2005-08-0118-26/+30 * Update to KOffice 1.4.0a.lofi2005-07-0618-174/+852 * Remove openoffice.org localized ports as I announced:maho2005-06-291-3/+0 * Update to KDE 3.4.1lofi2005-06-268-2050/+160 * Mega-patch to cleanup the ports infrastructure regarding our linux bits:netchild2005-06-181-2/+5 * - Unbreak and general updatepav2005-06-06