[sushi] utils: consolidate code for creating toolbar buttons
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] utils: consolidate code for creating toolbar buttons
- Date: Wed, 13 Jul 2011 15:08:08 +0000 (UTC)
commit 2e8bf272e2436fab33b585e643c1ad34b75f4355
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Jul 13 11:07:48 2011 -0400
utils: consolidate code for creating toolbar buttons
src/js/ui/utils.js | 51 +++++++++++++++++++++++++--------------------------
1 files changed, 25 insertions(+), 26 deletions(-)
---
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 78e9a8c..e89f73c 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -100,36 +100,35 @@ function getStaticSize(renderer, widget) {
return [ width, height ];
}
+function createToolButton(iconName, callback) {
+ let button = new Gtk.ToolButton({ expand: false,
+ "icon-name": iconName });
+ button.show();
+ button.connect("clicked", callback);
+
+ return button;
+}
+
function createFullScreenButton(mainWindow) {
- let toolbarZoom = new Gtk.ToolButton({ expand: false,
- "icon-name": "view-fullscreen-symbolic" });
- toolbarZoom.show();
- toolbarZoom.connect("clicked",
- function () {
- mainWindow.toggleFullScreen();
- });
-
- return toolbarZoom;
+ return createToolButton("view-fullscreen-symbolic", Lang.bind(this, function() {
+ mainWindow.toggleFullScreen();
+ }));
}
function createOpenButton(file, mainWindow) {
- let toolbarOpen = new Gtk.ToolButton({ expand: false,
- "icon-name": "document-open-symbolic" });
- toolbarOpen.show();
- toolbarOpen.connect("clicked",
- function () {
- let timestamp = Gtk.get_current_event_time();
- try {
- Gtk.show_uri(toolbarRun.get_screen(),
- file.get_uri(),
- timestamp);
-
- mainWindow.close();
- } catch (e) {
- }
- });
-
- return toolbarOpen;
+ return createToolButton("document-open-symbolic", Lang.bind(this, function(widget) {
+ let timestamp = Gtk.get_current_event_time();
+ try {
+ Gtk.show_uri(widget.get_screen(),
+ file.get_uri(),
+ timestamp);
+
+ mainWindow.close();
+ } catch (e) {
+ log('Unable to execute the default application for ' +
+ file.get_uri() + ' : ' + e.toString());
+ }
+ }));
}
function formatTimeString(timeVal) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]