[Goodies-commits] r7413 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sun May 24 10:15:05 CEST 2009
Author: mmassonnet
Date: 2009-05-24 08:15:05 +0000 (Sun, 24 May 2009)
New Revision: 7413
Modified:
xfce4-notes-plugin/trunk/ChangeLog
xfce4-notes-plugin/trunk/panel-plugin/application.vala
xfce4-notes-plugin/trunk/panel-plugin/window.vala
Log:
Create/delete/rename note groups
Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog 2009-05-24 05:23:55 UTC (rev 7412)
+++ xfce4-notes-plugin/trunk/ChangeLog 2009-05-24 08:15:05 UTC (rev 7413)
@@ -1,3 +1,17 @@
+2009-05-24 Mike Massonnet <mmassonnet at xfce.org>
+
+Create/delete/rename note groups
+ * panel-plugin/window.vala:
+ - Set window_list unowned (spares the copy of the list).
+ - New signal action. On activate Create/delete/rename items in the
+ menu Go send signals with a string describing the action.
+ - On window.name changes update the title too.
+ * panel-plugin/application.vala:
+ - Set Xnp.Window objects owned within window_list, otherwise the
+ instantiated objects get unrefed at the end of create_window.
+ - Connect to signal action in create_window.
+ - New methods rename_window and delete_window.
+
2009-05-23 Mike Massonnet <mmassonnet at xfce.org>
Display window list in menu Go
Modified: xfce4-notes-plugin/trunk/panel-plugin/application.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-05-24 05:23:55 UTC (rev 7412)
+++ xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-05-24 08:15:05 UTC (rev 7413)
@@ -26,22 +26,30 @@
public class Application : GLib.Object {
- private SList<unowned Xnp.Window> window_list;
+ private SList<Xnp.Window> window_list;
public Application () {
- /* TODO Load existing notes */
-
- /* Load an empty note */
+ /* TODO Load existing windows */
+ /* Create an initial empty window */
create_window (null);
create_window (null);
+ create_window (null);
}
+ /*
+ * Window management
+ */
+
+ /**
+ * create_window:
+ *
+ * Creates a new Xnp.Window and stores it inside window_list.
+ */
public void create_window (string? name) {
var window = new Xnp.Window ();
this.window_list.append (window);
foreach (var win in this.window_list) {
- win.set_window_list (ref this.window_list);
- debug ("%p.set_window_list (%p)", win, this.window_list);
+ win.set_window_list (this.window_list);
}
if (name == null) {
@@ -55,21 +63,89 @@
this.load_window_data (window);
+ window.action += (win, action) => {
+ if (action == "rename") {
+ rename_window (win);
+ }
+ else if (action == "delete") {
+ delete_window (win);
+ }
+ else if (action == "create-new-window") {
+ create_window (null);
+ }
+ };
+
window.show ();
}
+ /**
+ * load_window_data:
+ *
+ * Looks up the window name for existing notes otherwise
+ * inserts an initial empty note.
+ */
private void load_window_data (Xnp.Window window) {
+ /* TODO load existing notes */
window.insert_note ();
}
-/**/
- static int main (string[] args) {
- Gtk.init (ref args);
- new Xnp.Application ();
- Gtk.main ();
- return 0;
+ /**
+ * rename_window:
+ *
+ * Renames the window name.
+ */
+ private void rename_window (Xnp.Window window) {
+ var dialog = new Gtk.Dialog.with_buttons ("Rename group", window,
+ Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK);
+ dialog.set_default_response (Gtk.ResponseType.OK);
+ dialog.resizable = false;
+ dialog.icon_name = Gtk.STOCK_EDIT;
+ dialog.border_width = 4;
+ dialog.vbox.border_width = 6;
+
+ var entry = new Gtk.Entry ();
+ entry.text = window.name;
+ entry.activates_default = true;
+ dialog.vbox.add (entry);
+ dialog.vbox.show_all ();
+
+ int res = dialog.run ();
+ dialog.hide ();
+ if (res == Gtk.ResponseType.OK)
+ window.name = entry.text;
+ dialog.destroy ();
}
+ /**
+ * delete_window:
+ *
+ * Delte the window.
+ */
+ private void delete_window (Xnp.Window window) {
+ this.window_list.remove (window);
+ window.destroy ();
+
+ if (this.window_list.length () >= 1) {
+ foreach (var win in this.window_list) {
+ win.set_window_list (this.window_list);
+ }
+ }
+ else {
+ create_window (null);
+ }
+ }
+
+/**/
}
}
+
+static int main (string[] args) {
+ Gtk.init (ref args);
+ var app = new Xnp.Application ();
+ Gtk.main ();
+ app.unref ();
+ return 0;
+}
+
Modified: xfce4-notes-plugin/trunk/panel-plugin/window.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-05-24 05:23:55 UTC (rev 7412)
+++ xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-05-24 08:15:05 UTC (rev 7413)
@@ -50,7 +50,7 @@
private Gdk.Cursor CURSOR_BOTTOM = new Gdk.Cursor (Gdk.CursorType.BOTTOM_SIDE);
private Gdk.Cursor CURSOR_BOTTOM_LC = new Gdk.Cursor (Gdk.CursorType.BOTTOM_LEFT_CORNER);
- private SList<unowned Xnp.Window> window_list;
+ private unowned SList<unowned Xnp.Window> window_list;
public new string name { default = "Notes"; get; set; }
@@ -79,6 +79,8 @@
}
}
+ public signal void action (string action);
+
construct {
base.name = "xfce4-notes-plugin";
this.title = "Notes";
@@ -240,7 +242,14 @@
update_navigation_sensitivity ((int)p);
};
notify += (o, p) => {
- if (p.name == "title") {
+ if (p.name == "name") {
+ int page = this.notebook.get_current_page ();
+ if (page == -1)
+ return;
+ var current_note = (Xnp.Note)(this.notebook.get_nth_page (page));
+ update_title (current_note.name);
+ }
+ else if (p.name == "title") {
title_label.set_markup ("<b>"+title+"</b>");
}
};
@@ -606,8 +615,8 @@
mi = new Gtk.MenuItem.with_label (win.name);
mi.set_data ("window", (void*)win);
mi.activate += (i) => {
- debug ("present window X");
- //var win = (Xnp.Window)i.get_data ("window");
+ var w = (Xnp.Window)i.get_data ("window");
+ w.present ();
};
menu.append (mi);
@@ -622,6 +631,7 @@
((Gtk.ImageMenuItem)mi).set_image (image);
//mi.add_accelerator ("activate", this.accel_group, '<F2>',
// Gdk.ModifierType.SHIFT_MASK, Gtk.AccelFlags.MASK);
+ mi.activate += () => { action ("rename"); };
menu.append (mi);
mi = new Gtk.ImageMenuItem.with_mnemonic ("_Delete group");
@@ -629,6 +639,7 @@
((Gtk.ImageMenuItem)mi).set_image (image);
mi.add_accelerator ("activate", this.accel_group, 'W',
Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.MASK);
+ mi.activate += () => { action ("delete"); };
menu.append (mi);
mi = new Gtk.ImageMenuItem.with_mnemonic ("_Add a new group");
@@ -636,6 +647,7 @@
((Gtk.ImageMenuItem)mi).set_image (image);
mi.add_accelerator ("activate", this.accel_group, 'N',
Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.MASK);
+ mi.activate += () => { action ("create-new-window"); };
menu.append (mi);
menu.show_all ();
@@ -647,12 +659,12 @@
* Saves a list of window inside window.window_list to be shown
* within the window menu.
*/
- public void set_window_list (ref SList<Xnp.Window> list) {
- this.window_list = list.copy ();
+ public void set_window_list (SList<Xnp.Window> list) {
+ this.window_list = list;
}
/*
- * Private methods
+ * Window management
*/
/**
@@ -708,7 +720,7 @@
}
/*
- * Public methods
+ * Note management
*/
/**
More information about the Goodies-commits
mailing list