[Goodies-commits] r7400 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sat May 23 23:43:07 CEST 2009
Author: mmassonnet
Date: 2009-05-23 21:43:07 +0000 (Sat, 23 May 2009)
New Revision: 7400
Modified:
xfce4-notes-plugin/trunk/ChangeLog
xfce4-notes-plugin/trunk/panel-plugin/application.vala
xfce4-notes-plugin/trunk/panel-plugin/window.vala
Log:
Display window list in menu Go
Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog 2009-05-23 18:50:55 UTC (rev 7399)
+++ xfce4-notes-plugin/trunk/ChangeLog 2009-05-23 21:43:07 UTC (rev 7400)
@@ -1,5 +1,18 @@
2009-05-23 Mike Massonnet <mmassonnet at xfce.org>
+Display window list in menu Go
+ * panel-plugin/window.vala:
+ - New private property window_list that is set via the new private
+ method set_window_list. It is a simple list that stores a bunch of
+ pointers to Xnp.Window objects.
+ - Update the menu Go to include a list of windows and a rename item.
+ * panel-plugin/application.vala:
+ - New public method create_window that creates a new window and
+ stores it inside a simple list in its private data. The list is
+ passed to the windows that the object creates.
+
+2009-05-23 Mike Massonnet <mmassonnet at xfce.org>
+
Unique property "name" on Window
* panel-plugin/window.vala:
- New private method update_title to set the window title to
Modified: xfce4-notes-plugin/trunk/panel-plugin/application.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-05-23 18:50:55 UTC (rev 7399)
+++ xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-05-23 21:43:07 UTC (rev 7400)
@@ -26,14 +26,42 @@
public class Application : GLib.Object {
+ private SList<unowned Xnp.Window> window_list;
+
public Application () {
/* TODO Load existing notes */
+
/* Load an empty note */
+ create_window (null);
+ create_window (null);
+ }
+
+ public void create_window (string? name) {
var window = new Xnp.Window ();
- window.insert_note ();
+ 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);
+ }
+
+ if (name == null) {
+ uint len = this.window_list.length ();
+ if (len > 1)
+ window.name = "Notes %u".printf (len);
+ }
+ else {
+ window.name = name;
+ }
+
+ this.load_window_data (window);
+
window.show ();
}
+ private void load_window_data (Xnp.Window window) {
+ window.insert_note ();
+ }
+
/**/
static int main (string[] args) {
Gtk.init (ref args);
Modified: xfce4-notes-plugin/trunk/panel-plugin/window.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-05-23 18:50:55 UTC (rev 7399)
+++ xfce4-notes-plugin/trunk/panel-plugin/window.vala 2009-05-23 21:43:07 UTC (rev 7400)
@@ -50,6 +50,8 @@
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;
+
public new string name { default = "Notes"; get; set; }
private bool _above;
@@ -526,7 +528,9 @@
mi.activate += () => { delete_current_note (); };
menu.append (mi);
- mi = new Gtk.MenuItem.with_mnemonic ("_Rename");
+ mi = new Gtk.ImageMenuItem.with_mnemonic ("_Rename");
+ var image = new Gtk.Image.from_stock (Gtk.STOCK_EDIT, Gtk.IconSize.MENU);
+ ((Gtk.ImageMenuItem)mi).set_image (image);
mi.activate += () => { rename_current_note (); };
menu.append (mi);
@@ -567,42 +571,86 @@
* Update the menu Go when it is shown.
*/
private void update_menu_go (Gtk.Menu menu) {
- /* Clean existing items */
+ Gtk.MenuItem mi;
+ Gtk.Image image;
+
menu. at foreach ((w) => {
w.destroy ();
});
- /* Build the menu */
if (this.notebook != null) {
- int n_pages = this.notebook.get_n_pages ();
- for (int p = 0; p < n_pages; p++) {
- var note = (Xnp.Note)(this.notebook.get_nth_page (p));
- var mi = new Gtk.MenuItem.with_label (note.name);
- mi.set_data ("page", (void*)p);
- mi.activate += (i) => {
- int page = (int)i.get_data ("page");
- notebook.set_current_page (page);
- };
- menu.append (mi);
+ /* NOTE: An initial menu is created before the notebook is created
+ * to have the accelerators. */
+ foreach (var win in this.window_list) {
+ if (win == this) {
+ mi = new Gtk.MenuItem.with_label (win.name);
+ mi.sensitive = false;
+ menu.append (mi);
+
+ int n_pages = this.notebook.get_n_pages ();
+ for (int p = 0; p < n_pages; p++) {
+ var note = (Xnp.Note)(this.notebook.get_nth_page (p));
+ mi = new Gtk.MenuItem.with_label (note.name);
+ mi.set_data ("page", (void*)p);
+ mi.activate += (i) => {
+ int page = (int)i.get_data ("page");
+ notebook.set_current_page (page);
+ };
+ menu.append (mi);
+ }
+
+ mi = new Gtk.SeparatorMenuItem ();
+ menu.append (mi);
+ }
+ else {
+ 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");
+ };
+ menu.append (mi);
+
+ mi = new Gtk.SeparatorMenuItem ();
+ menu.append (mi);
+ }
}
}
- var mi_separator = new Gtk.SeparatorMenuItem ();
- menu.append (mi_separator);
+ mi = new Gtk.ImageMenuItem.with_mnemonic ("_Rename group");
+ image = new Gtk.Image.from_stock (Gtk.STOCK_EDIT, Gtk.IconSize.MENU);
+ ((Gtk.ImageMenuItem)mi).set_image (image);
+ //mi.add_accelerator ("activate", this.accel_group, '<F2>',
+ // Gdk.ModifierType.SHIFT_MASK, Gtk.AccelFlags.MASK);
+ menu.append (mi);
- var mi_image = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_ADD, null);
- mi_image.add_accelerator ("activate", this.accel_group, 'N',
+ mi = new Gtk.ImageMenuItem.with_mnemonic ("_Delete group");
+ image = new Gtk.Image.from_stock (Gtk.STOCK_REMOVE, Gtk.IconSize.MENU);
+ ((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);
- menu.append (mi_image);
+ menu.append (mi);
- mi_image = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_REMOVE, null);
- mi_image.add_accelerator ("activate", this.accel_group, 'W',
+ mi = new Gtk.ImageMenuItem.with_mnemonic ("_Add a new group");
+ image = new Gtk.Image.from_stock (Gtk.STOCK_ADD, Gtk.IconSize.MENU);
+ ((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);
- menu.append (mi_image);
+ menu.append (mi);
menu.show_all ();
}
+ /**
+ * set_window_list:
+ *
+ * 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 ();
+ }
+
/*
* Private methods
*/
More information about the Goodies-commits
mailing list