[Xfce4-commits] <xfce4-notes-plugin:master> Vala fixies
Mike Massonnet
noreply at xfce.org
Fri Dec 18 20:22:01 CET 2009
Updating branch refs/heads/master
to 697a678fef5ba7083ad51564ad7e23e445e885ae (commit)
from 9692e1abec95f98178ac270aca7a87cb3702f740 (commit)
commit 697a678fef5ba7083ad51564ad7e23e445e885ae
Author: Mike Massonnet <mmassonnet at xfce.org>
Date: Fri Dec 18 20:17:58 2009 +0100
Vala fixies
ChangeLog | 17 ++++
panel-plugin/application.vala | 2 +-
panel-plugin/main-status-icon.vala | 179 +++++++++++++++++-------------------
panel-plugin/window.vala | 3 +-
4 files changed, 104 insertions(+), 97 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 672baab..4859dd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2009-12-17 Mike Massonnet <mmassonnet at xfce.org>
+Vala fixies
+ * panel-plugin/application.vala:
+ - Set xfconf_channel to null, calling unref on it will keep the
+ pointer intact and print a warning during the next call on unref.
+ * panel-plugin/window.vala:
+ - Fix earlier commit to sync the menu item sticky with the internal
+ bool value, the menu item needs to be checked if it is constructed
+ or it will print a warning.
+ * panel-plugin/main-status-icon.vala:
+ - Last but not least, using Timeout.add inside an Object passes the
+ reference to it (the object will be ref'ed/unref'ed automatically)
+ and this is a no-go in this case, when the Timeout is used to kill
+ the application. As it cannot be unref'ed magically twice the whole
+ Object is now replaced by static functions.
+
+2009-12-17 Mike Massonnet <mmassonnet at xfce.org>
+
Clean up TODO file
2009-12-17 Mike Massonnet <mmassonnet at xfce.org>
diff --git a/panel-plugin/application.vala b/panel-plugin/application.vala
index b722178..03317ac 100644
--- a/panel-plugin/application.vala
+++ b/panel-plugin/application.vala
@@ -72,7 +72,7 @@ namespace Xnp {
~Application () {
save_windows_configuration ();
save_notes ();
- xfconf_channel.unref ();
+ xfconf_channel = null;
Xfconf.shutdown ();
}
diff --git a/panel-plugin/main-status-icon.vala b/panel-plugin/main-status-icon.vala
index 2443a65..6ddd10f 100644
--- a/panel-plugin/main-status-icon.vala
+++ b/panel-plugin/main-status-icon.vala
@@ -21,114 +21,103 @@ using Config;
using Xfce;
using Gtk;
-public class Notes : GLib.Object {
-
- private Gtk.Invisible invisible;
- private Gtk.StatusIcon status_icon;
- private Xnp.Application application;
- private Gtk.Menu context_menu;
-
- public Notes () {
- Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
- var save_location = Xfce.Resource.save_location (Xfce.ResourceType.CONFIG, "xfce4/xfce4-notes.rc", true);
- application = new Xnp.Application (save_location);
-
- status_icon = new Gtk.StatusIcon.from_icon_name ("xfce4-notes-plugin");
- status_icon.set_tooltip_text (_("Notes"));
- Timeout.add_seconds (60, () => {
- if (!status_icon.is_embedded ()) {
- warning ("Status Icon is not embedded");
- Gtk.main_quit ();
- }
- return false;
- });
- status_icon.activate += () => { application.show_hide_notes (); };
- context_menu = build_context_menu ();
- status_icon.popup_menu += () => {
- context_menu.popup (null, null, status_icon.position_menu, 0, Gtk.get_current_event_time ());
- };
-
- set_x_selection ();
- }
-
- /**
- * set_x_selection:
- *
- * Set an X selection to listen to for the popup command.
- */
- private bool set_x_selection () {
- invisible = new Gtk.Invisible ();
- if (!Xnp.Popup.set_x_selection (invisible)) {
- return false;
- }
- invisible.client_event += (w, event) => {
- if (Xnp.Popup.get_message_from_event (event) == "SHOW_HIDE") {
- application.show_hide_notes ();
- return true;
+static Xnp.Application application;
+static Gtk.Invisible invisible;
+static Gtk.StatusIcon status_icon;
+static Gtk.Menu context_menu;
+
+static void build_plugin () {
+ Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
+ var save_location = Xfce.Resource.save_location (Xfce.ResourceType.CONFIG, "xfce4/xfce4-notes.rc", true);
+ application = new Xnp.Application (save_location);
+ status_icon = new Gtk.StatusIcon.from_icon_name ("xfce4-notes-plugin");
+ status_icon.set_tooltip_text (_("Notes"));
+ Timeout.add_seconds (60, () => {
+ if (!status_icon.is_embedded ()) {
+ warning ("Status Icon is not embedded");
+ Gtk.main_quit ();
}
return false;
- };
- return true;
- }
+ });
+ status_icon.activate += () => { application.show_hide_notes (); };
+ context_menu = build_context_menu ();
+ status_icon.popup_menu += () => {
+ context_menu.popup (null, null, status_icon.position_menu, 0, Gtk.get_current_event_time ());
+ };
+ set_x_selection ();
+}
+
+static Gtk.Menu build_context_menu () {
+ var menu = new Gtk.Menu ();
- /**
- * build_context_menu:
- *
- * Builds the context menu for right click on status icon.
- */
- private Gtk.Menu build_context_menu () {
- var menu = new Gtk.Menu ();
+ var mi = new Gtk.MenuItem.with_mnemonic (_("_Go"));
+ var menu_go = application.context_menu ();
+ mi.set_submenu (menu_go);
+ menu.append (mi);
- var mi = new Gtk.MenuItem.with_mnemonic (_("_Go"));
- var menu_go = application.context_menu ();
- mi.set_submenu (menu_go);
- menu.append (mi);
+ mi = new Gtk.SeparatorMenuItem ();
+ menu.append (mi);
- mi = new Gtk.SeparatorMenuItem ();
- menu.append (mi);
+ mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_PROPERTIES, null);
+ mi.activate += () => { application.open_settings_dialog (); };
+ menu.append (mi);
- mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_PROPERTIES, null);
- mi.activate += () => { application.open_settings_dialog (); };
- menu.append (mi);
+ mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_ABOUT, null);
+ mi.activate += () => { application.open_about_dialog (); };
+ menu.append (mi);
- mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_ABOUT, null);
- mi.activate += () => { application.open_about_dialog (); };
- menu.append (mi);
+ mi = new Gtk.SeparatorMenuItem ();
+ menu.append (mi);
- mi = new Gtk.SeparatorMenuItem ();
- menu.append (mi);
+ mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_REMOVE, null);
+ mi.activate += () => {
+ Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", true);
+ Gtk.main_quit ();
+ };
+ menu.append (mi);
- mi = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_REMOVE, null);
- mi.activate += () => {
- Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", true);
- Gtk.main_quit ();
- };
- menu.append (mi);
+ menu.show_all ();
- menu.show_all ();
+ return menu;
+}
- return menu;
+static bool set_x_selection () {
+ invisible = new Gtk.Invisible ();
+ if (!Xnp.Popup.set_x_selection (invisible)) {
+ return false;
}
+ invisible.client_event += (w, event) => {
+ if (Xnp.Popup.get_message_from_event (event) == "SHOW_HIDE") {
+ application.show_hide_notes ();
+ return true;
+ }
+ return false;
+ };
+ return true;
+}
- public static int main (string[] args) {
- Gtk.init (ref args);
- Unique.App app = new Unique.App ("org.xfce.Notes", null);
- if (app.is_running) {
- if (app.send_message (Unique.Command.ACTIVATE, null) == Unique.Response.OK) {
- app = null;
- return 0;
- }
+static int main (string[] args) {
+ Gtk.init (ref args);
+ Unique.App app = new Unique.App ("org.xfce.Notes", null);
+ if (app.is_running) {
+ if (app.send_message (Unique.Command.ACTIVATE, null) == Unique.Response.OK) {
+ app = null;
+ return 0;
}
- app.message_received += (command, message_data, time_) => {
- if (command != Unique.Command.ACTIVATE) {
- return Unique.Response.PASSTHROUGH;
- }
- return Unique.Response.OK;
- };
- GLib.Environment.set_application_name (_("Notes"));
- var notes = new Notes ();
- Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", false);
- Gtk.main ();
- return 0;
}
+ app.message_received += (command, message_data, time_) => {
+ if (command != Unique.Command.ACTIVATE) {
+ return Unique.Response.PASSTHROUGH;
+ }
+ return Unique.Response.OK;
+ };
+ GLib.Environment.set_application_name (_("Notes"));
+ build_plugin ();
+ Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", false);
+ Gtk.main ();
+ application = null;
+ invisible = null;
+ status_icon = null;
+ context_menu = null;
+ return 0;
}
diff --git a/panel-plugin/window.vala b/panel-plugin/window.vala
index 9765775..e801f7b 100644
--- a/panel-plugin/window.vala
+++ b/panel-plugin/window.vala
@@ -149,11 +149,12 @@ namespace Xnp {
}
set {
this._sticky = value;
- this.mi_sticky.active = this._sticky;
if (value == true)
stick ();
else
unstick ();
+ if (this.mi_sticky is Gtk.CheckMenuItem)
+ this.mi_sticky.active = this._sticky;
}
}
More information about the Xfce4-commits
mailing list