[Goodies-commits] r7486 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sat Jun 6 22:09:04 CEST 2009
Author: mmassonnet
Date: 2009-06-06 20:09:04 +0000 (Sat, 06 Jun 2009)
New Revision: 7486
Added:
xfce4-notes-plugin/trunk/panel-plugin/main.vala
Modified:
xfce4-notes-plugin/trunk/ChangeLog
xfce4-notes-plugin/trunk/panel-plugin/application.vala
xfce4-notes-plugin/trunk/panel-plugin/hypertextview.vala
xfce4-notes-plugin/trunk/panel-plugin/window.vala
Log:
Vala the panel plugin
Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog 2009-06-06 20:06:05 UTC (rev 7485)
+++ xfce4-notes-plugin/trunk/ChangeLog 2009-06-06 20:09:04 UTC (rev 7486)
@@ -1,5 +1,18 @@
2009-06-06 Mike Massonnet <mmassonnet at xfce.org>
+Vala the panel plugin
+ * panel-plugin/main.vala:
+ - Registers an external panel plugin.
+ - On button click show/hide the notes.
+ * panel-plugin/window.vala:
+ - Replaced the Font menu with the Properties item.
+ * panel-plugin/application.vala:
+ - On action "properties" spawn xfce4-notes-settings.
+ - New method to show_hide_notes. Hides the notes when all are shown.
+ - Moved Xfconf.init/shutdown to main.vala.
+
+2009-06-06 Mike Massonnet <mmassonnet at xfce.org>
+
Overload hide in Xnp.Window
* panel-plugin/window.vala:
- Replace hide_cb in favor of the overloaded hide method.
Modified: xfce4-notes-plugin/trunk/panel-plugin/application.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-06-06 20:06:05 UTC (rev 7485)
+++ xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-06-06 20:09:04 UTC (rev 7486)
@@ -26,23 +26,23 @@
private SList<Xnp.Window> window_list;
private string notes_path;
- private string config_file;
+ public string config_file { get; construct; }
private Xfconf.Channel xfconf_channel;
construct {
notes_path = "%s/notes".printf (GLib.Environment.get_user_data_dir ());
- config_file = "%s/xfce4/panel/xfce4-notes-plugin.rc".printf (GLib.Environment.get_user_config_dir ());
}
- public Application () {
- try {
- Xfconf.init ();
- xfconf_channel = new Xfconf.Channel.with_property_base ("xfce4-panel", "/plugins/notes");
- }
- catch (Xfconf.Error e) {
- warning ("%s", e.message);
- }
+ public Application (string config_file) {
+ this.config_file = config_file;
+ xfconf_channel = new Xfconf.Channel.with_property_base ("xfce4-panel", "/plugins/notes");
+ xfconf_channel.property_changed += (channel, prop, val) => {
+ if (prop == "/global/background-color") {
+ // TODO Xnp.Color.set_background (val);
+ }
+ };
+
string name;
bool found = false;
try {
@@ -64,7 +64,6 @@
save_windows_configuration ();
save_notes ();
xfconf_channel.unref ();
- Xfconf.shutdown ();
}
/*
@@ -151,6 +150,9 @@
else if (action == "create-new-window") {
create_window ();
}
+ else if (action == "properties") {
+ open_settings_dialog ();
+ }
};
window.save_data += (win, note) => {
save_note (win, note);
@@ -245,7 +247,6 @@
* save_windows_configuration:
*
* Save window configuration inside rc file.
- * TODO save font descriptions
*/
public void save_windows_configuration () {
var keyfile = new GLib.KeyFile ();
@@ -279,7 +280,7 @@
*
* Save the contents of every existing notes.
*/
- private void save_notes () {
+ public void save_notes () {
foreach (var win in this.window_list) {
win.save_notes ();
}
@@ -412,22 +413,60 @@
if (!res) {
var error_dialog = new Gtk.MessageDialog (null, 0,
Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, "The name \"%s\" is invalid.", name);
- error_dialog.format_secondary_markup ("The invalid characters are restricted to: <tt>*|/\\:\"<>?</tt>");
+ error_dialog.format_secondary_markup ("The invalid characters are: %s".printf ("<tt>*|/\\:\"<>?</tt>"));
error_dialog.run ();
error_dialog.destroy ();
}
return res;
}
+ /**
+ * show_hide_notes:
+ *
+ * Show all the notes or hide them if they are all shown.
+ */
+ public void show_hide_notes () {
+ bool hide = true;
+ foreach (var win in this.window_list) {
+ if (!(bool)(win.get_flags () & Gtk.WidgetFlags.VISIBLE)) {
+ win.show ();
+ hide = false;
+ }
+ }
+ if (hide) {
+ foreach (var win in this.window_list) {
+ win.hide ();
+ }
+ }
+ }
+
+ /**
+ * open_settings_dialog:
+ *
+ * Open the settings dialog.
+ */
+ public void open_settings_dialog () {
+ try {
+ Gdk.spawn_command_line_on_screen (Gdk.Screen.get_default (), "xfce4-notes-settings");
+ }
+ catch (GLib.Error e) {
+ var error_dialog = new Gtk.MessageDialog (null, Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, "Unable to open the settings dialog");
+ error_dialog.format_secondary_text ("%s", e.message);
+ error_dialog.run ();
+ error_dialog.destroy ();
+ }
+ }
+
}
}
-static int main (string[] args) {
+/*static int main (string[] args) {
Gtk.init (ref args);
- var app = new Xnp.Application ();
+ var app = new Xnp.Application ("/tmp/notes-conf.rc");
Gtk.main ();
app.unref ();
return 0;
-}
+}*/
Modified: xfce4-notes-plugin/trunk/panel-plugin/hypertextview.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/hypertextview.vala 2009-06-06 20:06:05 UTC (rev 7485)
+++ xfce4-notes-plugin/trunk/panel-plugin/hypertextview.vala 2009-06-06 20:09:04 UTC (rev 7486)
@@ -2,9 +2,6 @@
* Notes - panel plugin for Xfce Desktop Environment
* Copyright (c) 2009 Mike Massonnet <mmassonnet at xfce.org>
*
- * TODO:
- * - On set_buffer initialize the undo/redo texts
- *
* 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
Added: xfce4-notes-plugin/trunk/panel-plugin/main.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/main.vala (rev 0)
+++ xfce4-notes-plugin/trunk/panel-plugin/main.vala 2009-06-06 20:09:04 UTC (rev 7486)
@@ -0,0 +1,99 @@
+/*
+ * Notes - panel plugin for Xfce Desktop Environment
+ * Copyright (C) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+using Config;
+using Xfconf;
+using Xfce;
+using Gtk;
+
+public class NotesPlugin : GLib.Object {
+
+ private Gtk.Button button;
+ private Gtk.Image image;
+ private Xfce.PanelPlugin panel_plugin;
+ private Xnp.Application application;
+
+ public NotesPlugin (Xfce.PanelPlugin panel_plugin) {
+ this.panel_plugin = panel_plugin;
+
+ application = new Xnp.Application (panel_plugin.save_location (true));
+
+ button = Xfce.create_panel_button ();
+ image = new Gtk.Image ();
+ button.add (image);
+ button.clicked += () => { application.show_hide_notes (); };
+ button.show_all ();
+ panel_plugin.add (button);
+ panel_plugin.add_action_widget (button);
+ panel_plugin.size_changed += (p, size) => {
+ button.set_size_request (size, size);
+ size -= 2 + 2 * ((button.style.xthickness > button.style.ythickness) ? button.style.xthickness : button.style.ythickness);
+ var pixbuf = Xfce.Icon.load ("xfce4-notes-plugin", size);
+ if (pixbuf == null)
+ pixbuf = Xfce.Icon.load (Gtk.STOCK_EDIT, size);
+ image.set_from_pixbuf (pixbuf);
+ return true;
+ };
+
+ set_x_selection ();
+
+ panel_plugin.save += () => {
+ application.save_windows_configuration ();
+ };
+ panel_plugin.free_data += () => {
+ application.save_windows_configuration ();
+ application.save_notes ();
+ };
+ panel_plugin.configure_plugin += () => {
+ application.open_settings_dialog ();
+ };
+ }
+
+ /**
+ * set_x_selection:
+ *
+ * Set an X selection to listen to for the popup command.
+ */
+ private bool set_x_selection () {
+ // TODO
+ return false;
+ }
+
+
+
+ static NotesPlugin plugin;
+ public static void register (Xfce.PanelPlugin panel_plugin) {
+ plugin = new NotesPlugin (panel_plugin);
+ panel_plugin.set_tooltip_text ("Notes");
+ panel_plugin.menu_show_configure ();
+ }
+
+ public static int main (string[] args) {
+ Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
+ try {
+ Xfconf.init ();
+ }
+ catch (Xfconf.Error e) {
+ warning ("%s", e.message);
+ }
+ Xfce.PanelPluginRegisterExternal (ref args, NotesPlugin.register);
+ Xfconf.shutdown ();
+ return 0;
+ }
+}
Modified: xfce4-notes-plugin/trunk/panel-plugin/window.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-06-06 20:06:05 UTC (rev 7485)
+++ xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-06-06 20:09:04 UTC (rev 7486)
@@ -649,11 +649,6 @@
menu_go.show += update_menu_go;
mi.set_submenu (menu_go);
- /* Properties */
- mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_PROPERTIES, null);
- mi.activate += () => { action ("properties"); };
- menu.append (mi);
-
/* Note items */
mi = new Gtk.SeparatorMenuItem ();
menu.append (mi);
@@ -684,8 +679,8 @@
mi = new Gtk.SeparatorMenuItem ();
menu.append (mi);
- mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_SELECT_FONT, null);
- mi.activate += set_font;
+ mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_PROPERTIES, null);
+ mi.activate += () => { action ("properties"); };
menu.append (mi);
mi = this.mi_above = new Gtk.CheckMenuItem.with_label ("Always on top");
More information about the Goodies-commits
mailing list