[Goodies-commits] r4679 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sun Apr 27 19:43:40 CEST 2008
Author: mmassonnet
Date: 2008-04-27 17:43:40 +0000 (Sun, 27 Apr 2008)
New Revision: 4679
Added:
xfce4-notes-plugin/trunk/panel-plugin/defines.h
Modified:
xfce4-notes-plugin/trunk/configure.in.in
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/panel-plugin/panel-plugin.c
Log:
Add configuration dialog (need xfconf)
* configure.in.in:
- Add optional build flag for the configuration dialog
* panel-plugin/Makefile.am:
- Add build deps and compilation for new files
* panel-plugin/defines.h:
- New file with common defines
* panel-plugin/notes.c(notes_window_new_with_label):
- Get default window geometry with xfconf (optional)
- Drop gtk_tooltips, and put gtk_tooltip instead (only with GTK+>=2.12.0)
* panel-plugin/notes.c(notes_window_load_data):
- Load default data from xfconf (optional)
* panel-plugin/notes.h:
- Quick clean up
* panel-plugin/panel-plugin.c:
- Add optional "configure-plugin" callback
Modified: xfce4-notes-plugin/trunk/configure.in.in
===================================================================
--- xfce4-notes-plugin/trunk/configure.in.in 2008-04-27 17:43:33 UTC (rev 4678)
+++ xfce4-notes-plugin/trunk/configure.in.in 2008-04-27 17:43:40 UTC (rev 4679)
@@ -46,11 +46,33 @@
XDT_CHECK_LIBX11_REQUIRE
dnl configure the panel plugin
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0])
+dnl check for xfconf
+m4_define([xfconf_minimum_version], [0])
+AC_ARG_ENABLE([configure-dialog],
+ [AC_HELP_STRING([--enable-configure-dialog],
+ [Build with configure dialog (xfce >= 4.5)])],
+ [xfconf=$enableval],
+ [xfconf=no])
+if test "x$xfconf" = "xyes"; then
+ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [xfconf_minimum_version], [have_xfconf=yes],
+ [
+ echo "*** Optional package libxfconf-0 was either not found on your system"
+ echo "*** or is too old. Please install or upgrade to at least version"
+ echo "*** xfconf_minimum_version, or adjust the PKG_CONFIG_PATH environment variable"
+ echo "*** if you installed the new version of the package in a nonstandard"
+ echo "*** prefix. Configuration dialog will be disabled."
+ ])
+
+ if test "x$have_xfconf" = "xyes" ; then
+ AC_DEFINE([HAVE_XFCONF], [1], [Define if Xfconf is present])
+ fi
+fi
+
dnl check for thunar_vfs
m4_define([thunar_minimum_version], [0.8.0])
AC_ARG_ENABLE([fs-monitor],
@@ -59,14 +81,14 @@
[thunar_vfs=$enableval],
[thunar_vfs=yes])
if test "x$thunar_vfs" = "xyes" ; then
- XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1],
- [thunar_minimum_version], [have_thunar_vfs=yes], [
-echo "*** Optional package thunar-vfs-1 was either not found on your system"
-echo "*** or is too old. Please install or upgrade to at least version"
-echo "*** thunar_minimum_version, or adjust the PKG_CONFIG_PATH environment variable"
-echo "*** if you installed the new version of the package in a nonstandard"
-echo "*** prefix. File system monitoring will be disabled."
-])
+ XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1], [thunar_minimum_version], [have_thunar_vfs=yes],
+ [
+ echo "*** Optional package thunar-vfs-1 was either not found on your system"
+ echo "*** or is too old. Please install or upgrade to at least version"
+ echo "*** thunar_minimum_version, or adjust the PKG_CONFIG_PATH environment variable"
+ echo "*** if you installed the new version of the package in a nonstandard"
+ echo "*** prefix. File system monitoring will be disabled."
+ ])
if test "x$have_thunar_vfs" = "xyes" ; then
AC_DEFINE([HAVE_THUNAR_VFS], [1], [Define if thunar-vfs is present.])
Modified: xfce4-notes-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2008-04-27 17:43:33 UTC (rev 4678)
+++ xfce4-notes-plugin/trunk/panel-plugin/Makefile.am 2008-04-27 17:43:40 UTC (rev 4679)
@@ -18,6 +18,8 @@
xfce4_notes_plugin_SOURCES = \
panel-plugin.c \
+ notes-properties-dialog.c \
+ notes-properties-dialog.h \
notes.c \
notes.h
@@ -27,13 +29,15 @@
@LIBXFCE4UTIL_CFLAGS@ \
@LIBXFCEGUI4_CFLAGS@ \
@THUNAR_VFS_CFLAGS@ \
+ @XFCONF_CFLAGS@ \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\"
xfce4_notes_plugin_LDADD = \
@LIBXFCE4PANEL_LIBS@ \
@LIBXFCE4UTIL_LIBS@ \
@LIBXFCEGUI4_LIBS@ \
- @THUNAR_VFS_LIBS@
+ @THUNAR_VFS_LIBS@ \
+ @XFCONF_LIBS@
desktop_in_in_files = xfce4-notes-plugin.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
Added: xfce4-notes-plugin/trunk/panel-plugin/defines.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/defines.h (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/defines.h 2008-04-27 17:43:40 UTC (rev 4679)
@@ -0,0 +1,26 @@
+/* $Id$
+ *
+ * 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 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
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef DEFINES_H
+#define DEFINES_H
+
+#define BORDER 8
+
+#endif
+
Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.c 2008-04-27 17:43:33 UTC (rev 4678)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.c 2008-04-27 17:43:40 UTC (rev 4679)
@@ -1,7 +1,7 @@
-/* $Id$
+/*
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (c) 2006-2008 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
* the Free Software Foundation; either version 2 of the License, or
@@ -29,13 +29,15 @@
#include <gdk/gdkkeysyms.h>
#include <libxfce4util/libxfce4util.h>
+#ifdef HAVE_XFCONF
+#include <xfconf/xfconf.h>
+#endif
+
#include "notes.h"
#define PLUGIN_NAME "xfce4-notes-plugin"
#define OPAQUE 0xffffffff
-
-
#ifdef HAVE_THUNAR_VFS
static void notes_window_fs_event (ThunarVfsMonitor *monitor,
ThunarVfsMonitorHandle *handle,
@@ -166,11 +168,23 @@
notes_window->notes = NULL;
notes_window->name = g_strdup (window_name);
+#ifdef HAVE_XFCONF
+ /* Configuration channel */
+ xfconf_init (NULL);
+ XfconfChannel *channel = xfconf_channel_new ("/Xfce4NotesPlugin/DefaultSettings");
+#endif
+
/* Window */
notes_window->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_deletable (GTK_WINDOW (notes_window->window), FALSE);
gtk_window_set_title (GTK_WINDOW (notes_window->window), window_name);
- gtk_window_set_default_size (GTK_WINDOW (notes_window->window), 375, 430);
+ gtk_window_set_default_size (GTK_WINDOW (notes_window->window),
+#ifdef HAVE_XFCONF
+ xfconf_channel_get_int (channel, "/window_geometry/width", 375),
+ xfconf_channel_get_int (channel, "/window_geometry/height", 430));
+#else
+ 375, 430);
+#endif
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);
@@ -308,30 +322,23 @@
GTK_ACCEL_MASK);
/* Tooltips */
+#if GTK_CHECK_VERSION(2,12,0)
accel_name = gtk_accelerator_get_label ('N', GDK_CONTROL_MASK);
- gtk_tooltips_set_tip (GTK_TOOLTIPS (notes_window->notes_plugin->tooltips),
- notes_window->btn_add,
- accel_name,
- NULL);
+ gtk_widget_set_tooltip_text (notes_window->btn_add, accel_name);
g_free (accel_name);
+
accel_name = gtk_accelerator_get_label ('W', GDK_CONTROL_MASK);
- gtk_tooltips_set_tip (GTK_TOOLTIPS (notes_window->notes_plugin->tooltips),
- notes_window->btn_del,
- accel_name,
- NULL);
+ gtk_widget_set_tooltip_text (notes_window->btn_del, accel_name);
g_free (accel_name);
+
accel_name = gtk_accelerator_get_label ('M', GDK_CONTROL_MASK);
- gtk_tooltips_set_tip (GTK_TOOLTIPS (notes_window->notes_plugin->tooltips),
- notes_window->btn_menu,
- accel_name,
- NULL);
+ gtk_widget_set_tooltip_text (notes_window->btn_menu, accel_name);
g_free (accel_name);
+
accel_name = gtk_accelerator_get_label (GDK_Escape, 0);
- gtk_tooltips_set_tip (GTK_TOOLTIPS (notes_window->notes_plugin->tooltips),
- notes_window->btn_close,
- accel_name,
- NULL);
+ gtk_widget_set_tooltip_text (notes_window->btn_close, accel_name);
g_free (accel_name);
+#endif
/* Load data */
notes_window_load_data (notes_window);
@@ -478,6 +485,15 @@
XfceRc *rc;
NotesNote *notes_note;
const gchar *note_name;
+ gint w = 375;
+ gint h = 430;
+ gboolean above = FALSE;
+ ShowOnStartup show_on_startup = LAST_STATE;
+ gboolean show_statusbar = FALSE;
+ gboolean sticky = TRUE;
+ gboolean visible = TRUE;
+ gint transparency = 10;
+ gchar *font_descr = NULL;
if (G_LIKELY (NULL == notes_window->name))
{
@@ -508,40 +524,57 @@
gtk_window_set_title (GTK_WINDOW (notes_window->window), notes_window->name);
}
+#ifdef HAVE_XFCONF
+ xfconf_init (NULL);
+ XfconfChannel *channel = xfconf_channel_new ("/Xfce4NotesPlugin/DefaultSettings");
+ w = xfconf_channel_get_int (channel, "/window_geometry/width", w);
+ h = xfconf_channel_get_int (channel, "/window_geometry/height", h);
+ above = xfconf_channel_get_bool (channel, "/window_state/always_on_top", above);
+ show_on_startup = xfconf_channel_get_bool (channel, "/window_state/show_on_startup", show_on_startup);
+ show_statusbar = xfconf_channel_get_bool (channel, "/window_state/resize_grip", show_statusbar);
+ sticky = xfconf_channel_get_bool (channel, "/window_state/sticky", sticky);
+ visible = xfconf_channel_get_bool (channel, "/window_state/visible", visible);
+ transparency = xfconf_channel_get_int (channel, "/window_state/transparency", transparency);
+ if (xfconf_channel_get_bool (channel, "/window_state/use_font", FALSE))
+ font_descr = xfconf_channel_get_string (channel, "/window_font/description", "Sans 10");
+ g_object_unref (channel);
+#endif
+
rc = xfce_rc_simple_open (notes_window->notes_plugin->config_file, FALSE);
xfce_rc_set_group (rc, notes_window->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);
+ notes_window->w = xfce_rc_read_int_entry (rc, "Width", w);
+ notes_window->h = xfce_rc_read_int_entry (rc, "Height", h);
- notes_window->above = xfce_rc_read_bool_entry (rc, "Above", FALSE);
- notes_window->show_on_startup = xfce_rc_read_int_entry (rc, "ShowOnStartup", LAST_STATE);
- notes_window->show_statusbar = xfce_rc_read_bool_entry (rc, "ShowStatusbar", FALSE);
- notes_window->sticky = xfce_rc_read_bool_entry (rc, "Sticky", TRUE);
- notes_window->visible = xfce_rc_read_bool_entry (rc, "Visible", TRUE);
- notes_window->transparency = xfce_rc_read_int_entry (rc, "Transparency", 10);
- notes_window->font = g_strdup (xfce_rc_read_entry (rc, "Font", NULL));
+ notes_window->above = xfce_rc_read_bool_entry (rc, "Above", above);
+ notes_window->show_on_startup = xfce_rc_read_int_entry (rc, "ShowOnStartup", show_on_startup);
+ notes_window->show_statusbar = xfce_rc_read_bool_entry (rc, "ShowStatusbar", show_statusbar);
+ notes_window->sticky = xfce_rc_read_bool_entry (rc, "Sticky", sticky);
+ notes_window->visible = xfce_rc_read_bool_entry (rc, "Visible", visible);
+ notes_window->transparency = xfce_rc_read_int_entry (rc, "Transparency", transparency);
+ notes_window->font = g_strdup (xfce_rc_read_entry (rc, "Font", font_descr));
+ g_free (font_descr);
xfce_rc_close (rc);
- TRACE ("\nname: %s"
- "\ngeometry: %d/%d:%dx%d"
- "\nabove: %d"
- "\nshow_on_startup: %d"
- "\nshow_statusbar: %d"
- "\nsticky: %d"
- "\nvisible: %d"
- "\ntransparency: %d",
- notes_window->name,
- notes_window->x, notes_window->y, notes_window->w, notes_window->h,
- notes_window->above,
- notes_window->show_on_startup,
- notes_window->show_statusbar,
- notes_window->sticky,
- notes_window->visible,
- notes_window->transparency);
+ DBG ("\nname: %s"
+ "\ngeometry: %d/%d:%dx%d"
+ "\nabove: %d"
+ "\nshow_on_startup: %d"
+ "\nshow_statusbar: %d"
+ "\nsticky: %d"
+ "\nvisible: %d"
+ "\ntransparency: %d",
+ notes_window->name,
+ notes_window->x, notes_window->y, notes_window->w, notes_window->h,
+ notes_window->above,
+ notes_window->show_on_startup,
+ notes_window->show_statusbar,
+ notes_window->sticky,
+ notes_window->visible,
+ notes_window->transparency);
/**
* Make sure we have at least one note if note_name is NULL. After that an
Modified: xfce4-notes-plugin/trunk/panel-plugin/notes.h
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/notes.h 2008-04-27 17:43:33 UTC (rev 4678)
+++ xfce4-notes-plugin/trunk/panel-plugin/notes.h 2008-04-27 17:43:40 UTC (rev 4679)
@@ -1,7 +1,7 @@
-/* $Id$
+/*
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (c) 2006-2008 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
* the Free Software Foundation; either version 2 of the License, or
@@ -28,7 +28,17 @@
#include <thunar-vfs/thunar-vfs.h>
#endif
+typedef enum
+{
+ LAST_STATE,
+ ALWAYS,
+ NEVER,
+} ShowOnStartup;
+
typedef struct _NotesPlugin NotesPlugin;
+typedef struct _NotesWindow NotesWindow;
+typedef struct _NotesNote NotesNote;
+
struct _NotesPlugin
{
XfcePanelPlugin *panel_plugin;
@@ -52,14 +62,6 @@
#endif
};
-typedef enum
-{
- LAST_STATE,
- ALWAYS,
- NEVER,
-} ShowOnStartup;
-
-typedef struct _NotesWindow NotesWindow;
struct _NotesWindow
{
NotesPlugin *notes_plugin;
@@ -100,7 +102,6 @@
#endif
};
-typedef struct _NotesNote NotesNote;
struct _NotesNote
{
NotesWindow *notes_window;
@@ -117,13 +118,8 @@
#endif
};
-typedef struct _NotesOptions NotesOptions;
-struct _NotesOptions
-{
-};
-
const gchar * notes_window_read_name (NotesPlugin *notes_plugin);
NotesWindow * notes_window_new (NotesPlugin *notes_plugin);
Modified: xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c 2008-04-27 17:43:33 UTC (rev 4678)
+++ xfce4-notes-plugin/trunk/panel-plugin/panel-plugin.c 2008-04-27 17:43:40 UTC (rev 4679)
@@ -25,9 +25,13 @@
#endif
#include "notes.h"
+#ifdef HAVE_XFCONF
+#include "notes-properties-dialog.h"
+#endif
#include "xfce4-popup-notes.h"
#define PLUGIN_NAME "xfce4-notes-plugin"
+#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-notes-plugin"
@@ -35,6 +39,9 @@
static NotesPlugin *notes_plugin_new (XfcePanelPlugin *panel_plugin);
+#ifdef HAVE_XFCONF
+static void notes_plugin_configure (NotesPlugin *notes_plugin);
+#endif
static gboolean notes_plugin_set_size (NotesPlugin *notes_plugin,
int size);
static void notes_plugin_load_data (NotesPlugin *notes_plugin);
@@ -118,14 +125,19 @@
notes_plugin->windows = NULL;
notes_plugin->btn_panel = xfce_create_panel_toggle_button ();
notes_plugin->icon_panel = gtk_image_new ();
- notes_plugin->tooltips = gtk_tooltips_new ();
gtk_container_add (GTK_CONTAINER (notes_plugin->btn_panel),
notes_plugin->icon_panel);
gtk_container_add (GTK_CONTAINER (panel_plugin),
notes_plugin->btn_panel);
+#ifdef HAVE_XFCONF
g_signal_connect_swapped (panel_plugin,
+ "configure-plugin",
+ G_CALLBACK (notes_plugin_configure),
+ notes_plugin);
+#endif
+ g_signal_connect_swapped (panel_plugin,
"size-changed",
G_CALLBACK (notes_plugin_set_size),
notes_plugin);
@@ -161,6 +173,9 @@
}
#endif
+#ifdef HAVE_XFCONF
+ xfce_panel_plugin_menu_show_configure (panel_plugin);
+#endif
xfce_panel_plugin_add_action_widget (panel_plugin, notes_plugin->btn_panel);
notes_plugin_set_selection (notes_plugin);
gtk_widget_show_all (notes_plugin->btn_panel);
@@ -168,6 +183,30 @@
return notes_plugin;
}
+#ifdef HAVE_XFCONF
+static void
+notes_plugin_configure (NotesPlugin *notes_plugin)
+{
+ GtkWidget *dialog = prop_dialog_new (notes_plugin);
+ g_return_if_fail (G_LIKELY (GTK_IS_WIDGET (dialog)));
+
+ xfce_panel_plugin_block_menu (notes_plugin->panel_plugin);
+
+ gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (result == GTK_RESPONSE_HELP)
+ {
+ result = g_spawn_command_line_async ("exo-open " PLUGIN_WEBSITE, NULL);
+ if (G_UNLIKELY (result == FALSE))
+ g_warning (_("Unable to open the following url: %s"), PLUGIN_WEBSITE);
+ }
+
+ if (GTK_IS_WIDGET (dialog))
+ gtk_widget_destroy (dialog);
+
+ xfce_panel_plugin_unblock_menu (notes_plugin->panel_plugin);
+}
+#endif
+
static gboolean
notes_plugin_set_size (NotesPlugin *notes_plugin,
int size)
@@ -175,8 +214,8 @@
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));
+ 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_panel), pixbuf);
g_object_unref (G_OBJECT (pixbuf));
More information about the Goodies-commits
mailing list