[dconf] editor: Add a GMenu
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] editor: Add a GMenu
- Date: Tue, 1 May 2012 23:44:44 +0000 (UTC)
commit aaf4b042e87e7c2970127648f80f7a73081ceccd
Author: Robert Ancell <robert ancell canonical com>
Date: Tue May 1 17:07:40 2012 +1200
editor: Add a GMenu
editor/Makefile.am | 4 +-
editor/dconf-editor-menu.ui | 15 +++++++++++++
editor/dconf-editor.vala | 48 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 4 deletions(-)
---
diff --git a/editor/Makefile.am b/editor/Makefile.am
index 55575fb..a030c7d 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -1,6 +1,6 @@
bin_PROGRAMS = dconf-editor
-AM_CFLAGS = $(gtk_CFLAGS) $(libxml_CFLAGS) -I$(top_srcdir)/common -I$(top_srcdir)/client -DPKGDATADIR=\"@datadir@/dconf-editor\"
+AM_CFLAGS = $(gtk_CFLAGS) $(libxml_CFLAGS) -I$(top_srcdir)/common -I$(top_srcdir)/client -DPKGDATADIR=\"@datadir@/dconf-editor\" -DVERSION=\"$(VERSION)\" -DGETTEXT_PACKAGE=\"dconf-editor\"
AM_VALAFLAGS = --vapidir ../client --pkg gtk+-3.0 --pkg libxml-2.0 --pkg dconf
CFLAGS += -Wno-error -Wno-unused-but-set-variable -Wno-unused-variable
dconf_editor_LDADD = ../client/libdconf.so.0 $(gtk_LIBS) $(gee_LIBS) $(libxml_LIBS)
@@ -29,6 +29,6 @@ update-icon-cache:
fi
uidir = $(datadir)/dconf-editor
-dist_ui_DATA = dconf-editor.ui
+dist_ui_DATA = dconf-editor.ui dconf-editor-menu.ui
EXTRA_DIST = $(gsettings_SCHEMAS) $(icons)
diff --git a/editor/dconf-editor-menu.ui b/editor/dconf-editor-menu.ui
new file mode 100644
index 0000000..8f62c3c
--- /dev/null
+++ b/editor/dconf-editor-menu.ui
@@ -0,0 +1,15 @@
+<interface>
+ <menu id="menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index c49cd5e..62058c7 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -17,14 +17,24 @@ class ConfigurationEditor : Gtk.Application
private Key? selected_key;
+ private const GLib.ActionEntry[] action_entries =
+ {
+ { "about", about_cb },
+ { "quit", quit_cb }
+ };
+
public ConfigurationEditor()
{
Object(application_id: "ca.desrt.dconf-editor", flags: ApplicationFlags.FLAGS_NONE);
}
-
+
protected override void startup()
{
base.startup();
+
+ Environment.set_application_name (_("DConf Editor"));
+
+ add_action_entries (action_entries, this);
settings = new Settings ("ca.desrt.dconf-editor.Settings");
@@ -33,7 +43,7 @@ class ConfigurationEditor : Gtk.Application
ui = new Gtk.Builder();
try
{
- string[] objects = { "set_default_action", "hpaned1" };
+ string[] objects = { "set_default_action", "hpaned1", "menu" };
ui.add_objects_from_file(Path.build_filename(Config.PKGDATADIR, "dconf-editor.ui"), objects);
}
catch (Error e)
@@ -47,6 +57,17 @@ class ConfigurationEditor : Gtk.Application
window.configure_event.connect(main_window_configure_event_cb);
window.add((Gtk.HPaned)ui.get_object("hpaned1"));
+ var menu_ui = new Gtk.Builder();
+ try
+ {
+ menu_ui.add_from_file(Path.build_filename(Config.PKGDATADIR, "dconf-editor-menu.ui"));
+ }
+ catch (Error e)
+ {
+ critical("Failed to load menu UI: %s", e.message);
+ }
+ set_app_menu((MenuModel)menu_ui.get_object("menu"));
+
window.set_default_size (settings.get_int ("width"), settings.get_int ("height"));
if (settings.get_boolean ("maximized"))
window.maximize ();
@@ -216,6 +237,29 @@ class ConfigurationEditor : Gtk.Application
return false;
}
+ private void about_cb()
+ {
+ string[] authors = { "Robert Ancell", null };
+ string license = _("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.\n\nThis 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.\n\nYou 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 Street, Fifth Floor, Boston, MA 02110-1301, USA");
+ Gtk.show_about_dialog (window,
+ "program-name", _("DConf Editor"),
+ "version", Config.VERSION,
+ "comments",
+ _("Directly edit your entire configuration database"),
+ "copyright", "Copyright \xc2\xa9 Canonical Ltd",
+ "license", license,
+ "wrap-license", true,
+ "authors", authors,
+ "translator-credits", _("translator-credits"),
+ "logo-icon-name", "dconf-editor",
+ null);
+ }
+
+ private void quit_cb()
+ {
+ window.destroy();
+ }
+
public static int main(string[] args)
{
var app = new ConfigurationEditor();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]