[baobab/wip/vala] First cut at menus
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala] First cut at menus
- Date: Sun, 15 Jan 2012 13:48:58 +0000 (UTC)
commit f8368d0772171ac32bdc522a84b9a70af82884fa
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 15 14:48:18 2012 +0100
First cut at menus
data/baobab-main-window.ui | 35 +++++++++++++++++++++++++++++++++++
src/baobab-application.vala | 21 +++++++++++++++++++--
src/baobab-window.vala | 38 ++++++++++++++++++++++++++++++++------
3 files changed, 86 insertions(+), 8 deletions(-)
---
diff --git a/data/baobab-main-window.ui b/data/baobab-main-window.ui
index a259707..5309d20 100644
--- a/data/baobab-main-window.ui
+++ b/data/baobab-main-window.ui
@@ -1,6 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <item label="_Help" action="app.help" accel="F1"/>
+ <item label="_About" action="app.about"/>
+ <item label="_Quit" action="app.quit" accel="<Primary>q"/>
+ </section>
+ </menu>
+ <menu id="menubar">
+ <section>
+ <submenu label="_Analyzer">
+ <section>
+ <item label="_Scan Home" action="win.scan-home" accel="<Primary>h"/>
+ <item label="Scan _Filesystem" action="win.scan-filesystem" accel="<Primary>f"/>
+ <item label="Scan F_older" action="win.scan-folder" accel="<Primary>o"/>
+ </section>
+ </submenu>
+ <submenu label="_View">
+ <section>
+ <item label="_Stop" action="win.stop"/>
+ <item label="_Reload" action="win.reload" accel="<Primary>r"/>
+ </section>
+ <section>
+ <item label="_Toolbar" action="win.show-toolbar"/>
+ <item label="_Statusbar" action="win.show-statusbar"/>
+ </section>
+ <section>
+ <item label="_Allocated Space" action="win.show-allocated"/>
+ </section>
+ <section>
+ <item label="_Expand All" action="win.expand-all"/>
+ <item label="_Collapse All" action="win.collapse-all"/>
+ </section>
+ </submenu>
+ </section>
+ </menu>
<object class="GtkGrid" id="window-contents">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index c8e3007..684f8d9 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -1,11 +1,17 @@
namespace Baobab {
public class Application : Gtk.Application {
+ static Application baobab;
+
+ private const GLib.ActionEntry[] action_entries = {
+ { "help", on_help_activate },
+ { "about", on_about_activate },
+ { "quit", on_quit_activate }
+ };
+
Settings desktop_settings;
Settings prefs_settings;
Settings ui_settings;
- static Application baobab;
-
protected override void activate () {
new Window (this);
}
@@ -61,6 +67,8 @@ namespace Baobab {
public Application () {
Object (application_id: "org.gnome.baobab", flags: ApplicationFlags.HANDLES_OPEN);
+
+ add_action_entries (action_entries, this);
}
public static Settings get_desktop_settings () {
@@ -77,5 +85,14 @@ namespace Baobab {
var app = baobab;
return app.ui_settings;
}
+
+ void on_help_activate () {
+ }
+
+ void on_about_activate () {
+ }
+
+ void on_quit_activate () {
+ }
}
}
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index efd41ab..5d6d13e 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -9,12 +9,17 @@ namespace Baobab {
static Gdk.Cursor busy_cursor;
private const GLib.ActionEntry[] action_entries = {
- { "scan-home", on_scan_home_activate },
+ { "scan-home", on_scan_home_activate },
{ "scan-filesystem", on_scan_filesystem_activate },
- { "scan-folder", on_scan_folder_activate },
- { "scan-remote", on_scan_remote_activate },
- { "stop", on_stop_activate },
- { "refresh", on_refresh_activate }
+ { "scan-folder", on_scan_folder_activate },
+ { "scan-remote", on_scan_remote_activate },
+ { "stop", on_stop_activate },
+ { "reload", on_reload_activate },
+ { "show-toolbar", on_show_toolbar },
+ { "show-statusbar", on_show_statusbar },
+ { "show-allocated", on_show_allocated },
+ { "expand-all", on_expand_all },
+ { "collapse-all", on_collapse_all }
};
private enum DndTargets {
@@ -40,6 +45,12 @@ namespace Baobab {
error ("loading main builder file: %s", e.message);
}
+ // Menus
+ var app_menu = builder.get_object ("appmenu") as MenuModel;
+ var menubar = builder.get_object ("menubar") as MenuModel;
+ app.set_app_menu (app_menu);
+ app.set_menubar (menubar);
+
// Cache some objects from the builder.
chart_type_combo = builder.get_object ("chart-type-combo") as Gtk.Widget;
rings_chart = builder.get_object ("rings-chart") as Chart;
@@ -108,12 +119,27 @@ namespace Baobab {
}
}
- void on_refresh_activate () {
+ void on_reload_activate () {
if (scanner != null) {
scan_directory (scanner.directory);
}
}
+ void on_show_toolbar () {
+ }
+
+ void on_show_statusbar () {
+ }
+
+ void on_show_allocated () {
+ }
+
+ void on_expand_all () {
+ }
+
+ void on_collapse_all () {
+ }
+
void on_drag_data_received (Gtk.Widget widget, Gdk.DragContext context, int x, int y,
Gtk.SelectionData selection_data, uint target_type, uint time) {
File dir = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]