[the-board] [ui] Add link button to Thing
- From: Lucas Rocha <lucasr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [the-board] [ui] Add link button to Thing
- Date: Sun, 5 Dec 2010 20:37:54 +0000 (UTC)
commit 2904137ff7fdb21abd84f8834232b33b86bbb89b
Author: Lucas Rocha <lucasr gnome org>
Date: Sun Dec 5 20:18:37 2010 +0000
[ui] Add link button to Thing
Should be shown when thing has a link url referering to the location
where it was added from. For example: a photo added from browser
extension will hold a link to the web page where it was added from.
data/icons/hicolor/24x24/actions/thing-link.png | Bin 0 -> 823 bytes
data/style/style.css | 5 ++
src/js/ui/thing.js | 50 ++++++++++++++++++++++-
3 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/data/icons/hicolor/24x24/actions/thing-link.png b/data/icons/hicolor/24x24/actions/thing-link.png
new file mode 100644
index 0000000..a70fef8
Binary files /dev/null and b/data/icons/hicolor/24x24/actions/thing-link.png differ
diff --git a/data/style/style.css b/data/style/style.css
index 50086c7..d1317e7 100644
--- a/data/style/style.css
+++ b/data/style/style.css
@@ -55,6 +55,10 @@ TbBox#button-main-box {
background-color: white;
}
+MxButton#thing-link-button {
+ -mx-icon-name: thing-link;
+}
+
MxButton#thing-remove-button {
-mx-icon-name: thing-remove;
}
@@ -63,6 +67,7 @@ MxButton#thing-resize-button {
-mx-icon-name: thing-resize;
}
+MxButton#thing-link-button,
MxButton#thing-resize-button,
MxButton#thing-remove-button {
border-image: none;
diff --git a/src/js/ui/thing.js b/src/js/ui/thing.js
index 13bbe18..b80d64b 100644
--- a/src/js/ui/thing.js
+++ b/src/js/ui/thing.js
@@ -5,6 +5,7 @@ const Tweener = imports.tweener.tweener;
// gi imports
const Clutter = imports.gi.Clutter;
+const GIO = imports.gi.Gio;
const GObject = imports.gi.GObject;
const Mx = imports.gi.Mx;
const Tb = imports.gi.Tb;
@@ -64,6 +65,8 @@ Thing.prototype = {
this._canResize = true;
}
+ this._link = null;
+
this._activateOnClick = true;
this._content = null;
@@ -113,12 +116,33 @@ Thing.prototype = {
_createControls : function() {
this._createRemoveButton();
+ this._createLinkButton();
if (this._canResize) {
this._createResizeButton();
}
},
+ _createLinkButton : function() {
+ this._linkButton =
+ new Mx.Button({ visible: false,
+ name: "thing-link-button" });
+
+ this._linkButton.opacity = 0;
+ this._linkButton.anchorX = _SHOW_CONTROLS_LENGTH;
+ this._linkButton.anchorY = _SHOW_CONTROLS_LENGTH;
+
+ this._linkButton.connect("clicked",
+ Lang.bind(this, this._onLinkButtonClicked));
+
+ this._mainBox.append(this._linkButton,
+ Tb.BoxPackFlags.FIXED);
+
+ this._mainBox.set_fixed_child_align(this._linkButton,
+ Tb.BoxAlignment.START,
+ Tb.BoxAlignment.START);
+ },
+
_createRemoveButton : function() {
this._removeButton =
new Mx.Button({ visible: false,
@@ -217,6 +241,7 @@ Thing.prototype = {
Tb.BoxPackFlags.EXPAND);
this._removeButton.raise(this._content.contentActor);
+ this._linkButton.raise(this._content.contentActor);
if (this._canResize) {
this._resizeButton.raise(this._content.contentActor);
@@ -262,6 +287,18 @@ Thing.prototype = {
this.leave();
},
+ _onLinkButtonClicked : function() {
+ if (!this._link) {
+ return;
+ }
+
+ try {
+ GIO.app_info_launch_default_for_uri(this._link, null);
+ } catch (e) {
+ // FIXME: Need a way to show UI errors
+ }
+ },
+
_onRemoveButtonClicked : function() {
this.emit("remove");
},
@@ -307,6 +344,10 @@ Thing.prototype = {
showControls : function() {
let actorsToShow = [this._removeButton];
+ if (this._link) {
+ actorsToShow.push(this._linkButton);
+ }
+
if (this._canResize) {
actorsToShow.push(this._resizeButton);
}
@@ -321,7 +362,8 @@ Thing.prototype = {
},
hideControls : function() {
- let actorsToHide = [this._removeButton];
+ let actorsToHide = [this._linkButton,
+ this._removeButton];
if (this._canResize) {
actorsToHide.push(this._resizeButton);
@@ -347,6 +389,8 @@ Thing.prototype = {
true /* from state */);
}
+ this._link = state.link || null;
+
this.loadState(state);
},
@@ -361,6 +405,10 @@ Thing.prototype = {
state.width = this._mainBox.width;
state.height = this._mainBox.height;
+ if (this._link) {
+ state.link = this._link;
+ }
+
return state;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]