Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lots lots of changes during the APS meeting.

* Removed SVNVERSION tag (ready for moving to git if accepted as a gnome module)
* Improved the gconf settings dialog.
* Launch browsers for help and about.
* Make use of set_size_hints to avoid the applet expanding over the entire panel(only effective when the handle is enablabled -- don't blame me, it is a problem with gnome-panel!)
* Use installed AUTHORS and COPYING files for authors and licenses in the applet. (therefore deprecated building licenses.vapi)
* Reorganized switcher.vala, moving utility subroutines out from the class namespace.
* Removed dependency on abs_topsrcdir ( some test cases may become broken)
* Updated strings in the gconf schema so that they are more expressive.
* Added a gconf key to disable the gtk module detection at applet startup.
* Replace the static Bonobo verb handlers with instance member functions.
  • Loading branch information...
commit 5335beff21a4b221e0e1f4b1cc8dfd8155ac8e0e 1 parent acad4be
@rainwoodman rainwoodman authored
Showing with 1,723 additions and 1,095 deletions.
  1. +0 −1  Makefile.am
  2. +0 −1  Makefile.configmake
  3. +0 −16 Makefile.licenses
  4. +184 −122 applet/applet.vala
  5. +77 −64 applet/gtkextra-gconfdialog.vala
  6. +168 −158 applet/switcher.vala
  7. +1 −1  applet/workspaceselector.vala
  8. +5 −5 configure.ac
  9. +27 −7 gnome-globalmenu.schemas.in
  10. +1 −1  gnome-globalmenu.spec
  11. +1 −1  gtk-modules/globalmenu/module-main.vala
  12. +2 −2 gtk-modules/globalmenu/tests/test-unload.vala
  13. +4 −0 libgnomenu/application.vala
  14. +2 −14 libgnomenu/menu.vala
  15. +7 −46 libgnomenu/menubar.vala
  16. +59 −20 libgnomenu/menubarbox.vala
  17. +2 −1  libgnomenu/menuitem.vala
  18. +1 −1  libgnomenu/tests/test-leak.vala
  19. +0 −4 libgnomenu/tests/test-menubar.vala
  20. +2 −2 libgnomenu/tests/test-parser.vala
  21. +72 −37 po/de.po
  22. +76 −40 po/en_GB.po
  23. +76 −40 po/es.po
  24. +69 −35 po/fi.po
  25. +76 −40 po/fr.po
  26. +49 −28 po/gnome-globalmenu.pot
  27. +74 −38 po/hu.po
  28. +52 −31 po/id.po
  29. +76 −40 po/it.po
  30. +49 −28 po/ko.po
  31. +73 −37 po/nl.po
  32. +49 −28 po/pl.po
  33. +76 −40 po/pt.po
  34. +76 −40 po/pt_BR.po
  35. +76 −40 po/ru.po
  36. +76 −40 po/sv.po
  37. +76 −40 po/zh_CN.po
  38. +3 −2 tests/Makefile.am
  39. +1 −0  tests/testman.vala
  40. +1 −1  vapi/gconf-2.0.vapi
  41. +2 −1  vapi/libpanelapplet-2.0.vapi
  42. +2 −2 vapi/libwnck-1.0.vapi
View
1  Makefile.am
@@ -30,7 +30,6 @@ CLEANFILES =
include $(top_srcdir)/Makefile.configmake
include $(top_srcdir)/Makefile.config
-include $(top_srcdir)/Makefile.licenses
schemadir = $(GCONF_SCHEMA_FILE_DIR)
schema_in_files = gnome-globalmenu.schemas.in
View
1  Makefile.configmake
@@ -56,7 +56,6 @@ configmake.h: Makefile.configmake Makefile
echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
echo '#define PKGLIBDIR "$(pkglibdir)"'; \
echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
- echo '#define ABSTOPSRCDIR "$(abs_top_srcdir)"'; \
} | sed '/""/d' > $@-t
mv $@-t $@
BUILT_SOURCES += configmake.h configmake.vapi
View
16 Makefile.licenses
@@ -1,16 +0,0 @@
-LICENSES = GPLv2 GPLv3 AUTHORS
-licenses.h licenses.vapi: $(LICENSES)
- echo 'namespace Licenses {' > licenses.vala
- for i in $(LICENSES); do \
- echo -n 'public static const string '$$i'="""'; >> licenses.vala \
- cat $$i; \
- echo '""";'; \
- done >> licenses.vala ;
- echo '}' >> licenses.vala
- $(VALAC_BIN) -C --basedir=$(top_srcdir) --library=licenses licenses.vala
- rm licenses.vala
- rm licenses.c
- rm licenses.gir
-
-BUILT_SOURCES += licenses.vapi licenses.h
-EXTRA_DIST += $(LICENSES) licenses.vapi
View
306 applet/applet.vala
@@ -8,6 +8,40 @@ using GConf;
[CCode (cname = "GlobalMenuPanelApplet")]
public class Applet : Panel.Applet {
public static const string IID = "OAFIID:GlobalMenu_PanelApplet";
+ static const string applet_menu_xml_template = """
+<popup name="button3">
+ <menuitem name="Preferences"
+ verb="Preferences"
+ _label="@Preferences@"
+ pixtype="stock"
+ pixname="gtk-preferences"/>
+ <menuitem name="Help"
+ verb="Help"
+ _label="@Help@"
+ pixtype="stock"
+ pixname="gtk-help"/>
+ <menuitem name="About"
+ verb="About"
+ _label="@About@"
+ pixtype="stock"
+ pixname="gtk-about"/>
+</popup>
+ """;
+ static string[] subs = {
+ "@Preferences@", _("_Preferences"),
+ "@Help@", _("_Help"),
+ "@About@", _("_About")
+ };
+ static const string APPLET_NAME = _("globalmenu-panel-applet");
+ static const string APPLET_ICON = "globalmenu";
+ static const string GCONF_SCHEMA_DIR = "/schemas/apps/globalmenu-panel-applet/prefs";
+
+ static const BonoboUI.Verb[] verbs = {
+ {"About", (BonoboUI.VerbFn) applet_menu_clicked, null},
+ {"Help", (BonoboUI.VerbFn) applet_menu_clicked, null},
+ {"Preferences", (BonoboUI.VerbFn) applet_menu_clicked, null},
+ {null, null, null}
+ };
public Applet() { }
public override void dispose() {
@@ -17,11 +51,8 @@ public class Applet : Panel.Applet {
}
base.dispose();
}
- ~Applet() {
- }
construct {
- disposed = false;
add_events(Gdk.EventMask.KEY_PRESS_MASK);
menubars.visible = true;
@@ -31,15 +62,13 @@ public class Applet : Panel.Applet {
menubars.add(switcher);
setup_popup_menu(switcher);
- main_menubar.min_length = 12; /*Then it will have a overflown item*/
setup_popup_menu(main_menubar);
menubars.add(main_menubar);
- menubars.child_set(main_menubar, "expand", true, null); /*Let the main_menubar use the remaining space in the applet.*/
-
+ menubars.child_set(main_menubar, "shrink", true, null);
/*init panel */
- flags = (Panel.AppletFlags.EXPAND_MINOR | Panel.AppletFlags.EXPAND_MAJOR );
+ has_handle = false;
set_background_widget(this);
Gdk.Color color;
@@ -54,11 +83,36 @@ public class Applet : Panel.Applet {
private Monitor monitor = new Monitor();
private MenuBarBox menubars = new MenuBarBox();
- private bool disposed;
+ private bool disposed = false;
private GlobalMenu main_menubar = new GlobalMenu();
private Switcher switcher = new Switcher();
private Notify.Notification notify_no_plugin;
+
+ private bool initialized = false;
+ public bool disable_module_check = false;
+ private bool _has_handle = false;
+ public bool has_handle {
+ set {
+ if(value) {
+ flags = (0
+ | Panel.AppletFlags.HAS_HANDLE
+ | Panel.AppletFlags.EXPAND_MINOR
+ | Panel.AppletFlags.EXPAND_MAJOR
+ );
+ } else {
+ flags = (0
+ | Panel.AppletFlags.EXPAND_MINOR
+ | Panel.AppletFlags.EXPAND_MAJOR
+ );
+ set_size_hints(null, 0);
+ }
+ _has_handle = value;
+ }
+ get {
+ return _has_handle;
+ }
+ }
public override void screen_changed(Gdk.Screen? previous_screen) {
Gdk.Screen screen = get_screen();
if(previous_screen != null) {
@@ -82,6 +136,7 @@ public class Applet : Panel.Applet {
}
main_menubar.switch_to(xid);
}
+
public override void change_background(AppletBackgroundType type, Gdk.Color? color, Gdk.Pixmap? pixmap) {
Background bg = new Background();
switch(type){
@@ -111,55 +166,40 @@ public class Applet : Panel.Applet {
menubars.background = bg;
}
public override void change_orient(AppletOrient orient) {
+ update_size();
+ }
+ public override void change_size(uint size) {
+ update_size();
+ }
+ private void update_size() {
switch(orient) {
case AppletOrient.UP:
menubars.gravity = Gravity.DOWN;
menubars.pack_direction = PackDirection.LTR;
menubars.child_pack_direction = PackDirection.LTR;
+ menubars.set_size_request((int)size, -1);
break;
case AppletOrient.DOWN:
menubars.gravity = Gravity.DOWN;
menubars.pack_direction = PackDirection.LTR;
menubars.child_pack_direction = PackDirection.LTR;
+ menubars.set_size_request((int)size, -1);
break;
case AppletOrient.LEFT:
menubars.gravity = Gravity.LEFT;
menubars.pack_direction = PackDirection.TTB;
menubars.child_pack_direction = PackDirection.TTB;
+ menubars.set_size_request(-1, (int)size);
break;
case AppletOrient.RIGHT:
menubars.gravity = Gravity.RIGHT;
menubars.pack_direction = PackDirection.TTB;
menubars.child_pack_direction = PackDirection.TTB;
+ menubars.set_size_request(-1, (int)size);
break;
}
}
- static const string APPLET_NAME = _("globalmenu-panel-applet");
- static const string APPLET_ICON = "globalmenu";
- static const string GCONF_SCHEMA_DIR = "/schemas/apps/globalmenu-panel-applet/prefs";
- static const string[] APPLET_AUTHORS = {"Coding:",
- "Yu Feng <rainwoodman@gmail.com>",
- "Mingxi Wu <fengshenx@gmail.com>",
- "bis0n.lives <bis0n.lives@gmail.com>",
- "Luca Viggiani <lviggiani@gmail.com>",
- "",
- "Packaging:",
- "sstasyuk <sstasyuk@gmail.com>",
- "David Watson <dwatson031@gmail.com>",
- "Valiant Wing <Valiant.Wing@gmail.com>",
- null};
-
- static const string[] APPLET_ADOCUMENTERS = {
- "Pierre Slamich <pierre.slamich@gmail.com>",
- null};
-
- static const BonoboUI.Verb[] verbs = {
- {"About", on_about_clicked, null},
- {"Help", on_help_clicked, null},
- {"Preferences", on_preferences_clicked, null},
- {null, null, null}
- };
public void init() {
/* Connect to gconf */
@@ -176,142 +216,164 @@ public class Applet : Panel.Applet {
};
}
- string applet_menu_xml_template = """
-<popup name="button3">
- <menuitem name="Preferences"
- verb="Preferences"
- _label="@Preferences@"
- pixtype="stock"
- pixname="gtk-preferences"/>
- <menuitem name="Help"
- verb="Help"
- _label="@Help@"
- pixtype="stock"
- pixname="gtk-help"/>
- <menuitem name="About"
- verb="About"
- _label="@About@"
- pixtype="stock"
- pixname="gtk-about"/>
-</popup>
- """;
- string[] subs = {
- "@Preferences@", _("_Preferences"),
- "@Help@", _("_Help"),
- "@About@", _("_About")
- };
string applet_menu_xml = Template.replace(applet_menu_xml_template, subs);
setup_menu (applet_menu_xml, verbs, this);
get_prefs();
-
+
+ initialized = true;
+ check_module();
}
private void check_module() {
- Settings settings = get_settings();
- if(settings == null) return;
- string modules = settings.gtk_modules;
- modules += Environment.get_variable("GTK_MODULES");
+ if(!initialized) return;
+ if(disable_module_check) return;
- if(modules != null && modules.str("globalmenu") != null) {
- return;
- }
-
- if(notify_no_plugin == null) {
- if(!Notify.is_initted()) {
- if(!Notify.init(APPLET_NAME)) {
- critical("libnotify is not initialized");
- return;
- }
- }
- notify_no_plugin = new Notify.Notification(
- _("No Global Menu?"),
- _("The Global Menu Plugin is not enabled on this desktop.") +
- _("Enable the plugin by accessing the preferences dialog via a right-click,") +
- _("or by exporting GTK_MODULES=globalmenu-gnome in your profile.")
- , "globalmenu", null);
+ string modules = Environment.get_variable("GTK_MODULES");
+ if(modules == null) modules = "";
+ Settings settings = get_settings();
+ if(settings != null) {
+ modules += settings.gtk_modules;
}
+
+ if(modules.str("globalmenu") != null) return;
+
try {
- notify_no_plugin.show();
+ Notify.init(APPLET_NAME);
+ notify_no_plugin = new Notify.Notification(
+ _("No Global Menu?"),
+ _("The Global Menu Plugin is not enabled on this desktop.") +
+ _("Enable the plugin by accessing the preferences dialog via a right-click,") +
+ _("or by exporting GTK_MODULES=globalmenu-gnome in your profile.")
+ , "globalmenu", null);
+
+ notify_no_plugin.show();
} catch (GLib.Error e) {
/*ignore the error*/
+ warning("notify library doesn't work as intended");
}
}
- public override void realize() {
- base.realize();
- }
private void get_prefs() {
switcher.max_size = gconf_get_int("title_max_width");
switcher.show_icon = gconf_get_bool("show_icon");
switcher.show_label = gconf_get_bool("show_name");
switcher.show_window_actions = gconf_get_bool("show_window_actions");
switcher.show_window_list = gconf_get_bool("show_window_list");
+ this.has_handle = gconf_get_bool("has_handle");
+ this.disable_module_check = gconf_get_bool("disable_module_check");
}
- private static void on_about_clicked (BonoboUI.Component component,
- void* user_data, string cname) {
-// Applet _this = (Applet) user_data;
-
+
+ [CCode (instance_pos = 1.1)]
+ private void applet_menu_clicked (BonoboUI.Component component,
+ string cname) {
+ switch(cname) {
+ case "About":
+ show_about();
+ break;
+ case "Preferences":
+ show_preferences();
+ break;
+ case "Help":
+ show_help();
+ break;
+ }
+ }
+
+ private void show_about() {
var dialog = new Gtk.AboutDialog();
dialog.program_name = APPLET_NAME;
string ver = Config.VERSION;
- if(Config.SVNVERSION.length > 0 ){
- ver += ".svn" + Config.SVNVERSION;
- }
dialog.version = ver;
dialog.website = "http://code.google.com/p/gnome2-globalmenu";
dialog.website_label = _("Project Home");
dialog.wrap_license = false;
- dialog.license = Licenses.GPLv2;
+ try {
+ string license = null;
+ FileUtils.get_contents(Config.DOCDIR + "/COPYING", out license);
+ dialog.license = license;
+ } catch(FileError e) {
+ warning("%s", e.message);
+ }
+ try {
+ string authors = null;
+ FileUtils.get_contents(Config.DOCDIR + "/AUTHORS", out authors);
+ string[] authors_array = authors.split("\n");
+ dialog.authors = authors_array;
+ } catch(FileError e) {
+ warning("%s", e.message);
+ }
dialog.logo_icon_name = APPLET_ICON;
- dialog.authors = APPLET_AUTHORS;
- dialog.documenters = APPLET_ADOCUMENTERS;
dialog.translator_credits = _("translator-credits");
dialog.set_icon_name("gtk-about");
dialog.run();
dialog.destroy();
- }
- private static void on_help_clicked (BonoboUI.Component component,
- void* user_data, string cname) {
-// Applet _this = (Applet) user_data;
- var dialog = new Gtk.AboutDialog();
- dialog.program_name = APPLET_NAME;
- dialog.version = Config.VERSION;
- dialog.website = "http://code.google.com/p/gnome2-globalmenu/wiki/HelpCentral";
- dialog.website_label = _("On-line help");
- dialog.logo_icon_name = "gtk-help";
- dialog.set_icon_name("gtk-help");
- dialog.run();
- dialog.destroy();
- }
- private static void on_preferences_clicked (BonoboUI.Component component,
- void* user_data, string cname) {
-
- Applet _this = (Applet) user_data;
-
+
+
+ }
+ private void show_preferences() {
GConfDialog gcd = new GConfDialog(_("Global Menu Applet Preferences"));
- gcd.add_key("/apps/gnome_settings_daemon/gtk-modules/globalmenu-gnome");
- gcd.add_subkeys(_this.get_preferences_key(),
- new string[]{
- "show_icon",
- "show_name",
- "title_max_width",
- "show_window_actions",
- "show_window_list"});
-
- gcd.run();
+ string root = get_preferences_key();
+
+ gcd.add_key_group(
+ _("System Preferences"),
+ new string[] {
+ "/apps/gnome_settings_daemon/gtk-modules/globalmenu-gnome",
+ root + "/disable_module_check"
+ }
+ );
+
+ gcd.add_key_group(
+ _("Applet Behaviors"),
+ new string[]{
+ root + "/has_handle",
+ root + "/show_icon",
+ root + "/show_name",
+ root + "/title_max_width",
+ root + "/show_window_actions",
+ root + "/show_window_list"
+ }
+ );
+
+ switch(gcd.run()) {
+ case Gtk.ResponseType.HELP:
+ show_help();
+ break;
+ }
gcd.destroy();
}
+ private void show_help() {
+ try {
+ Gnome.url_show("http://code.google.com/p/gnome2-globalmenu/wiki/HelpCentral");
+ } catch(GLib.Error e) {
+ warning("%s", e.message);
+ }
+ }
public override bool button_press_event(Gdk.EventButton event) {
if(event.button == 3)
return control.do_popup(event.button, event.time);
return false;
}
+ public override void size_request(out Gtk.Requisition req) {
+ base.size_request(out req);
+ unowned int[] hints = menubars.get_size_hints();
+ assert(hints.length % 2 == 0);
+ if(has_handle) {
+ /* This is to workaround a problem with gnome panel.
+ * gnome panel won't handle size_hints correctly if
+ * the applet has no handle.
+ *
+ * Take a look at the sample code of gnome-panel/applets/wncklets
+ * */
+ set_size_hints(hints, 0);
+ }
+ }
+
private void setup_popup_menu(Gtk.Widget widget) {
widget.button_press_event += (widget, event) => {
if(event.button == 3) {
View
141 applet/gtkextra-gconfdialog.vala
@@ -29,95 +29,101 @@ using GConf;
icon_name = "gtk-preferences";
}
- public GConfDialog.with_subkeys(string key, string dialog_title, string[]? subkeys = null) {
- title = dialog_title;
- icon_name = "gtk-preferences";
- add_subkeys(key, subkeys);
- }
construct {
_default_client = GConf.Client.get_default();
//vbox.width_request = 320;
- add_button("gtk-close", Gtk.ResponseType.CLOSE);
+ add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE);
+ add_button(Gtk.STOCK_HELP, Gtk.ResponseType.HELP);
}
- public void add_key(string key) {
- try {
- weak GConf.Entry entry = _default_client.get_entry(key, null, true);
- if(entry != null) addEntry(entry);
- } catch (GLib.Error e) {
- warning("%s", e.message);
- }
- }
- public void add_subkeys(string key, string[]? subkeys= null) {
+
+ public void add_key_group(string group_name, string[] keys) {
+ var frame = new Gtk.Frame(group_name);
+ var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f);
+ var box = new Gtk.VBox(false, 0);
+ var label_widget = frame.label_widget;
+ label_widget.modify_font(Pango.FontDescription.from_string("Bold"));
+ frame.border_width = 10;
+ frame.add(alignment);
+ alignment.add(box);
+ alignment.left_padding = 10;
+// frame.shadow_type = Gtk.ShadowType.NONE;
try {
- weak GLib.SList<GConf.Entry> prefs = _default_client.all_entries(key);
- if (subkeys == null) {
- foreach(weak GConf.Entry entry in prefs)
- addEntry(entry);
- } else {
- foreach(weak string subkey in subkeys) {
- add_key(key + "/" + subkey);
- }
- }
- } catch(GLib.Error e) {
+ foreach(weak string key in keys) {
+ var widget = create_proxy_widget(key);
+ box.pack_start(widget, false, false, 5);
+ } } catch(GLib.Error e) {
warning("%s", e.message);
}
+ vbox.pack_start(frame, true, false, 0);
+ frame.show_all();
}
- private void addEntry(GConf.Entry entry) {
- GConf.Schema schema = get_schema(entry);
+ private Gtk.Widget create_proxy_widget(string key) throws GLib.Error {
+ GConf.Entry entry = _default_client.get_entry(key, null, true);
+ GConf.Schema schema = safely_get_schema(entry);
weak string tooltip = schema.get_long_desc();
Gtk.Box row = new Gtk.HBox(false, 0);
- Gtk.Image info = new Gtk.Image.from_stock("gtk-dialog-info", Gtk.IconSize.BUTTON);
- info.tooltip_text = tooltip;
- row.pack_start(info, false, false, 2);
-
Gtk.Label label = new Gtk.Label(schema.get_short_desc());
label.justify = Gtk.Justification.LEFT;
label.tooltip_text = tooltip;
- row.pack_start(label, false, false, 2);
- Gtk.Widget widget;
+ Gtk.Widget action_widget;
+ Gtk.Widget render_widget;
switch(schema.get_type()) {
case ValueType.BOOL:
- widget = new Gtk.CheckButton();
- (widget as Gtk.CheckButton).active = _default_client.get_bool(entry.key);
- (widget as Gtk.CheckButton).clicked += onCheckButtonActivated;
+ var checkbox = new Gtk.CheckButton();
+ checkbox.active = _default_client.get_bool(entry.key);
+ checkbox.clicked += onCheckButtonActivated;
+ checkbox.add(label);
+ render_widget = checkbox;
+ action_widget = render_widget;
break;
case ValueType.STRING:
- widget = new Gtk.Entry();
- (widget as Gtk.Entry).text = _default_client.get_string(entry.key);
+ var entrybox = new Gtk.Entry();
+ var box = new Gtk.HBox(false, 0);
+ entrybox.text = _default_client.get_string(entry.key);
/* TODO: connect changed signal to eventhandler */
+ box.pack_start(label, false, false, 2);
+ box.pack_start(entrybox, false, false, 2);
+ action_widget = entrybox;
+ render_widget = box;
break;
case ValueType.INT:
- widget = new Gtk.SpinButton.with_range(-100, 200, 1);
- (widget as Gtk.SpinButton).value = _default_client.get_int(entry.key);
- (widget as Gtk.SpinButton).value_changed += onSpinButtonValueChanged;
+ var box = new Gtk.HBox(false, 0);
+ var spin = new Gtk.SpinButton.with_range(-100, 200, 1);
+ spin.value = _default_client.get_int(entry.key);
+ spin.value_changed += onSpinButtonValueChanged;
+ box.pack_start(label, false, false, 2);
+ box.pack_start(spin, false, false, 2);
+ action_widget = spin;
+ render_widget = box;
break;
default:
- return;
+ return new Gtk.EventBox();
}
- widget.tooltip_text = tooltip;
- widget.user_data = entry;
+ action_widget.tooltip_text = tooltip;
+ action_widget.set_data("gconf-entry", entry);
+ action_widget.set_data("gconf-schema", schema);
- row.pack_start(new Gtk.EventBox(), true, true, 2);
- row.pack_start(widget, false, false, 2);
+ Gtk.Button reset = new Gtk.Button.from_stock(Gtk.STOCK_CLEAR);
+ reset.tooltip_text = _("Reset to the default value");
+// reset.set_image(new Gtk.Image.from_stock("gtk-clear", Gtk.IconSize.SMALL_TOOLBAR));
+ reset.set_data("gconf-entry", entry);
+ reset.set_data("gconf-schema", schema);
+ reset.set_data("target", action_widget);
+
+ reset.clicked += onResetButtonPressed;
- Gtk.Button button = new Gtk.Button();
- button.tooltip_text = _("Reset to the default value");
- button.set_image(new Gtk.Image.from_stock("gtk-clear", Gtk.IconSize.BUTTON));
- button.user_data = widget;
- button.clicked += onResetButtonPressed;
+ row.pack_start(render_widget, false, false, 2);
+ row.pack_end(reset, false, false, 2);
- row.pack_start(button, false, false, 2);
- row.show_all();
- vbox.pack_start(row, true, true, 2);
-
+ return row;
}
private void onCheckButtonActivated(Gtk.CheckButton widget) {
- weak GConf.Entry entry = (GConf.Entry)widget.user_data;
+ var entry = (GConf.Entry)widget.get_data("gconf-entry");
try {
_default_client.set_bool(entry.key, widget.active);
} catch (GLib.Error e) {
@@ -126,7 +132,7 @@ using GConf;
}
private void onSpinButtonValueChanged(Gtk.SpinButton widget) {
- weak GConf.Entry entry = (GConf.Entry)widget.user_data;
+ var entry = (GConf.Entry)widget.get_data("gconf-entry");
try {
_default_client.set_int(entry.key, (int)widget.value);
} catch (GLib.Error e) {
@@ -134,7 +140,11 @@ using GConf;
}
}
- private GConf.Schema get_schema(GConf.Entry entry) {
+ /**
+ * Safely obtain a schema for the entry.
+ * If no schema is found, return a fake schema.
+ */
+ private GConf.Schema safely_get_schema(GConf.Entry entry) {
weak string schema_name = entry.get_schema_name();
if(schema_name == null) {
@@ -149,18 +159,21 @@ using GConf;
}
}
private void onResetButtonPressed(Gtk.Button widget) {
- Gtk.Widget target = (Gtk.Widget)widget.user_data;
- weak GConf.Entry entry = (GConf.Entry)target.user_data;
- GConf.Schema schema = get_schema(entry);
+ weak GConf.Schema schema = (GConf.Schema)widget.get_data("gconf-schema");
+ weak GConf.Value default_value = schema.get_default_value();
+ var target = (Gtk.Widget)widget.get_data("target");
switch(schema.get_type()) {
case ValueType.BOOL:
- (target as Gtk.CheckButton).active = schema.get_default_value().get_bool();
+ var checkbutton = target as Gtk.CheckButton;
+ checkbutton.active = default_value.get_bool();
break;
case ValueType.STRING:
- (target as Gtk.Entry).text = schema.get_default_value().get_string();
+ var entrybox = target as Gtk.Entry;
+ entrybox.text = default_value.get_string();
break;
case ValueType.INT:
- (target as Gtk.SpinButton).value = schema.get_default_value().get_int();
+ var spin = target as Gtk.SpinButton;
+ spin.value = default_value.get_int();
break;
}
}
View
326 applet/switcher.vala
@@ -96,16 +96,6 @@ using Gtk;
current_window = null;
}
}
- private string replace(string source, string find, string replacement) {
- /* replaces the string.replace method which depends on GLib.RegEx >= 2.12 */
- string[] buf = source.split(find);
- StringBuilder sb = new StringBuilder("");
- for (int co=0; co<buf.length; co++) {
- sb.append(buf[co]);
- if (co!=(buf.length-1)) sb.append(replacement);
- }
- return sb.str;
- }
private void on_deactivate() {
update(false);
}
@@ -203,14 +193,6 @@ using Gtk;
window.make_above();
window.unmake_above();
}
- private string remove_path(string txt, string separator) {
- long co = txt.length-1;
- while ((co>=0) && (txt.substring(co, 1)!=separator)) {
- co--;
- }
- string ret = txt.substring(co+1,(txt.length-co-1));
- return ret;
- }
private void set_iconify_destination(Wnck.Window window) {
if(!this.is_realized()) return;
if (window.get_window_type() != Wnck.WindowType.DESKTOP) {
@@ -229,11 +211,6 @@ using Gtk;
!window.is_minimized() &&
!window.is_skip_pager());
}
- private string pixbuf_encode_b64(Gdk.Pixbuf pixbuf) {
- Gdk.Pixdata pixdata = {0};
- pixdata.from_pixbuf(pixbuf, true);
- return Base64.encode(pixdata.serialize());
- }
private string do_xml_menu() {
if (!_show_window_list) return "";
@@ -294,64 +271,7 @@ using Gtk;
};
return Template.replace(WINACT_TEMPLATE, substs);
}
- private Wnck.Window find_desktop() {
- weak GLib.List<Wnck.Window> windows = Wnck.Screen.get_default().get_windows();
- foreach(weak Wnck.Window window in windows)
- if (window.get_window_type() == Wnck.WindowType.DESKTOP) return window;
- return null;
- }
- private Gdk.Pixbuf guess_icon(Wnck.Window window, int width = -1, int height = -1) {
- Gdk.Pixbuf[] icons = {
- window.get_mini_icon(),
- window.get_icon()};
- return guess_icon_array(icons, width, height);
- }
- private Gdk.Pixbuf guess_icon_array(Gdk.Pixbuf[] icons, int width, int height) {
- Gdk.Pixbuf icon = null;
- int min_dist = 99999;
- int best_size = 16;
- if(height == -1 || width == -1) {
- Gtk.icon_size_lookup(Gtk.IconSize.MENU, out width, out height);
- }
- int scaled_size = height;
- if(width < scaled_size)
- scaled_size = width;
-
- foreach(Gdk.Pixbuf i in icons) {
- int size = i.height;
- if(i.get_width() > size)
- size = i.width;
- int dist = size - scaled_size;
- if(dist < 0) dist = -dist;
- if(dist < min_dist) {
- min_dist = dist;
- icon = i;
- best_size = size;
- }
- }
-
- /* This should never happen. In case it happens
- * return something to make sure it doesn't crash*/
- if(icon == null) return icons[0];
- double ratio = (double)scaled_size/(double)best_size;
- if(ratio < 0) ratio = 1.0;
- int scaled_width = (int) (icon.width * ratio);
- int scaled_height = (int) (icon.height * ratio);
-
- Gdk.Pixbuf scaled_icon = new Gdk.Pixbuf(
- Gdk.Colorspace.RGB,
- icon.has_alpha, 8,
- scaled_width,
- scaled_height
- );
-
- icon.scale(scaled_icon,
- 0, 0, scaled_icon.width, scaled_icon.height,
- 0, 0, ratio, ratio, Gdk.InterpType.BILINEAR);
- /* can't use scale_simple because the vala binding is wrong*/
- return scaled_icon;
- }
private void update(bool include_menu) {
search_box.text = "";
@@ -457,21 +377,6 @@ using Gtk;
}
}
}*/
- private bool guess_dock_is_around() {
- weak GLib.List<Wnck.Window> windows = Wnck.Screen.get_default().get_windows();
- foreach(weak Wnck.Window window in windows)
- if (window.get_window_type() == Wnck.WindowType.DOCK) {
- switch(window.get_application().get_name()) {
- case "cairo-dock":
- case "avant-window-navigator":
- case "Do":
- /* add any other known dock having a task bar */
- return true;
- break;
- }
- }
- return false;
- }
/**
* The following 3 functions map item to window and verse vesa
*
@@ -553,76 +458,181 @@ using Gtk;
}
}
- public class SearchBoxMenuItem : Gtk.ImageMenuItem {
- private Gtk.Entry textbox = new Gtk.Entry();
- public string text {
- get { return textbox.text;}
- set { textbox.text = value; }
- }
- public SearchBoxMenuItem() {
- }
- construct {
- this.image = new Gtk.Image.from_icon_name("search", Gtk.IconSize.MENU);
- textbox.editable = true;
- textbox.sensitive = true;
- textbox.can_focus = true;
- textbox.text = "Type here...";
- textbox.is_focus = true;
-
- this.add(textbox);
- this.show_all();
- this.set_focus_child(textbox);
-
+private class SearchBoxMenuItem : Gtk.ImageMenuItem {
+ private Gtk.Entry textbox = new Gtk.Entry();
+ public string text {
+ get { return textbox.text;}
+ set { textbox.text = value; }
+ }
+ public SearchBoxMenuItem() {
+ }
+ construct {
+ this.image = new Gtk.Image.from_icon_name("search", Gtk.IconSize.MENU);
+ textbox.editable = true;
+ textbox.sensitive = true;
+ textbox.can_focus = true;
+ textbox.text = "Type here...";
+ textbox.is_focus = true;
+
+ this.add(textbox);
+ this.show_all();
+ this.set_focus_child(textbox);
+
+ textbox.state = Gtk.StateType.NORMAL;
+ textbox.state_changed += (box, previous_state) => {
textbox.state = Gtk.StateType.NORMAL;
- textbox.state_changed += (box, previous_state) => {
- textbox.state = Gtk.StateType.NORMAL;
- };
- textbox.changed += (box) => {
- Gnomenu.Menu shell = parent as Gnomenu.Menu;
- Gnomenu.MenuItem item = find_item();
- if(item != null)
- shell.select_item(item);
- };
+ };
+ textbox.changed += (box) => {
+ Gnomenu.Menu shell = parent as Gnomenu.Menu;
+ Gnomenu.MenuItem item = find_item();
+ if(item != null)
+ shell.select_item(item);
+ };
- textbox.activate += (box) => {
- Gnomenu.Menu shell = parent as Gnomenu.Menu;
- Gnomenu.MenuItem item = find_item();
- if(item != null)
- shell.activate_item(item, true);
- };
- this.state_changed += (_this, previous_state) => {
- this.state = Gtk.StateType.NORMAL;
- };
- }
-
- public Gnomenu.MenuItem? find_item() {
- Gnomenu.Shell shell = parent as Gnomenu.Shell;
- for(int i = 0; i < shell.length; i++) {
- Gnomenu.MenuItem item = shell.get_item(i) as Gnomenu.MenuItem;
- if(item.item_label != null &&
- item.item_label.casefold()
- .has_prefix(textbox.text.casefold())) {
- return item as Gnomenu.MenuItem;
- }
+ textbox.activate += (box) => {
+ Gnomenu.Menu shell = parent as Gnomenu.Menu;
+ Gnomenu.MenuItem item = find_item();
+ if(item != null)
+ shell.activate_item(item, true);
+ };
+ this.state_changed += (_this, previous_state) => {
+ this.state = Gtk.StateType.NORMAL;
+ };
+ }
+
+ public Gnomenu.MenuItem? find_item() {
+ Gnomenu.Shell shell = parent as Gnomenu.Shell;
+ for(int i = 0; i < shell.length; i++) {
+ Gnomenu.MenuItem item = shell.get_item(i) as Gnomenu.MenuItem;
+ if(item.item_label != null &&
+ item.item_label.casefold()
+ .has_prefix(textbox.text.casefold())) {
+ return item as Gnomenu.MenuItem;
}
- return null;
}
+ return null;
+ }
- public override void parent_set(Gtk.Widget? previous_parent) {
- if(previous_parent!=null) {
- previous_parent.key_press_event -= steal_key_press_event;
- }
- base.parent_set(previous_parent);
- if(parent != null) {
- parent.key_press_event += steal_key_press_event;
- }
+ public override void parent_set(Gtk.Widget? previous_parent) {
+ if(previous_parent!=null) {
+ previous_parent.key_press_event -= steal_key_press_event;
}
- private bool steal_key_press_event(Gtk.Widget widget,
- Gdk.EventKey event) {
- return textbox.key_press_event(event);
+ base.parent_set(previous_parent);
+ if(parent != null) {
+ parent.key_press_event += steal_key_press_event;
}
- public override void activate_item() {
+ }
+ private bool steal_key_press_event(Gtk.Widget widget,
+ Gdk.EventKey event) {
+ return textbox.key_press_event(event);
+ }
+ public override void activate_item() {
+ }
+ public override void activate() {
+ }
+}
+
+
+/**
+ * Toolhelp routines
+ *
+ * */
+private Gdk.Pixbuf guess_icon(Wnck.Window window, int width = -1, int height = -1) {
+ Gdk.Pixbuf[] icons = {
+ window.get_mini_icon(),
+ window.get_icon()};
+ return guess_icon_array(icons, width, height);
+}
+private Gdk.Pixbuf guess_icon_array(Gdk.Pixbuf[] icons, int width, int height) {
+ Gdk.Pixbuf icon = null;
+ int min_dist = 99999;
+ int best_size = 16;
+ if(height == -1 || width == -1) {
+ Gtk.icon_size_lookup(Gtk.IconSize.MENU, out width, out height);
+ }
+ int scaled_size = height;
+ if(width < scaled_size)
+ scaled_size = width;
+
+ foreach(Gdk.Pixbuf i in icons) {
+ int size = i.height;
+ if(i.get_width() > size)
+ size = i.width;
+ int dist = size - scaled_size;
+ if(dist < 0) dist = -dist;
+ if(dist < min_dist) {
+ min_dist = dist;
+ icon = i;
+ best_size = size;
}
- public override void activate() {
+ }
+
+ /* This should never happen. In case it happens
+ * return something to make sure it doesn't crash*/
+ if(icon == null) return icons[0];
+ double ratio = (double)scaled_size/(double)best_size;
+ if(ratio < 0) ratio = 1.0;
+ int scaled_width = (int) (icon.width * ratio);
+ int scaled_height = (int) (icon.height * ratio);
+
+ Gdk.Pixbuf scaled_icon = new Gdk.Pixbuf(
+ Gdk.Colorspace.RGB,
+ icon.has_alpha, 8,
+ scaled_width,
+ scaled_height
+ );
+
+ icon.scale(scaled_icon,
+ 0, 0, scaled_icon.width, scaled_icon.height,
+ 0, 0, ratio, ratio, Gdk.InterpType.BILINEAR);
+ /* can't use scale_simple because the vala binding is wrong*/
+ return scaled_icon;
+}
+
+private bool guess_dock_is_around() {
+ weak GLib.List<Wnck.Window> windows = Wnck.Screen.get_default().get_windows();
+ foreach(weak Wnck.Window window in windows)
+ if (window.get_window_type() == Wnck.WindowType.DOCK) {
+ switch(window.get_application().get_name()) {
+ case "cairo-dock":
+ case "avant-window-navigator":
+ case "Do":
+ /* add any other known dock having a task bar */
+ return true;
+ break;
+ }
}
+ return false;
+}
+
+private Wnck.Window? find_desktop() {
+ weak GLib.List<Wnck.Window> windows = Wnck.Screen.get_default().get_windows();
+ foreach(weak Wnck.Window window in windows)
+ if (window.get_window_type() == Wnck.WindowType.DESKTOP) return window;
+ return null;
+}
+
+private string replace(string source, string find, string replacement) {
+ /* replaces the string.replace method which depends on GLib.RegEx >= 2.12 */
+ string[] buf = source.split(find);
+ StringBuilder sb = new StringBuilder("");
+ for (int co=0; co<buf.length; co++) {
+ sb.append(buf[co]);
+ if (co!=(buf.length-1)) sb.append(replacement);
+ }
+ return sb.str;
+}
+
+private string remove_path(string txt, string separator) {
+ long co = txt.length-1;
+ while ((co>=0) && (txt.substring(co, 1)!=separator)) {
+ co--;
}
+ string ret = txt.substring(co+1,(txt.length-co-1));
+ return ret;
+}
+private string pixbuf_encode_b64(Gdk.Pixbuf pixbuf) {
+ Gdk.Pixdata pixdata = {0};
+ pixdata.from_pixbuf(pixbuf, true);
+ return Base64.encode(pixdata.serialize());
+}
View
2  applet/workspaceselector.vala
@@ -267,7 +267,7 @@ class WorkspaceSelector : Gtk.Window {
return target.get_workspace().get_viewport_y() / screen_height;
}
}
- public WorkspaceItem selected_item {
+ public WorkspaceItem? selected_item {
get {
foreach(weak WorkspaceItem wi in workspaces)
if (wi.selected) return wi;
View
10 configure.ac
@@ -54,7 +54,7 @@ fi
# Check for Vala
VALA_PROG_VALAC(0.5.6)
-VALA_DEFAULT_PKGS="--vapidir \$(top_srcdir) --vapidir \$(top_srcdir)/vapi --pkg configmake --pkg licenses --pkg config"
+VALA_DEFAULT_PKGS="--vapidir \$(top_srcdir) --vapidir \$(top_srcdir)/vapi --pkg configmake --pkg config"
AC_SUBST(VALA_DEFAULT_PKGS)
# check for modules
@@ -166,10 +166,10 @@ GTK_MODULES_DIR="$($PKG_CONFIG --variable=libdir gtk+-2.0)/gtk-2.0/modules"
AC_SUBST(GTK_MODULES_DIR)
# svnversion
-AC_PATH_PROG(SVNVERSION_BIN, [svnversion])
-SVNVERSION=`$SVNVERSION_BIN|sed -e 's;:;_;g' -e 's;exported;;'`
-AC_SUBST(SVNVERSION)
-AC_DEFINE_UNQUOTED(SVNVERSION, "$SVNVERSION", [svn version if appropriate])
+dnl AC_PATH_PROG(SVNVERSION_BIN, [svnversion])
+dnl SVNVERSION=`$SVNVERSION_BIN|sed -e 's;:;_;g' -e 's;exported;;'`
+dnl AC_SUBST(SVNVERSION)
+dnl AC_DEFINE_UNQUOTED(SVNVERSION, "$SVNVERSION", [svn version if appropriate])
# old automake fix
AC_SUBST(abs_top_srcdir)
View
34 gnome-globalmenu.schemas.in
@@ -13,13 +13,33 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/globalmenu-panel-applet/prefs/disable_module_check</key>
+ <owner>globalmenu-panel-applet</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short>Disable checking the GTK plugin module at startup</short>
+ <long>Disable checking the GTK plugin module at startup. If you know the module is loaded but for some reasons the applet cannot correctly detect this fact, set this key to true to skip the checking.</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/globalmenu-panel-applet/prefs/has_handle</key>
+ <owner>globalmenu-panel-applet</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short>Add a handle to the applet</short>
+ <long>Specify if the applet has a handle. When the handle is enabled, the applet will not expand to occupy the remaining empty area on the panel.</long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/globalmenu-panel-applet/prefs/show_icon</key>
<owner>globalmenu-panel-applet</owner>
<type>bool</type>
<default>FALSE</default>
<locale name="C">
- <short>Icon</short>
- <long>Show/Hide the icon of the active window</long>
+ <short>Show the icon of the action window in the applet</short>
+ <long>Show the icon of the active window in the applet when enabled.</long>
</locale>
</schema>
<schema>
@@ -28,8 +48,8 @@
<type>bool</type>
<default>TRUE</default>
<locale name="C">
- <short>Label</short>
- <long>Show/Hide the name of the active application</long>
+ <short>Show the name of the active application in the applet</short>
+ <long>Show the name of the active application in the applet when enabled</long>
</locale>
</schema>
<schema>
@@ -38,7 +58,7 @@
<type>bool</type>
<default>TRUE</default>
<locale name="C">
- <short>Window List</short>
+ <short>Enabled the Window List</short>
<long>Switch among applications via the application name label</long>
</locale>
</schema>
@@ -48,7 +68,7 @@
<type>bool</type>
<default>TRUE</default>
<locale name="C">
- <short>Window Actions</short>
+ <short>Enable the Window Actions</short>
<long>Add window action menu entries to active application name menu</long>
</locale>
</schema>
@@ -58,7 +78,7 @@
<type>int</type>
<default>-1</default>
<locale name="C">
- <short>Max title length</short>
+ <short>Maximum length of the title area</short>
<long>The maximum length of name of the active application, in pixels</long>
</locale>
</schema>
View
2  gnome-globalmenu.spec
@@ -1,5 +1,5 @@
%define base_version 0.7.6
-%define alphatag 20080423svn2524
+%define alphatag 20080423svn2525
Name: gnome-globalmenu
Version: %{base_version}
View
2  gtk-modules/globalmenu/module-main.vala
@@ -48,7 +48,7 @@ public class GlobalMenuGNOME {
prepare_log_file();
Log.set_handler (domain.to_string(), LogLevelFlags.LEVEL_DEBUG, default_log_handler);
- debug("Global Menu Version: %s:%s", Config.VERSION, Config.SVNVERSION);
+ debug("Global Menu Version: %s", Config.VERSION);
if(!disabled) {
debug("Global Menu is enabled");
} else {
View
4 gtk-modules/globalmenu/tests/test-unload.vala
@@ -16,13 +16,13 @@ namespace GnomenuGtk {
add("test", () => {
Builder builder = new Builder();
try {
- builder.add_from_file(Config.ABSTOPSRCDIR + rel_path +"/tests/test-unload.ui");
+ builder.add_from_file("./test-unload.ui");
} catch(GLib.Error e) {
critical("%s", e.message);
}
window = builder.get_object("test_window") as Window;
chooser = builder.get_object("chooser") as FileChooser;
- chooser.set_filename(Config.ABSTOPSRCDIR + rel_path + "/.libs/libglobalmenu-gnome.so");
+ chooser.set_filename("./libglobalmenu-gnome.so");
load = builder.get_object("load") as Button;
unload = builder.get_object("unload") as Button;
load.clicked += load_module;
View
4 libgnomenu/application.vala
@@ -81,6 +81,10 @@ public class Application{
screen.window_opened += window_opened;
screen.window_closed += window_closed;
screen.application_closed += application_closed;
+ unowned List<AppInfo> appinfos = AppInfo.get_all();
+ foreach(var appinfo in appinfos) {
+ message("%s", appinfo.get_executable());
+ }
}
private Application() { }
View
16 libgnomenu/menu.vala
@@ -14,22 +14,10 @@ namespace Gnomenu {
base.dispose();
}
static construct {
- Gtk.Settings.install_property(
- new ParamSpecBoolean("use-rgba-colormap",
- "use RGBA colormap if possible",
- "Use RGBA colormap if possible",
- false,
- ParamFlags.READABLE | ParamFlags.WRITABLE));
}
construct {
- get_settings().notify["use-rgba-colormap"] += (settings) => {
- bool val = false;
- settings.get("use-rgba-colormap", &val, null);
- use_rgba_colormap = val;
- };
- bool val = false;
- get_settings().get("use-rgba-colormap", &val, null);
- use_rgba_colormap = val;
+ weak string rgba = Environment.get_variable("LIBGNOMENU_ENABLE_RGBA");
+ use_rgba_colormap = (rgba != null);
}
private bool disposed = false;
private bool _use_rgba_colormap = false;
View
53 libgnomenu/menubar.vala
@@ -76,12 +76,6 @@ namespace Gnomenu {
construct {
disposed = false;
_background = new Background();
- /*This is quirky. min_length should be
- * a 'constrcut set' property, and this
- * value should be set in CreateMethod,
- * however then test-menubar will
- * fail to build due to a vala bug in 0.5.1*/
- _min_length = -1;
setup_overflown_item();
}
public override void dispose() {
@@ -217,29 +211,14 @@ namespace Gnomenu {
switch(pack_direction) {
case PackDirection.TTB:
case PackDirection.BTT:
- return allocation.height < real_requisition.height;
+ return allocation.height < requisition.height;
case PackDirection.LTR:
case PackDirection.RTL:
default:
- return allocation.width < real_requisition.width;
+ return allocation.width < requisition.width;
}
}
}
- /* minimal length of the menubar.
- * if >= 0,
- * the menu bar will report this length to
- * either width or height in ::request
- *
- * Notice that initally this value is <0,
- * to avoid a recursion of new MenuBar();
- * */
- public int min_length {
- get { return _min_length;}
- set {
- _min_length = value;
- queue_resize();
- }
- }
/**
* Look up a child item from a path.
@@ -295,10 +274,6 @@ namespace Gnomenu {
private MenuItem _overflown_item = new Gnomenu.MenuItem();
- private int _min_length;
-
- private Requisition real_requisition;
-
private bool disposed;
public override void style_set(Style? old_style) {
@@ -520,25 +495,11 @@ namespace Gnomenu {
return false;
}
public override void size_request(out Requisition req) {
- base.size_request(out real_requisition);
- req = real_requisition;
- if(min_length >= 0) {
- Requisition r = {0, 0};
- if(_overflown_item!= null) {
- _overflown_item.size_request(out r);
- }
- switch(pack_direction) {
- case PackDirection.TTB:
- case PackDirection.BTT:
- req.height = min_length>r.height? min_length: r.height;
- break;
- case PackDirection.LTR:
- case PackDirection.RTL:
- default:
- req.width = min_length>r.width?min_length:r.width;
- break;
- }
- }
+ Requisition r = {0, 0};
+ base.size_request(out req);
+ _overflown_item.size_request(out r);
+ if(r.width > req.width) req.width = r.width;
+ if(r.height > req.height) req.height = r.height;
}
public override void insert(Widget child, int position) {
base.insert(child, position);
View
79 libgnomenu/menubarbox.vala
@@ -5,8 +5,10 @@ namespace Gnomenu {
public class MenuBarBox: Gtk.Container {
private struct ChildPropBag {
public bool expand;
+ public bool shrink;
}
static const int PROP_EXPAND = 1234;
+ static const int PROP_SHRINK = 1235;
static construct {
install_child_property(PROP_EXPAND,
new ParamSpecBoolean(
@@ -17,6 +19,15 @@ public class MenuBarBox: Gtk.Container {
ParamFlags.READABLE |
ParamFlags.WRITABLE
));
+ install_child_property(PROP_SHRINK,
+ new ParamSpecBoolean(
+ "shrink",
+ "shrink",
+ "the child will shrink if set to true",
+ false,
+ ParamFlags.READABLE |
+ ParamFlags.WRITABLE
+ ));
}
public PackDirection pack_direction {
/* The child menubar's child pack direction is the same
@@ -90,6 +101,11 @@ public class MenuBarBox: Gtk.Container {
private List<weak Gnomenu.MenuBar> children;
+ private int[] size_hints;
+
+ public unowned int[] get_size_hints() {
+ return size_hints;
+ }
public override void forall(bool include_internals, Gtk.Callback callback) {
if(include_internals) {
@@ -121,26 +137,37 @@ public class MenuBarBox: Gtk.Container {
r.width = 0;
r.height = 0;
Requisition cr;
+ List<int> hints = null;
foreach(Gnomenu.MenuBar menubar in children) {
if(!menubar.visible) continue;
menubar.size_request(out cr);
+ bool shrink = false;
+ child_get(menubar, "shrink", &shrink);
switch(pack_direction) {
case PackDirection.LTR:
case PackDirection.RTL:
r.height = r.height>cr.height?r.height:cr.height;
+ hints.prepend(r.width + 2);
r.width += cr.width;
+ hints.prepend(r.width + 1);
break;
case PackDirection.BTT:
case PackDirection.TTB:
r.width = r.width>cr.width?r.width:cr.width;
+ hints.prepend(r.height + 2);
r.height += cr.height;
+ hints.prepend(r.height + 1);
break;
}
}
+ size_hints = new int[hints.length()];
+ int i = 0;
+ foreach(int val in hints) {
+ size_hints[i] = val;
+ i++;
+ }
}
- public override void map() {
- base.map();
- }
+
public override void size_allocate(Gdk.Rectangle a) {
allocation = (Allocation) a;
Requisition cr;
@@ -150,37 +177,37 @@ public class MenuBarBox: Gtk.Container {
int rev_x = a.width;
int rev_y = a.height;
- int num_of_expands = 0;
- int non_expand_a = 0;
+ int num_of_shrinks = 0;
+ int non_shrink_a = 0;
foreach(Gnomenu.MenuBar menubar in children) {
if(!menubar.visible) continue;
- bool expand = false;
- child_get(menubar, "expand", &expand, null);
- if(expand) num_of_expands++;
+ bool shrink = false;
+ child_get(menubar, "shrink", &shrink, null);
+ if(shrink) num_of_shrinks++;
else {
menubar.get_child_requisition(out cr);
switch(pack_direction) {
case PackDirection.LTR:
case PackDirection.RTL:
- non_expand_a += cr.width;
+ non_shrink_a += cr.width;
break;
case PackDirection.BTT:
case PackDirection.TTB:
- non_expand_a += cr.height;
+ non_shrink_a += cr.height;
break;
}
}
}
foreach(Gnomenu.MenuBar menubar in children) {
- bool expand = false;
+ bool shrink = false;
if(!menubar.visible) continue;
menubar.get_child_requisition(out cr);
- child_get(menubar, "expand", &expand, null);
+ child_get(menubar, "shrink", &shrink, null);
switch(pack_direction) {
case PackDirection.LTR:
- if(expand) {
- ca.width = (a.width - non_expand_a)/num_of_expands;
+ if(shrink) {
+ ca.width = (a.width - non_shrink_a)/num_of_shrinks;
if(ca.width < 0) ca.width = 0;
} else {
ca.width = cr.width;
@@ -191,8 +218,8 @@ public class MenuBarBox: Gtk.Container {
x += ca.width;
break;
case PackDirection.RTL:
- if(expand) {
- ca.width = (a.width - non_expand_a)/num_of_expands;
+ if(shrink) {
+ ca.width = (a.width - non_shrink_a)/num_of_shrinks;
if(ca.width < 0) ca.width = 0;
} else {
ca.width = cr.width;
@@ -205,8 +232,8 @@ public class MenuBarBox: Gtk.Container {
break;
case PackDirection.TTB:
ca.width = a.width;
- if(expand) {
- ca.height = (a.height - non_expand_a)/num_of_expands;
+ if(shrink) {
+ ca.height = (a.height - non_shrink_a)/num_of_shrinks;
if(ca.height < 0) ca.height = 0;
} else {
ca.height = cr.height;
@@ -217,8 +244,8 @@ public class MenuBarBox: Gtk.Container {
break;
case PackDirection.BTT:
ca.width = a.width;
- if(expand) {
- ca.height = (a.height - non_expand_a)/num_of_expands;
+ if(shrink) {
+ ca.height = (a.height - non_shrink_a)/num_of_shrinks;
if(ca.height < 0) ca.height = 0;
} else {
ca.height = cr.height;
@@ -240,6 +267,10 @@ public class MenuBarBox: Gtk.Container {
ChildPropBag* prop = props.lookup(child);
value.set_boolean(prop->expand);
break;
+ case PROP_SHRINK:
+ ChildPropBag* prop = props.lookup(child);
+ value.set_boolean(prop->shrink);
+ break;
}
}
public override void set_child_property(Gtk.Widget child, uint id,
@@ -253,6 +284,14 @@ public class MenuBarBox: Gtk.Container {
queue_resize();
}
break;
+ case PROP_SHRINK:
+ bool shrink = value.get_boolean();
+ ChildPropBag* prop = props.lookup(child);
+ if(prop->shrink != shrink ) {
+ prop->shrink = shrink;
+ queue_resize();
+ }
+ break;
}
}
View
3  libgnomenu/menuitem.vala
@@ -610,7 +610,8 @@ namespace Gnomenu {
else
desc = null;
weak Widget bin_child = get_child();
- bin_child.modify_font(desc);
+ if(bin_child != null)
+ bin_child.modify_font(desc);
}
private void update_label_text() {
if(!Item.type_has_label(_item_type)) return;
View
2  libgnomenu/tests/test-leak.vala
@@ -40,7 +40,7 @@ namespace Gnomenu {
shell = new MenuBar();
window.add(shell);
string test3;
- FileUtils.get_contents(Config.ABSTOPSRCDIR + "/libgnomenu/tests/evo-nolabel.xml", out test3, null);
+ FileUtils.get_contents("./evo-nolabel.xml", out test3, null);
Parser.parse(shell as MenuBar, test3);
// mem_profile();
for(i = 0; i< 10; i++) {
View
4 libgnomenu/tests/test-menubar.vala
@@ -78,7 +78,6 @@ namespace Gnomenu {
add("usability", () => {
assert(window is Gtk.Window);
Parser.parse( menubar, test1);
- menubar.min_length = -1;
window.show();
Gtk.main();
});
@@ -87,7 +86,6 @@ namespace Gnomenu {
Parser.parse( menubar, test1);
menubar.modify_bg(StateType.NORMAL, color);
menubar.gravity = Gravity.DOWN;
- menubar.min_length = 20;
window.resize(20, 20);
window.show();
assert(menubar.overflown == true);
@@ -103,7 +101,6 @@ namespace Gnomenu {
Parser.parse( menubar, test1);
menubar.modify_bg(StateType.NORMAL, color);
menubar.gravity = Gravity.RIGHT;
- menubar.min_length = 20;
menubar.pack_direction = Gtk.PackDirection.BTT;
window.resize(20, 20);
window.show();
@@ -119,7 +116,6 @@ namespace Gnomenu {
});
add("sensitive", () => {
Parser.parse( menubar, test1);
- menubar.min_length = -1;
window.show();
/*
won't compile before vala 0.5.7
View
4 libgnomenu/tests/test-parser.vala
@@ -59,8 +59,8 @@ namespace Gnomenu {
shell = new MenuBar();
string test3;
string test4;
- FileUtils.get_contents(Config.ABSTOPSRCDIR + "/libgnomenu/tests/evo-nolabel.xml", out test3, null);
- FileUtils.get_contents(Config.ABSTOPSRCDIR + "/libgnomenu/tests/evo.xml", out test4, null);
+ FileUtils.get_contents("./evo-nolabel.xml", out test3, null);
+ FileUtils.get_contents("./evo.xml", out test4, null);
Parser.parse(shell, test3);
Parser.parse(shell, test3);
Parser.parse(shell, test3);
View
109 po/de.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: globalmenu\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-23 22:00-0400\n"
+"POT-Creation-Date: 2009-05-05 17:11-0400\n"
"PO-Revision-Date: 2009-04-20 20:00+0000\n"
"Last-Translator: atomfrede <Unknown>\n"
"Language-Team: German <de@li.org>\n"
@@ -55,55 +55,55 @@ msgid ""
"instead of the command line."
msgstr ""
-#: ../applet/applet.vala:138
+#: ../applet/applet.vala:169
msgid "globalmenu-panel-applet"
msgstr "globalmenu-panel-applet"
-#: ../applet/applet.vala:200
+#: ../applet/applet.vala:216
msgid "_Preferences"
msgstr "_Einstellungen"
-#: ../applet/applet.vala:201
+#: ../applet/applet.vala:217
msgid "_Help"
msgstr "_Hilfe"
-#: ../applet/applet.vala:202
+#: ../applet/applet.vala:218
msgid "_About"
msgstr "_Über"
-#: ../applet/applet.vala:230
+#: ../applet/applet.vala:246
msgid "No Global Menu?"
msgstr "Kein Globalesmenu?"
-#: ../applet/applet.vala:231
+#: ../applet/applet.vala:247
msgid "The Global Menu Plugin is not enabled on this desktop."
msgstr "Global Menu Plugin ist nicht aktiviert"
-#: ../applet/applet.vala:232
+#: ../applet/applet.vala:248
msgid ""
"Enable the plugin by accessing the preferences dialog via a right-click,"
msgstr ""
-#: ../applet/applet.vala:233
+#: ../applet/applet.vala:249
msgid "or by exporting GTK_MODULES=globalmenu-gnome in your profile."
msgstr ""
-#: ../applet/applet.vala:266
+#: ../applet/applet.vala:283
msgid "Project Home"
msgstr "Projektseite"
-#: ../applet/applet.vala:272
+#: ../applet/applet.vala:301
msgid "translator-credits"
msgstr ""
"Launchpad Contributions:\n"
" Thomas Trummer https://launchpad.net/~truetom\n"
" atomfrede https://launchpad.net/~atomfrede"
-#: ../applet/applet.vala:284
+#: ../applet/applet.vala:313
msgid "On-line help"
msgstr "Online-Hilfe"
-#: ../applet/applet.vala:295
+#: ../applet/applet.vala:324
msgid "Global Menu Applet Preferences"
msgstr "Global Menu Einstellungen"
@@ -151,11 +151,11 @@ msgstr ""
msgid "_Close"
msgstr "_Schließen"
-#: ../applet/switcher.vala:272
+#: ../applet/switcher.vala:249
msgid "Show _Desktop"
msgstr "_Desktop anzeigen"
-#: ../applet/switcher.vala:372
+#: ../applet/switcher.vala:292
msgid "Desktop"
msgstr ""
@@ -164,54 +164,80 @@ msgid "Follow the window"
msgstr ""
#: ../gnome-globalmenu.schemas.in.h:1
-msgid "Add window action menu entries to active application name menu"
+msgid "Add a handle to the applet"
msgstr ""
#: ../gnome-globalmenu.schemas.in.h:2
-msgid "Enable Global Menu For GTK applications"
-msgstr "Globales Menü für GTK Anwendungen verwenden"
+msgid "Add window action menu entries to active application name menu"
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:3
-msgid "Icon"
-msgstr "Symbol"
+msgid "Disable checking the GTK plugin module at startup"
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:4
msgid ""
-"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
-"loaded."
+"Disable checking the GTK plugin module at startup. If you know the module is "
+"loaded but for some reasons the applet cannot correctly detect this fact, "
+"set this key to true to skip the checking."
msgstr ""
#: ../gnome-globalmenu.schemas.in.h:5
-msgid "Label"
-msgstr "Beschriftung"
+msgid "Enable Global Menu For GTK applications"
+msgstr "Globales Menü für GTK Anwendungen verwenden"
#: ../gnome-globalmenu.schemas.in.h:6
-msgid "Max title length"
-msgstr "Maximale Titellänge"
+msgid "Enable the Window Actions"
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:7
-msgid "Show/Hide the icon of the active window"
-msgstr "Zeige/Verstecke das Symbol des aktiven Fensters"
+#, fuzzy
+msgid "Enabled the Window List"
+msgstr "Fensterliste"
#: ../gnome-globalmenu.schemas.in.h:8
-msgid "Show/Hide the name of the active application"
-msgstr "Zeige/Verstecke den Namen der aktiven Anwendung"
+msgid ""
+"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
+"loaded."
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:9
-msgid "Switch among applications via the application name label"
+msgid "Maximum length of the title area"
msgstr ""
#: ../gnome-globalmenu.schemas.in.h:10
-msgid "The maximum length of name of the active application, in pixels"
-msgstr ""
+#, fuzzy
+msgid "Show the icon of the action window in the applet"
+msgstr "Zeige/Verstecke das Symbol des aktiven Fensters"
#: ../gnome-globalmenu.schemas.in.h:11
-msgid "Window Actions"
-msgstr ""
+#, fuzzy
+msgid "Show the icon of the active window in the applet when enabled."
+msgstr "Zeige/Verstecke das Symbol des aktiven Fensters"
#: ../gnome-globalmenu.schemas.in.h:12
-msgid "Window List"
-msgstr "Fensterliste"
+#, fuzzy
+msgid "Show the name of the active application in the applet"
+msgstr "Zeige/Verstecke den Namen der aktiven Anwendung"
+
+#: ../gnome-globalmenu.schemas.in.h:13
+#, fuzzy
+msgid "Show the name of the active application in the applet when enabled"
+msgstr "Zeige/Verstecke den Namen der aktiven Anwendung"
+
+#: ../gnome-globalmenu.schemas.in.h:14
+msgid ""
+"Specify if the applet has a handle. When the handle is enabled, the applet "
+"will not expand to occupy the remaining empty area on the panel."
+msgstr ""
+
+#: ../gnome-globalmenu.schemas.in.h:15
+msgid "Switch among applications via the application name label"
+msgstr ""
+
+#: ../gnome-globalmenu.schemas.in.h:16
+msgid "The maximum length of name of the active application, in pixels"
+msgstr ""
#: ../applet/GlobalMenu_PanelApplet.server.in.in.h:1
msgid "Global Menu Panel Applet"
@@ -232,3 +258,12 @@ msgstr ""
#: ../xfce/GlobalMenu_XFCEPlugin.desktop.in.in.h:2
msgid "The Global Menu Plugin for XFCE Panel"
msgstr ""
+
+#~ msgid "Icon"
+#~ msgstr "Symbol"
+
+#~ msgid "Label"
+#~ msgstr "Beschriftung"
+
+#~ msgid "Max title length"
+#~ msgstr "Maximale Titellänge"
View
116 po/en_GB.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: globalmenu\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-23 22:00-0400\n"
+"POT-Creation-Date: 2009-05-05 17:11-0400\n"
"PO-Revision-Date: 2009-04-13 15:41+0000\n"
"Last-Translator: Alex Anthony <Unknown>\n"
"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
@@ -55,54 +55,54 @@ msgid ""
"instead of the command line."
msgstr ""
-#: ../applet/applet.vala:138
+#: ../applet/applet.vala:169
msgid "globalmenu-panel-applet"
msgstr "globalmenu-panel-applet"
-#: ../applet/applet.vala:200
+#: ../applet/applet.vala:216
msgid "_Preferences"
msgstr "_Preferences"
-#: ../applet/applet.vala:201
+#: ../applet/applet.vala:217
msgid "_Help"
msgstr "_Help"
-#: ../applet/applet.vala:202
+#: ../applet/applet.vala:218
msgid "_About"
msgstr "_About"
-#: ../applet/applet.vala:230
+#: ../applet/applet.vala:246
msgid "No Global Menu?"
msgstr ""
-#: ../applet/applet.vala:231
+#: ../applet/applet.vala:247
msgid "The Global Menu Plugin is not enabled on this desktop."
msgstr ""
-#: ../applet/applet.vala:232
+#: ../applet/applet.vala:248
msgid ""
"Enable the plugin by accessing the preferences dialog via a right-click,"
msgstr ""
-#: ../applet/applet.vala:233
+#: ../applet/applet.vala:249
msgid "or by exporting GTK_MODULES=globalmenu-gnome in your profile."
msgstr ""
-#: ../applet/applet.vala:266
+#: ../applet/applet.vala:283
msgid "Project Home"
msgstr "Project Home"
-#: ../applet/applet.vala:272
+#: ../applet/applet.vala:301
msgid "translator-credits"
msgstr ""
"Launchpad Contributions:\n"
" Alex Anthony https://launchpad.net/~alex-anthony28991"
-#: ../applet/applet.vala:284
+#: ../applet/applet.vala:313
msgid "On-line help"
msgstr "On-line help"
-#: ../applet/applet.vala:295
+#: ../applet/applet.vala:324
msgid "Global Menu Applet Preferences"
msgstr ""
@@ -150,11 +150,11 @@ msgstr "_Workspace..."
msgid "_Close"
msgstr "_Close"
-#: ../applet/switcher.vala:272
+#: ../applet/switcher.vala:249
msgid "Show _Desktop"
msgstr "Show _Desktop"
-#: ../applet/switcher.vala:372
+#: ../applet/switcher.vala:292
msgid "Desktop"
msgstr ""
@@ -163,56 +163,83 @@ msgid "Follow the window"
msgstr "Follow the window"
#: ../gnome-globalmenu.schemas.in.h:1
-msgid "Add window action menu entries to active application name menu"
-msgstr "Add window action menu entries to active application name menu"
+msgid "Add a handle to the applet"
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:2
-msgid "Enable Global Menu For GTK applications"
-msgstr "Enable Global Menu For GTK applications"
+msgid "Add window action menu entries to active application name menu"
+msgstr "Add window action menu entries to active application name menu"
#: ../gnome-globalmenu.schemas.in.h:3
-msgid "Icon"
-msgstr "Icon"
+msgid "Disable checking the GTK plugin module at startup"
+msgstr ""
#: ../gnome-globalmenu.schemas.in.h:4
msgid ""
-"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
-"loaded."
+"Disable checking the GTK plugin module at startup. If you know the module is "
+"loaded but for some reasons the applet cannot correctly detect this fact, "
+"set this key to true to skip the checking."
msgstr ""
-"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
-"loaded."
#: ../gnome-globalmenu.schemas.in.h:5
-msgid "Label"
-msgstr "Label"
+msgid "Enable Global Menu For GTK applications"
+msgstr "Enable Global Menu For GTK applications"
#: ../gnome-globalmenu.schemas.in.h:6
-msgid "Max title length"
-msgstr "Max title length"
+#, fuzzy
+msgid "Enable the Window Actions"
+msgstr "Window Actions"
#: ../gnome-globalmenu.schemas.in.h:7
-msgid "Show/Hide the icon of the active window"
-msgstr "Show/Hide the icon of the active window"
+#, fuzzy
+msgid "Enabled the Window List"
+msgstr "Window List"
#: ../gnome-globalmenu.schemas.in.h:8
-msgid "Show/Hide the name of the active application"
-msgstr "Show/Hide the name of the active application"
+msgid ""
+"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
+"loaded."
+msgstr ""
+"If this key is true, libglobalmenu-gnome, the GTK plugin for Global Menu is "
+"loaded."
#: ../gnome-globalmenu.schemas.in.h:9
-msgid "Switch among applications via the application name label"
+msgid "Maximum length of the title area"
msgstr ""
#: ../gnome-globalmenu.schemas.in.h:10
-msgid "The maximum length of name of the active application, in pixels"
-msgstr "The maximum length of name of the active application, in pixels"
+#, fuzzy
+msgid "Show the icon of the action window in the applet"
+msgstr "Show/Hide the icon of the active window"
#: ../gnome-globalmenu.schemas.in.h:11
-msgid "Window Actions"
-msgstr "Window Actions"
+#, fuzzy
+msgid "Show the icon of the active window in the applet when enabled."
+msgstr "Show/Hide the icon of the active window"
#: ../gnome-globalmenu.schemas.in.h:12
-msgid "Window List"
-msgstr "Window List"
+#, fuzzy
+msgid "Show the name of the active application in the applet"
+msgstr "Show/Hide the name of the active application"
+
+#: ../gnome-globalmenu.schemas.in.h:13
+#, fuzzy
+msgid "Show the name of the active application in the applet when enabled"
+msgstr "Show/Hide the name of the active application"
+
+#: ../gnome-globalmenu.schemas.in.h:14
+msgid ""
+"Specify if the applet has a handle. When the handle is enabled, the applet "
+"will not expand to occupy the remaining empty area on the panel."
+msgstr ""
+
+#: ../gnome-globalmenu.schemas.in.h:15
+msgid "Switch among applications via the application name label"
+msgstr ""
+
+#: ../gnome-globalmenu.schemas.in.h:16
+msgid "The maximum length of name of the active application, in pixels"
+msgstr "The maximum length of name of the active application, in pixels"
#: ../applet/GlobalMenu_PanelApplet.server.in.in.h:1
msgid "Global Menu Panel Applet"
@@ -233,3 +260,12 @@ msgstr "Global Menu Plugin for XFCE Panel"
#: ../xfce/GlobalMenu_XFCEPlugin.desktop.in.in.h:2
msgid "The Global Menu Plugin for XFCE Panel"
msgstr "The Global Menu Plugin for XFCE Panel"
+
+#~ msgid "Icon"
+#~ msgstr "Icon"
+
+#~ msgid "Label"
+#~ msgstr "Label"
+
+#~ msgid "Max title length"
+#~ msgstr "Max title length"
View
116 po/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: globalmenu\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-04-23 22:00-0400\n"
+"POT-Creation-Date: 2009-05-05 17:11-0400\n"
"PO-Revision-Date: 2009-04-21 06:40+0000\n"
"Last-Translator: raziel <zimbiozix@hotmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
@@ -57,47 +57,47 @@ msgstr ""
"Esos parametros deben de ser proveidos en la seccion GLOBALMENU_GNOME_ARGS "
"y no en la linea de comando"