[Goodies-commits] r3320 - in xfce4-notes-plugin/trunk: . icons icons/16x16 icons/22x22 icons/24x24 icons/32x32 icons/scalable panel-plugin po
Mike Massonnet
mmassonnet at xfce.org
Wed Oct 10 23:54:47 CEST 2007
Author: mmassonnet
Date: 2007-10-10 21:54:46 +0000 (Wed, 10 Oct 2007)
New Revision: 3320
Added:
xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
Modified:
xfce4-notes-plugin/trunk/AUTHORS
xfce4-notes-plugin/trunk/Makefile.am
xfce4-notes-plugin/trunk/configure.in.in
xfce4-notes-plugin/trunk/icons/16x16/Makefile.am
xfce4-notes-plugin/trunk/icons/22x22/Makefile.am
xfce4-notes-plugin/trunk/icons/24x24/Makefile.am
xfce4-notes-plugin/trunk/icons/32x32/Makefile.am
xfce4-notes-plugin/trunk/icons/Makefile.am
xfce4-notes-plugin/trunk/icons/scalable/Makefile.am
xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
xfce4-notes-plugin/trunk/panel-plugin/notes.c
xfce4-notes-plugin/trunk/panel-plugin/notes.h
xfce4-notes-plugin/trunk/po/POTFILES.in
Log:
Commit the first work of the rewrite. *EXPERIMENTAL CODE*
Modified: xfce4-notes-plugin/trunk/AUTHORS
===================================================================
--- xfce4-notes-plugin/trunk/AUTHORS 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/AUTHORS 2007-10-10 21:54:46 UTC (rev 3320)
@@ -2,4 +2,4 @@
- Creator & former maintainer
Mike Massonnet <mmassonnet at gmail.com>
- - Maintainer
+ - Port to Xfce 4.4 & current maintainer
Modified: xfce4-notes-plugin/trunk/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -1,10 +1,8 @@
-# $Id$
-
@SET_MAKE@
-SUBDIRS = \
- icons \
- panel-plugin \
+SUBDIRS = \
+ icons \
+ panel-plugin \
po
@@ -18,16 +16,13 @@
zcat $(PACKAGE)-$(VERSION).tar.gz | bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
-EXTRA_DIST = \
- README \
- intltool-extract.in \
- intltool-merge.in \
+EXTRA_DIST = \
+ README \
+ intltool-extract.in \
+ intltool-merge.in \
intltool-update.in
-DISTCLEANFILES = \
- intltool-extract \
- intltool-merge \
+DISTCLEANFILES = \
+ intltool-extract \
+ intltool-merge \
intltool-update
-
-
-# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
Modified: xfce4-notes-plugin/trunk/configure.in.in
===================================================================
--- xfce4-notes-plugin/trunk/configure.in.in 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/configure.in.in 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,7 +4,7 @@
dnl
dnl 2003 Benedikt Meurer <benedikt.meurer at unix-ag.uni-siegen.de>
dnl 2003 Jakob Henriksson <b0kaj+dev at lysator.liu.se>
-dnl 2006 Mike Massonnet <mmassonnet at gmail.com>
+dnl 2006, 2007 Mike Massonnet <mmassonnet at gmail.com>
dnl
m4_define([xfce4_notes_plugin_version_major], [1])
Modified: xfce4-notes-plugin/trunk/icons/16x16/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/16x16/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/16x16/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,4 +4,3 @@
EXTRA_DIST = \
$(icons_DATA)
-
Modified: xfce4-notes-plugin/trunk/icons/22x22/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/22x22/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/22x22/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,4 +4,3 @@
EXTRA_DIST = \
$(icons_DATA)
-
Modified: xfce4-notes-plugin/trunk/icons/24x24/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/24x24/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/24x24/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,4 +4,3 @@
EXTRA_DIST = \
$(icons_DATA)
-
Modified: xfce4-notes-plugin/trunk/icons/32x32/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/32x32/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/32x32/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,4 +4,3 @@
EXTRA_DIST = \
$(icons_DATA)
-
Modified: xfce4-notes-plugin/trunk/icons/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -1,4 +1,4 @@
-SUBDIRS = \
+SUBDIRS = \
16x16 \
22x22 \
24x24 \
Modified: xfce4-notes-plugin/trunk/icons/scalable/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/icons/scalable/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/icons/scalable/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -4,4 +4,3 @@
EXTRA_DIST = \
$(icons_DATA)
-
Modified: xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2007-10-10 21:54:46 UTC (rev 3320)
@@ -1,44 +1,41 @@
-bin_PROGRAMS = xfce4-popup-notes
+#bin_PROGRAMS = xfce4-popup-notes
+#
+#xfce4_popup_notes_SOURCES = \
+# xfce4-popup-notes.c \
+# xfce4-popup-notes.h
+#
+#xfce4_popup_notes_CFLAGS = \
+# $(LIBX11_CFLAGS) \
+# $(GTK_CFLAGS)
+#
+#xfce4_popup_notes_LDADD = \
+# $(LIBX11_LDFLAGS) \
+# $(LIBX11_LIBS) \
+# $(GTK_LIBS)
-xfce4_popup_notes_SOURCES = \
- xfce4-popup-notes.c \
- xfce4-popup-notes.h
-
-xfce4_popup_notes_CFLAGS = \
- $(LIBX11_CFLAGS) \
- $(GTK_CFLAGS)
-
-xfce4_popup_notes_LDADD = \
- $(LIBX11_LDFLAGS) \
- $(LIBX11_LIBS) \
- $(GTK_LIBS)
-
plugindir = $(libexecdir)/xfce4/panel-plugins
plugin_PROGRAMS = xfce4-notes-plugin
xfce4_notes_plugin_SOURCES = \
+ panel-plugin.c \
notes.c \
- notes-window.c \
- notes-options.c \
notes.h \
- notes-window.h \
- notes-options.h
xfce4_notes_plugin_CFLAGS = \
-I$(top_srcdir) \
@LIBXFCE4PANEL_CFLAGS@ \
- @LIBXFCEGUI4_CFLAGS@ \
@LIBXFCE4UTIL_CFLAGS@ \
+ @LIBXFCEGUI4_CFLAGS@ \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\"
xfce4_notes_plugin_LDADD = \
@LIBXFCE4PANEL_LIBS@ \
- @LIBXFCEGUI4_LIBS@ \
- @LIBXFCE4UTIL_LIBS@
+ @LIBXFCE4UTIL_LIBS@ \
+ @LIBXFCEGUI4_LIBS@
desktop_in_in_files = xfce4-notes-plugin.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-
+
desktopdir = $(datadir)/xfce4/panel-plugins
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.c 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.c 2007-10-10 21:54:46 UTC (rev 3320)
@@ -1,8 +1,6 @@
-/* $Id$
+/* $Id$
*
- * Notes - panel plugin for Xfce Desktop Environment
- * Copyright (C) 2003 Jakob Henriksson <b0kaj+dev at lysator.liu.se>
- * 2006 Mike Massonnet <mmassonnet at gmail.com>
+ * Copyright (c) 2006 Mike Massonnet <mmassonnet at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -12,7 +10,7 @@
* 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 General Public License for more details.
+ * GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
@@ -23,455 +21,468 @@
#include <config.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <stdlib.h>
#include <gtk/gtk.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
-#include <libxfce4panel/xfce-panel-plugin.h>
-#include <libxfce4panel/xfce-panel-convenience.h>
-
#include "notes.h"
-#include "notes-options.h"
-#include "xfce4-popup-notes.h"
#define PLUGIN_NAME "xfce4-notes-plugin"
-static void notes_construct (XfcePanelPlugin *);
-static void notes_free_data (XfcePanelPlugin *,
- NotesPlugin *);
-static void notes_save (XfcePanelPlugin *,
- NotesPlugin *);
-static gboolean save_on_timeout_execute (NotesPlugin *);
+gchar *
+notes_window_read_name (NotesPlugin *notes_plugin)
+{
+ static GDir *dir = NULL;
+ static gchar *notes_path = NULL;
+ static gchar *name = NULL;
-static void notes_configure (XfcePanelPlugin *,
- NotesPlugin *);
-static gboolean notes_set_size (XfcePanelPlugin *,
- int size,
- NotesPlugin *);
-static void notes_load_data (XfcePanelPlugin *,
- NotesPlugin *);
-static gboolean notes_button_clicked (XfcePanelPlugin *,
- NotesPlugin *);
-static void on_options_response (GtkWidget *,
- int response,
- NotesPlugin *);
-static gboolean notes_message_received (GtkWidget *,
- GdkEventClient *,
- gpointer data);
-static gboolean notes_set_selection (NotesPlugin *notes);
+ if (G_UNLIKELY (dir == NULL))
+ {
+ notes_path = notes_plugin->notes_path;
+ dir = g_dir_open (notes_path);
+ }
+ g_free (name);
+ if (G_UNLIKELY ((name = g_dir_read_name (dir)) == NULL))
+ {
+ g_dir_close (dir);
+ DBG ("Notes dir closed: %p\n", dir);
+ dir = NULL;
+ }
-/* Panel Plugin Interface */
+ return name;
+}
-XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (notes_construct);
-
-
-/* internal functions */
-
-static void
-notes_free_data (XfcePanelPlugin *plugin, NotesPlugin *notes)
+NotesWindow *
+notes_window_new (NotesPlugin *notes_plugin,
+ gchar *notes_window_name)
{
- if (notes->timeout_id > 0)
- g_source_remove (notes->timeout_id);
+ NotesWindow *notes_window;
+ GtkAccelGroup *accel_group;
+ GtkWidget *img_add, *img_del, *img_close;
- notes_save (plugin, notes);
+ notes_window = g_slice_new0 (NotesWindow);
+ notes_window->notes_plugin = notes_plugin;
+ g_slist_append (notes_plugin->windows, notes_window);
- DBG ("Free data: %s", PLUGIN_NAME);
- gtk_main_quit ();
-}
+ /* Window */
+ notes_window->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (notes_window->window), _("Notes"));
+ gtk_window_set_default_size (GTK_WINDOW (notes_window->window), 375, 430);
+ gtk_window_set_decorated (GTK_WINDOW (notes_window->window), FALSE);
+ gtk_window_set_icon_name (GTK_WINDOW (notes_window->window), "xfce4-notes-plugin");
+ gtk_widget_set_name (notes_window->window, PLUGIN_NAME);
-static void
-notes_save (XfcePanelPlugin *plugin, NotesPlugin *notes)
-{
- char *file;
- XfceRc *rc;
- gint id;
- NotePage *page;
- GList *pages;
- GtkTextBuffer *buffer;
- GtkTextIter start, end;
- gchar *text;
- const gchar *label;
- gchar note_entry[12], label_entry[13];
+ /* Frame */
+ notes_window->frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (notes_window->frame), GTK_SHADOW_OUT);
+ gtk_container_add (GTK_CONTAINER (notes_window->window),
+ note->frame);
+ gtk_widget_show (notes_window->frame);
- DBG ("Save: %s", PLUGIN_NAME);
+ /* Vertical box */
+ notes_window->vbox = gtk_vbox_new (FALSE, 0);
+ gtk_box_set_spacing (GTK_BOX (notes_window->vbox), 1);
+ gtk_container_add (GTK_CONTAINER (notes_window->frame),
+ notes_window->vbox);
+ gtk_widget_show (notes_window->vbox);
- file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
- "xfce4/panel/notes.rc", TRUE);
- if (G_UNLIKELY (!file))
- return;
+ /* Horizontal box */
+ notes_window->hbox = gtk_hbox_new (FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (notes_window->vbox),
+ notes_window->hbox,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show (notes_window->hbox);
- rc = xfce_rc_simple_open (file, FALSE);
- g_free (file);
+ /* Add button FIXME create panel button ?! */
+ notes_window->btn_add = xfce_create_panel_button ();
+ gtk_widget_set_size_request (notes_window->btn_add, 22, 22);
+ img_add = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (notes_window->btn_add),
+ img_add);
+ gtk_box_pack_start (GTK_BOX (notes_window->hbox),
+ notes_window->btn_add,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show (img_add);
+ gtk_widget_show (notes_window->btn_add);
- if (rc)
- {
- if (GTK_WIDGET_VISIBLE (notes->note->window))
- {
- gtk_window_get_position (GTK_WINDOW (notes->note->window),
- ¬es->note->x, ¬es->note->y);
- if (GTK_WIDGET_VISIBLE (notes->note->notebook))
- gtk_window_get_size (GTK_WINDOW (notes->note->window),
- ¬es->note->w, ¬es->note->h);
- else
- gtk_window_get_size (GTK_WINDOW (notes->note->window),
- ¬es->note->w, NULL);
- }
+ /* Remove button */
+ notes_window->btn_del = xfce_create_panel_button ();
+ gtk_widget_set_size_request (notes_window->btn_del, 22, 22);
+ img_del = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (notes_window->btn_del),
+ img_del);
+ gtk_box_pack_start (GTK_BOX (notes_window->hbox),
+ notes_window->btn_del,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show (img_del);
+ gtk_widget_show (notes_window->btn_del);
- xfce_rc_set_group (rc, "settings");
+ /* Event box move */
+ notes_window->eb_move = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (notes_window->eb_move), FALSE);
+ gtk_widget_realize (notes_window->eb_move);
+ gtk_box_pack_start (GTK_BOX (notes_window->hbox),
+ notes_window->eb_move,
+ TRUE,
+ TRUE,
+ 0);
+ gtk_widget_show (notes_window->eb_move);
- xfce_rc_write_int_entry (rc, "pos_x", notes->note->x);
- xfce_rc_write_int_entry (rc, "pos_y", notes->note->y);
- xfce_rc_write_int_entry (rc, "width", notes->note->w);
- xfce_rc_write_int_entry (rc, "height", notes->note->h);
+ /* Title */
+ notes_window->title = gtk_label_new (_("<b>Notes</b>"));
+ gtk_label_set_use_markup (GTK_LABEL (notes_window->title), TRUE);
+ gtk_container_add (GTK_CONTAINER (notes_window->eb_move),
+ notes_window->title);
+ gtk_widget_show (notes_window->title);
- xfce_rc_write_bool_entry (rc, "visible", GTK_WIDGET_VISIBLE (notes->note->window));
- xfce_rc_write_bool_entry (rc, "show", notes->options.show);
- xfce_rc_write_bool_entry (rc, "task_switcher", notes->options.task_switcher);
- xfce_rc_write_bool_entry (rc, "always_on_top", notes->options.always_on_top);
- xfce_rc_write_bool_entry (rc, "stick", notes->options.stick);
- xfce_rc_write_bool_entry (rc, "statusbar", notes->options.statusbar);
+ /* Close button */
+ notes_window->btn_close = xfce_create_panel_button ();
+ gtk_widget_set_size_request (notes_window->btn_close, 22, 22);
+ img_close = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (notes_window->btn_close),
+ img_close);
+ gtk_box_pack_start (GTK_BOX (notes_window->hbox),
+ notes_window->btn_close,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show (img_close);
+ gtk_widget_show (notes_window->btn_close);
+
+ /* Notebook */
+ notes_window->notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notes_window->notebook), FALSE);
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notes_window->notebook), GTK_POS_LEFT);
+ gtk_notebook_set_scrollable (GTK_NOTEBOOK (notes_window->notebook), TRUE);
+ gtk_box_pack_start (GTK_BOX (notes_window->vbox),
+ notes_window->notebook,
+ TRUE,
+ TRUE,
+ 0);
+ gtk_widget_show (notes_window->notebook);
- pages = notes->note->pages;
- xfce_rc_set_group (rc, "notes");
+ /* Status bar */
+ notes_window->statusbar = gtk_statusbar_new ();
+ gtk_box_pack_start (GTK_BOX (notes_window->vbox),
+ notes_window->statusbar,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show (notes_window->statusbar);
- for (id = 0, page = (NotePage *)g_list_nth_data (pages, id);
- page != NULL;
- id++, page = (NotePage *)g_list_nth_data (pages, id))
- {
- if (page->label_dirty)
- {
- label = gtk_label_get_text (GTK_LABEL (page->label));
- g_snprintf (label_entry, 13, "label%d", id);
+ /* Accel group */
+ accel_group = gtk_accel_group_new ();
+ gtk_window_add_accel_group (GTK_WINDOW (notes_window->window), accel_group);
+ gtk_widget_add_accelerator (notes_window->btn_add,
+ "clicked",
+ accel_group,
+ 'N',
+ GDK_CONTROL_MASK,
+ GTK_ACCEL_MASK);
+ gtk_widget_add_accelerator (notes_window->btn_del,
+ "clicked",
+ accel_group,
+ 'W',
+ GDK_CONTROL_MASK,
+ GTK_ACCEL_MASK);
- xfce_rc_write_entry (rc, label_entry, label);
+ /* Signals FIXME */
+ g_signal_connect (notes_window->btn_add,
+ "clicked",
+ G_CALLBACK (notes_window_add_note),
+ notes_plugin);
+ g_signal_connect (notes_window->btn_del,
+ "clicked",
+ G_CALLBACK (notes_window_delete_note),
+ notes_plugin);
+ g_signal_connect (G_OBJECT (notes_window->eb_move),
+ "button-press-event",
+ G_CALLBACK (notes_window_move),
+ notes_window);
+ g_signal_connect (G_OBJECT (notes_window->eb_move),
+ "scroll-event",
+ G_CALLBACK (notes_window_shade),
+ notes_window);
+ g_signal_connect (notes_window->window,
+ "delete-event",
+ G_CALLBACK (notes_window_close_window), /* XXX should prevent ALT+F4 */
+ notes_plugin);
+ g_signal_connect (notes_window->btn_close,
+ "clicked",
+ G_CALLBACK (notes_window_close_window),
+ notes_plugin);
- DBG ("Label %d: %s", id, label);
- }
+ /* Load data */
+ notes_window_load_data (notes_window);
- g_snprintf (note_entry, 12, "note%d", id);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (page->text));
- gtk_text_buffer_get_bounds (buffer, &start, &end);
- text = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (buffer), &start,
- &end, TRUE);
+ /* Show the stuff, or not */
+ if (G_LIKELY (notes_window->show_statusbar))
+ gtk_widget_show (notes_window->statusbar);
+ else
+ gtk_widget_hide (notes_window->statusbar);
- DBG ("Note %d (%s): %s", id, note_entry, text);
- xfce_rc_write_entry (rc, note_entry, text);
- g_free (text);
- }
+ if (G_LIKELY (notes_window->visible
+ && notes_window->show_on_startup != NEVER))
+ gtk_widget_show (notes_window->windows);
+ else
+ gtk_widget_hide (notes_window->windows);
- xfce_rc_close (rc);
- }
+ return notes_window;
}
-static gboolean
-save_on_timeout_execute (NotesPlugin *notes)
-{
- notes_save (notes->plugin, notes);
-
- return FALSE;
-}
-
void
-save_on_timeout (NotesPlugin *notes)
+notes_window_load_data (NotesWindow *notes_window)
{
- if (notes->timeout_id > 0)
- {
- g_source_remove (notes->timeout_id);
- notes->timeout_id = 0;
- }
+ XfceRc *rc;
+ NotesNote *notes_note;
+ gchar *note_name;
+ gchar *window_name;
- notes->timeout_id = g_timeout_add (60000,
- (GSourceFunc) save_on_timeout_execute,
- notes);
-}
+ window_name = gtk_label_get_text (notes_window->title);
+ if (G_UNLIKELY (g_ascii_strncasecmp (window_name, "", 1) == 0))
+ {
+ guint id = g_slist_length (notes_window->notes_plugin->windows);
+ if (G_LIKELY (id > 1))
+ gchar *window_name_tmp = g_strdup_printf ("Notes %d", id);
+ else
+ gchar *window_name_tmp = g_strdup ("Notes");
+ gtk_label_set_text (notes_window->title, window_name_tmp);
+ window_name = gtk_label_get_text (notes_window->title);
+ g_free (window_name_tmp);
+ }
-static void
-notes_configure (XfcePanelPlugin *plugin, NotesPlugin *notes)
-{
- GtkWidget *dialog;
+ rc = xfce_rc_simple_open (notes_window->notes_plugin->config_file, FALSE);
+ xfce_rc_set_group (rc, window_name);
- DBG ("Configure: %s", PLUGIN_NAME);
+ notes_window->x = xfce_rc_read_int_entry (rc, "PosX", -1);
+ notes_window->y = xfce_rc_read_int_entry (rc, "PosY", -1);
+ notes_window->w = xfce_rc_read_int_entry (rc, "Width", 375);
+ notes_window->h = xfce_rc_read_int_entry (rc, "Height", 430);
- xfce_panel_plugin_block_menu (plugin);
- dialog = notes_options_new (notes);
+ notes_window->always_on_top = xfce_rc_read_bool_entry (rc, "AlwaysOnTop", FALSE);
+ notes_window->show_in_pager = xfce_rc_read_bool_entry (rc, "ShowInPager", TRUE);
+ notes_window->show_on_startup = xfce_rc_read_int_entry (rc, "ShowOnStartup", ALWAYS);
+ notes_window->show_statusbar = xfce_rc_read_bool_entry (rc, "ShowStatusbar", TRUE);
+ notes_window->stick = xfce_rc_read_bool_entry (rc, "Stick", TRUE);
+ notes_window->visible = xfce_rc_read_bool_entry (rc, "Visible", TRUE);
- g_object_set_data (G_OBJECT (notes->plugin), "configure", dialog);
+ xfce_rc_close (rc);
- g_signal_connect (dialog, "response", G_CALLBACK (on_options_response),
- notes);
+ do
+ {
+ note_name = notes_note_read_name (notes_window);
+ notes_note = notes_note_new (notes_window, note_name);
+ notes_note->notes_window = notes_window;
+ g_slist_append (notes_window->notes, notes_note);
+ }
+ while (G_LIKELY (note_name != NULL));
}
-static gboolean
-notes_set_size (XfcePanelPlugin *plugin, int size, NotesPlugin *notes)
+void
+notes_window_configure (NotesPlugin *notes_window)
{
- GdkPixbuf *pixbuf;
-
- DBG ("Set size to %d: %s", size, PLUGIN_NAME);
-
- gtk_widget_set_size_request (notes->button, size, size);
-
- size = size - 2 - (2 * MAX (notes->button->style->xthickness,
- notes->button->style->ythickness));
- pixbuf = xfce_themed_icon_load ("xfce4-notes-plugin", size);
- gtk_image_set_from_pixbuf (GTK_IMAGE (notes->icon), pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
-
- return TRUE;
}
-
-/* create widgets and connect to signals */
-
-static void
-notes_construct (XfcePanelPlugin *plugin)
+void
+notes_window_response (GtkWidget *widget,
+ int response,
+ NotesWindow *notes_window)
{
- NotesPlugin *notes;
-
- xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-
- DBG ("Construct: %s", PLUGIN_NAME);
-
- DBG ("Properties: size = %d, panel_position = %d",
- xfce_panel_plugin_get_size (plugin),
- xfce_panel_plugin_get_screen_position (plugin));
-
- notes = notes_new (plugin);
-
- notes_set_selection (notes);
-
- gtk_container_add (GTK_CONTAINER (plugin), notes->button);
-
- xfce_panel_plugin_add_action_widget (plugin, notes->button);
-
- g_signal_connect (plugin, "free-data",
- G_CALLBACK (notes_free_data), notes);
-
- g_signal_connect (notes->button, "clicked",
- G_CALLBACK (notes_button_clicked), notes);
-
- g_signal_connect (plugin, "save",
- G_CALLBACK (notes_save), notes);
-
- g_signal_connect (plugin, "size-changed",
- G_CALLBACK (notes_set_size), notes);
-
- xfce_panel_plugin_menu_show_configure (plugin);
- g_signal_connect (plugin, "configure-plugin",
- G_CALLBACK (notes_configure), notes);
-
- if (notes->options.show || notes->options.visible)
- gtk_button_clicked (GTK_BUTTON (notes->button));
}
-NotesPlugin *
-notes_new (XfcePanelPlugin *plugin)
+void
+notes_window_save (NotesWindow *notes_window)
{
- NotesPlugin *notes;
+ XfceRc *rc;
+ gchar *window_name;
- DBG ("New Notes Plugin");
+ window_name = gtk_label_get_text (notes_window->title);
- notes = g_new0 (NotesPlugin, 1);
+ if (GTK_WIDGET_VISIBLE (notes_window->window))
+ {
+ gtk_window_get_position (GTK_WINDOW (notes_window->window),
+ ¬es_window->x,
+ ¬es_window->y);
+ gtk_window_get_size (GTK_WINDOW (notes->note->window),
+ ¬es_window->w,
+ ¬es_window->h);
+ }
- notes->plugin = plugin;
- notes->timeout_id = 0;
+ rc = xfce_rc_simple_open (notes_window->notes_plugin->config_file, FALSE);
+ g_return_if_fail (G_UNLIKELY (!rc));
- notes->button = xfce_create_panel_button ();
- gtk_widget_show (notes->button);
+ xfce_rc_set_group (rc, window_name);
- notes->icon = gtk_image_new ();
- gtk_widget_show (notes->icon);
- gtk_container_add (GTK_CONTAINER (notes->button), notes->icon);
+ xfce_rc_write_int_entry (rc, "PosX", notes_window->x);
+ xfce_rc_write_int_entry (rc, "PosY", notes_window->y);
+ xfce_rc_write_int_entry (rc, "Width", notes_window->w);
+ xfce_rc_write_int_entry (rc, "Height", notes_window->h);
- notes->tooltips = gtk_tooltips_new ();
+ xfce_rc_write_bool_entry (rc, "AlwaysOnTop",
+ notes_window->always_on_top);
+ xfce_rc_write_bool_entry (rc, "ShowInPager",
+ notes_window->show_in_pager);
+ xfce_rc_write_int_entry (rc, "ShowOnStartup",
+ notes_window->show_on_startup);
+ xfce_rc_write_bool_entry (rc, "ShowStatusbar",
+ notes_window->show_statusbar);
+ xfce_rc_write_bool_entry (rc, "Stick",
+ notes_window->stick);
+ xfce_rc_write_bool_entry (rc, "Visible",
+ GTK_WIDGET_VISIBLE (notes_window->window));
- notes->note = note_new (notes);
- notes_load_data (plugin, notes);
-
- return notes;
+ xfce_rc_close (rc);
}
-static void
-notes_load_data (XfcePanelPlugin *plugin, NotesPlugin *notes)
-{
- gchar *file;
- XfceRc *rc;
- gchar note_entry[12];
- gint id;
- file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
- "xfce4/panel/notes.rc", TRUE);
- if (G_UNLIKELY (!file))
- return;
- DBG ("Look up file (%s)", file);
+gchar *
+notes_note_read_name (NotesWindow *notes_window)
+{
+ static GDir *dir = NULL;
+ static gchar *notes_path = NULL;
+ static gchar *window_title = NULL;
+ static gchar *path = NULL;
+ static gchar *note_name = NULL;
- rc = xfce_rc_simple_open (file, FALSE);
- g_free (file);
+ if (G_UNLIKELY (dir == NULL))
+ {
+ if (G_UNLIKELY (notes_path == NULL))
+ {
+ notes_path = notes_window->notes_plugin->notes_path;
+ notes_title = notes_window->title;
+ path = g_build_path (G_DIR_SEPARATOR_S,
+ notes_path,
+ notes_title,
+ NULL);
+ }
+ dir = g_dir_open (path);
+ g_return_val_if_fail (G_UNLIKELY (!dir), NULL);
+ }
- if (rc)
- {
- id = 0;
- g_snprintf (note_entry, 12, "note%d", id++);
- xfce_rc_set_group (rc, "notes");
- while (xfce_rc_has_entry (rc, note_entry))
- {
- note_page_new (plugin, notes);
- g_snprintf (note_entry, 12, "note%d", id++);
- }
- if (id == 1 && !xfce_rc_has_entry (rc, note_entry))
- note_page_new (plugin, notes);
+ g_free (note_name);
+ if (G_UNLIKELY ((note_name = g_dir_read_name (dir)) == NULL))
+ {
+ g_dir_close (dir);
+ DBG ("Notes dir closed: %p\n", dir);
+ dir = NULL;
+ }
- xfce_rc_set_group (rc, "settings");
-
- notes->note->x = xfce_rc_read_int_entry (rc, "pos_x", -1);
- notes->note->y = xfce_rc_read_int_entry (rc, "pos_y", -1);
- notes->note->w = xfce_rc_read_int_entry (rc, "width", 242);
- notes->note->h = xfce_rc_read_int_entry (rc, "height", 200);
-
- notes->options.visible = xfce_rc_read_bool_entry (rc, "visible", FALSE);
- notes->options.show = xfce_rc_read_bool_entry (rc, "show", FALSE);
- notes->options.task_switcher = xfce_rc_read_bool_entry (rc, "task_switcher", TRUE);
- notes->options.always_on_top = xfce_rc_read_bool_entry (rc, "always_on_top", FALSE);
- notes->options.stick = xfce_rc_read_bool_entry (rc, "stick", TRUE);
- notes->options.statusbar = xfce_rc_read_bool_entry (rc, "statusbar", TRUE);
-
- xfce_rc_close (rc);
- }
+ return note_name;
}
-static gboolean
-notes_button_clicked (XfcePanelPlugin *plugin, NotesPlugin *notes)
+/**
+ * notes_note_new:
+ * @notes_window : a NotesWindow pointer
+ * @notes_note_name : the name of the notes to open
+ * or %NULL to create a new note
+ *
+ * Create a new note.
+ *
+ * Return value: a pointer to a new allocated NotesNote.
+ **/
+NotesNote *
+notes_note_new (NotesWindow *notes_window,
+ gchar *notes_note_name)
{
- DBG ("Notes Button Clicked");
+ NotesNote *notes_note;
+ GtkTextBuffer *buffer;
- /* Show/hide the note */
- if (!GTK_WIDGET_VISIBLE (notes->note->window))
- {
- if (notes->note->x != -1 && notes->note->y != -1)
- gtk_window_move (GTK_WINDOW (notes->note->window), notes->note->x,
- notes->note->y);
- gtk_window_resize (GTK_WINDOW (notes->note->window), notes->note->w,
- notes->note->h);
+ notes_note = g_slice_new0 (NotesNote);
+ notes_note->notes_window = notes_window;
+ g_slist_append (notes_window->notes, notes_note);
- GTK_WIDGET_UNSET_FLAGS (notes->note->notebook, GTK_CAN_FOCUS);
+ /* Label */
+ GtkWidget *eb_border = gtk_event_box_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (eb_border), 3);
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (eb_border), FALSE);
+ notes_note->title = gtk_label_new (notes_note_name);
+ gtk_container_add (GTK_CONTAINER (eb_border),
+ notes_note->title);
- gtk_widget_show_all (notes->note->window);
+ /* Scrolled window */
+ notes_note->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (notes_note->scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
- gtk_window_set_keep_above (GTK_WINDOW (notes->note->window),
- notes->options.always_on_top);
+ /* Text view */
+ notes_note->text_view = gtk_text_view_new ();
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (notes_note->text_view));
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (notes_note->text_view), GTK_WRAP_WORD);
+ gtk_container_add (GTK_CONTAINER (notes_note->scrolled_window),
+ notes_note->text_view);
- if (notes->options.stick)
- gtk_window_stick (GTK_WINDOW (notes->note->window));
- else
- gtk_window_unstick (GTK_WINDOW (notes->note->window));
+ /* Notebook */
+ gtk_notebook_append_page (GTK_NOTEBOOK (notes_window->notebook),
+ notes_note->scrolled_window,
+ eb_border);
+ /* gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notes_window->notebook),
+ (gboolean) g_slist_length (notes_window->notes)); FIXME */
- if (!notes->options.task_switcher)
- {
- gtk_window_set_skip_pager_hint (GTK_WINDOW (notes->note->window), TRUE);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (notes->note->window), TRUE);
- }
+ /* Signals FIXME */
+ g_signal_connect (notes_note->text_view,
+ "key-press-event",
+ G_CALLBACK (notes_note_key_pressed),
+ notes_note);
+ g_signal_connect (buffer,
+ "changed",
+ G_CALLBACK (notes_note_buffer_changed),
+ notes_window->panel_plugin);
+ g_signal_connect (eb_border,
+ "button-press-event",
+ G_CALLBACK (notes_note_rename),
+ notes_window);
- if (!notes->options.statusbar)
- {
- gtk_widget_hide (notes->note->statusbar);
- /* and fix some GTK+2 oddy */
- if (notes->note->x != -1 && notes->note->y != -1)
- {
- gtk_window_move (GTK_WINDOW (notes->note->window),
- notes->note->x,
- notes->note->y);
- }
- }
- }
- else
- {
- gtk_window_get_position (GTK_WINDOW (notes->note->window),
- ¬es->note->x, ¬es->note->y);
- if (GTK_WIDGET_VISIBLE (notes->note->notebook))
- gtk_window_get_size (GTK_WINDOW (notes->note->window),
- ¬es->note->w, ¬es->note->h);
- else
- gtk_window_get_size (GTK_WINDOW (notes->note->window),
- ¬es->note->w, NULL);
+ /* Load data */
+ notes_note_load_data (notes_note, buffer);
- gtk_widget_hide (notes->note->window);
- }
+ /* Show the stuff */
+ /* gtk_widget_show_all (eb_border); XXX */
+ gtk_widget_show_all (notes_note->scrolled_window);
- return FALSE;
+ return notes_note;
}
-static void
-on_options_response (GtkWidget *widget, int response, NotesPlugin *notes)
+void
+notes_note_load_data (NotesNote *notes_note
+ GtkTextBuffer *buffer)
{
- xfce_panel_plugin_unblock_menu (notes->plugin);
- gtk_widget_destroy (widget);
+ gchar *note_name;
+ gchar *filename;
+ gchar *contents = NULL;
- notes_save (notes->plugin, notes);
-}
+ note_name = gtk_label_get_text (notes_note->title);
+ if (G_UNLIKELY (g_ascii_strncasecmp (note_name, "", 1) == 0))
+ {
+ guint id = g_slist_length (notes_note->notes_window->notes);
+ gchar *note_name_tmp = g_strdup_printf ("%d", id);
+ gtk_label_set_text (notes_note->title, note_name_tmp);
+ note_name = gtk_label_get_text (notes_note->title);
+ g_free (note_name_tmp);
+ }
+ filename = g_build_path (G_DIR_SEPARATOR_S,
+ notes_note->notes_window->notes_plugin->notes_path,
+ notes_note->notes_window->title,
+ notes_name,
+ NULL);
-/* handle user messages */
+ if (G_LIKELY (g_file_get_contents (filename, &contents, NULL, NULL)))
+ {
+ gtk_text_buffer_set_text (buffer, contents, -1);
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (notes_note->text_view), buffer);
+ }
-static gboolean
-notes_message_received (GtkWidget *widget, GdkEventClient *ev, gpointer data)
-{
- NotesPlugin *notes;
-
- notes = data;
-
- if (ev->data_format == 8 && *(ev->data.b) != '\0')
- {
- if (!strcmp (XFCE_NOTES_MESSAGE, ev->data.b))
- {
- notes_button_clicked (notes->plugin, notes);
- /* Show the text view */
- gtk_widget_show (notes->note->notebook);
- gtk_window_resize (GTK_WINDOW (notes->note->window),
- notes->note->w, notes->note->h);
- return TRUE;
- }
- }
-
- return FALSE;
+ g_free (contents);
+ g_free (filename);
}
-static gboolean
-notes_set_selection (NotesPlugin *notes)
-{
- GdkScreen *gscreen;
- gchar selection_name[32];
- Atom selection_atom;
- GtkWidget *win;
- Window xwin;
-
- win = gtk_invisible_new ();
- gtk_widget_realize (win);
- xwin = GDK_WINDOW_XID (GTK_WIDGET (win)->window);
-
- gscreen = gtk_widget_get_screen (win);
- g_snprintf (selection_name, sizeof (selection_name),
- XFCE_NOTES_SELECTION"%d", gdk_screen_get_number (gscreen));
- selection_atom = XInternAtom (GDK_DISPLAY (), selection_name, FALSE);
-
- if (XGetSelectionOwner (GDK_DISPLAY (), selection_atom))
- {
- gtk_widget_destroy (win);
- return FALSE;
- }
-
- XSelectInput (GDK_DISPLAY (), xwin, PropertyChangeMask);
- XSetSelectionOwner (GDK_DISPLAY (), selection_atom, xwin, GDK_CURRENT_TIME);
-
- g_signal_connect (win, "client-event",
- G_CALLBACK (notes_message_received), notes);
-
- return TRUE;
-}
-
Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.h 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.h 2007-10-10 21:54:46 UTC (rev 3320)
@@ -20,39 +20,89 @@
#ifndef NOTES_H
#define NOTES_H
-#include <gdk/gdkkeysyms.h>
+/* #include <gdk/gdkkeysyms.h> FIXME */
-#include "notes-window.h"
+typedef struct _NotesPlugin NotesPlugin;
+struct _NotesPlugin
+{
+ XfcePanelPlugin *panel_plugin;
+ GSList *windows;
+ /* guint timeout_id; FIXME */
+ gchar *config_file;
+ gchar *notes_path;
-typedef struct
+ GtkWidget *btn_panel;
+ GtkWidget *icon;
+
+ GtkTooltips *tooltips;
+};
+
+typedef enum _ShowOnStartup ShowOnStartup;
+enum _ShowOnStartup
{
- gboolean visible;
- gboolean show;
- gboolean task_switcher;
- gboolean always_on_top;
- gboolean stick;
- gboolean statusbar;
-}
-NotesOptions;
+ LAST_STATE,
+ ALWAYS,
+ NEVER,
+};
-typedef struct
+typedef struct _NotesWindow NotesWindow;
+struct _NotesWindow
{
- XfcePanelPlugin *plugin;
+ NotesPlugin *notes_plugin;
+ GSList *notes;
- GtkWidget *button;
- GtkWidget *icon;
- GtkTooltips *tooltips;
+ gint x, y, w, h;
+ gboolean always_on_top;
+ gboolean show_in_pager; /* XXX Replaces show in task switcher */
+ ShowOnStartup show_on_startup;
+ gboolean show_statusbar;
+ gboolean stick;
+ gboolean visible;
- Note *note;
- NotesOptions options;
+ GtkWidget *window;
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *btn_add;
+ GtkWidget *btn_del;
+ GtkWidget *btn_close;
+ GtkWidget *title;
+ GtkWidget *eb_move; /* event box */
+ GtkWidget *notebook;
+ GtkWidget *statusbar;
+};
- guint timeout_id;
-}
-NotesPlugin;
+typedef struct _NotesNote NotesNote;
+struct _NotesNote
+{
+ NotesWindow *notes_window;
-NotesPlugin * notes_new (XfcePanelPlugin *);
-Note * note_new (NotesPlugin *);
-void note_page_new (XfcePanelPlugin *, NotesPlugin *);
-void save_on_timeout (NotesPlugin *);
+ GtkWidget *title;
+ GtkWidget *scrolled_window;
+ GtkWidget *text_view;
+};
+typedef struct _NotesOptions NotesOptions;
+struct _NotesOptions
+{
+};
+
+gchar * notes_window_read_name (NotesPlugin *notes_plugin);
+
+NotesWindow * notes_window_new (NotesPlugin *notes_plugin,
+ gchar *notes_window_name);
+void notes_window_load_data (NotesWindow *notes_window);
+
+void notes_window_configure (NotesWindow *notes_window);
+
+void notes_window_response (GtkWidget *widget,
+ int response,
+ NotesWindow *notes_window);
+gchar * notes_note_read_name (NotesWindow *notes_window);
+
+NotesNote * notes_note_new (NotesWindow *notes_window,
+ gchar *notes_note_name);
+void notes_note_load_data (NotesNote *notes_note,
+ GtkTextBuffer *buffer);
+
#endif
Added: xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c 2007-10-10 21:54:46 UTC (rev 3320)
@@ -0,0 +1,211 @@
+/* $Id$
+ *
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (C) 2003 Jakob Henriksson <b0kaj+dev at lysator.liu.se>
+ * Copyright (C) 2006 Mike Massonnet <mmassonnet at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfce4panel/xfce-panel-convenience.h>
+
+#include "notes.h"
+
+#define PLUGIN_NAME "xfce4-notes-plugin"
+
+
+
+static void notes_plugin_register (XfcePanelPlugin *panel_plugin);
+
+static NotesPlugin *notes_plugin_new (XfcePanelPlugin *panel_plugin);
+
+static void notes_plugin_load_data (NotesPlugin *notes_plugin);
+
+static gboolean notes_plugin_set_size (NotesPlugin *notes_plugin,
+ int size);
+static void notes_plugin_save (NotesPlugin *notes_plugin);
+
+static void notes_plugin_free (NotesPlugin *notes_plugin);
+
+static gboolean notes_plugin_popup (NotesPlugin *notes_plugin);
+
+/* TODO sort the next functions */
+static gboolean save_on_timeout_execute (NotesPlugin *notes_plugin);
+
+static void save_on_timeout (NotesPlugin *notes);
+
+
+
+
+static void
+notes_plugin_register (XfcePanelPlugin *panel_plugin)
+{
+ DBG ("Properties: size = %d, screen_position = %d",
+ xfce_panel_plugin_get_size (panel_plugin),
+ xfce_panel_plugin_get_screen_position (panel_plugin));
+
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+ NotesPlugin *notes_plugin = notes_plugin_new (panel_plugin);
+ g_return_if_fail (G_UNLIKELY (!notes_plugin));
+ notes_plugin_load_data (notes_plugin);
+}
+
+static NotesPlugin *
+notes_plugin_new (XfcePanelPlugin *panel_plugin)
+{
+ NotesPlugin *notes_plugin = g_slice_new0 (NotesPlugin);
+ notes_plugin->panel_plugin = panel_plugin;
+ /* notes_plugin->timeout_id = 0; FIXME */
+
+ notes_plugin->btn_panel = xfce_create_panel_button ();
+ notes_plugin->icon = gtk_image_new ();
+ notes_plugin->tooltips = gtk_tooltips_new ();
+
+ gtk_container_add (GTK_CONTAINER (notes_plugin->btn_panel),
+ notes_plugin->icon);
+ gtk_container_add (GTK_CONTAINER (panel_plugin),
+ notes_plugin->btn_panel);
+
+ xfce_panel_plugin_add_action_widget (panel_plugin, notes_plugin->btn_panel);
+ xfce_panel_plugin_menu_show_configure (panel_plugin);
+
+ g_signal_connect (panel_plugin,
+ "configure-plugin",
+ G_CALLBACK (notes_plugin_configure),
+ notes_plugin);
+ g_signal_connect (panel_plugin,
+ "size-changed",
+ G_CALLBACK (notes_plugin_set_size),
+ notes_plugin);
+ g_signal_connect (notes_plugin->btn_panel,
+ "clicked",
+ G_CALLBACK (notes_plugin_popup),
+ notes_plugin);
+ g_signal_connect (panel_plugin,
+ "save",
+ G_CALLBACK (notes_plugin_save),
+ notes_plugin);
+ g_signal_connect (panel_plugin,
+ "free-data",
+ G_CALLBACK (notes_plugin_free),
+ notes_plugin);
+
+ return notes_plugin;
+}
+
+static void
+notes_plugin_load_data (NotesPlugin *notes_plugin)
+{
+ DBG ("Look up file: %s\nNotes path: %s", notes_plugin->config_file,
+ notes_plugin->notes_path);
+ NotesWindow *notes_window;
+ gchar *notes_window_name;
+
+ notes_plugin->notes_path =
+ xfce_resource_save_location (XFCE_RESOURCE_DATA,
+ "notes/",
+ TRUE);
+ g_return_if_fail (G_UNLIKELY (!notes_plugin->notes_path));
+
+ notes_plugin->config_file =
+ xfce_panel_plugin_lookup_rc_file (notes_plugin->panel_plugin);
+ g_return_if_fail (G_UNLIKELY (!notes_plugin->config_file));
+
+ do
+ {
+ window_name = notes_window_read_name (notes_plugin);
+ notes_window = notes_window_new (notes_plugin, window_name);
+ notes_window->notes_plugin = notes_plugin;
+ g_slist_append (notes_plugin->windows, notes_window);
+
+ }
+ while (G_LIKELY (window_name != NULL));
+}
+
+static gboolean
+notes_plugin_set_size (NotesPlugin *notes_plugin,
+ int size)
+{
+ DBG ("Set size to %d", size);
+
+ gtk_widget_set_size_request (notes_plugin->btn_panel, size, size);
+ size = size - 2 - (2 * MAX (notes_plugin->btn_panel->style->xthickness,
+ notes_plugin->btn_panel->style->ythickness));
+ GdkPixbuf *pixbuf = xfce_themed_icon_load ("xfce4-notes-plugin", size);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (notes_plugin->icon), pixbuf);
+ g_object_unref (G_OBJECT (pixbuf));
+
+ return TRUE;
+}
+
+static void
+notes_plugin_save (NotesPlugin *notes_plugin)
+{
+ g_slist_foreach (notes_plugin->windows, notes_window_save, NULL);
+}
+
+static void
+notes_plugin_free (NotesPlugin *notes_plugin)
+{
+ /* if (notes->timeout_id > 0)
+ g_source_remove (notes->timeout_id); FIXME */
+
+ notes_plugin_save (notes_plugin);
+ gtk_main_quit ();
+}
+
+static gboolean
+notes_plugin_popup (NotesPlugin *notes_plugin)
+{
+ return FALSE;
+}
+
+
+
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (notes_plugin_register);
+
+/* TODO sort the next functions */
+
+static gboolean
+save_on_timeout_execute (NotesPlugin *notes)
+{
+ notes_save (notes->plugin, notes);
+ return FALSE;
+}
+
+static void
+save_on_timeout (NotesPlugin *notes)
+{
+ /*if (notes->timeout_id > 0)
+ {
+ g_source_remove (notes->timeout_id);
+ notes->timeout_id = 0;
+ }
+ notes->timeout_id = g_timeout_add (60000, (GSourceFunc) save_on_timeout_execute, notes);*/
+}
+
Modified: xfce4-notes-plugin/trunk/po/POTFILES.in
===================================================================
--- xfce4-notes-plugin/trunk/po/POTFILES.in 2007-10-09 20:38:36 UTC (rev 3319)
+++ xfce4-notes-plugin/trunk/po/POTFILES.in 2007-10-10 21:54:46 UTC (rev 3320)
@@ -1,7 +1,4 @@
+panel-plugin/panel-plugin.c
panel-plugin/notes.c
panel-plugin/notes.h
-panel-plugin/notes-options.c
-panel-plugin/notes-options.h
-panel-plugin/notes-window.c
-panel-plugin/notes-window.h
panel-plugin/xfce4-notes-plugin.desktop.in.in
More information about the Goodies-commits
mailing list