[sushi] text: add a toolbar with an edit action



commit cc0006dcb3d2cd9d8ab47d8c8418343522cc65a3
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Jul 2 00:44:28 2011 -0400

    text: add a toolbar with an edit action

 src/js/ui/utils.js     |   25 ++++++++++++++++++++++++-
 src/js/viewers/text.js |   15 +++++++++++++++
 2 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 37db45f..7b6e0be 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -85,7 +85,7 @@ function createFullScreenButton(mainWindow) {
     return toolbarZoom;
 }
 
-function createRunButton(file) {
+function createRunButton(file, mainWindow) {
     let toolbarRun = new Gtk.ToolButton({ expand: false,
                                           "icon-name": "system-run-symbolic" });
     toolbarRun.show();
@@ -96,6 +96,29 @@ function createRunButton(file) {
                                Gtk.show_uri(toolbarRun.get_screen(),
                                             file.get_uri(),
                                             timestamp);
+
+                               mainWindow.close();
+                           } catch (e) {
+                           }
+                       });
+
+    return toolbarRun;
+}
+
+function createEditButton(file, mainWindow) {
+    // FIXME: needs better icon
+    let toolbarRun = new Gtk.ToolButton({ expand: false,
+                                          "icon-name": "edit-cut-symbolic" });
+    toolbarRun.show();
+    toolbarRun.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) {
                            }
                        });
diff --git a/src/js/viewers/text.js b/src/js/viewers/text.js
index 7584460..3932081 100644
--- a/src/js/viewers/text.js
+++ b/src/js/viewers/text.js
@@ -68,6 +68,21 @@ TextRenderer.prototype = {
 
     getSizeForAllocation : function(allocation) {
         return allocation;
+    },
+
+    createToolbar : function() {
+        this._mainToolbar = new Gtk.Toolbar({ "icon-size": Gtk.IconSize.MENU });
+        this._mainToolbar.get_style_context().add_class("np-toolbar");
+        this._mainToolbar.set_show_arrow(false);
+
+        this._toolbarRun = Utils.createEditButton(this._file, this._mainWindow);
+        this._mainToolbar.insert(this._toolbarRun, 0);
+
+        this._mainToolbar.show();
+
+        this._toolbarActor = Utils.forcedSizeActor(this._mainToolbar);
+
+        return this._toolbarActor;
     }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]