Created
May 23, 2013 15:42
-
-
Save oluc/5637023 to your computer and use it in GitHub Desktop.
patch for Analog Clock v7 GNOME3 extension, from https://github.com/l300lvl/analog-clock-gnome-shell-extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Analog_Clock@l300lvl.co.nr/extension.js b/Analog_Clock@l300lvl.co.nr/extension.js | |
index 61c45a1..2747453 100644 | |
--- a/Analog_Clock@l300lvl.co.nr/extension.js | |
+++ b/Analog_Clock@l300lvl.co.nr/extension.js | |
@@ -1,18 +1,18 @@ | |
-const Lang = imports.lang; | |
+const Lang = imports.lang; | |
const Mainloop = imports.mainloop; | |
-const Cairo = imports.cairo; | |
-const Clutter = imports.gi.Clutter; | |
-const St = imports.gi.St; | |
-const Gettext = imports.gettext.domain('analog-clock'); | |
-const _ = Gettext.gettext; | |
- | |
-const Config = imports.misc.config; | |
-const Main = imports.ui.main; | |
-const DateMenu = imports.ui.dateMenu; | |
+const Cairo = imports.cairo; | |
+const Clutter = imports.gi.Clutter; | |
+const St = imports.gi.St; | |
+const Gettext = imports.gettext.domain('analog-clock'); | |
+const _ = Gettext.gettext; | |
+ | |
+const Config = imports.misc.config; | |
+const Main = imports.ui.main; | |
+const DateMenu = imports.ui.dateMenu; | |
const PanelMenu = imports.ui.panelMenu; | |
const PopupMenu = imports.ui.popupMenu; | |
-const Calendar = imports.ui.calendar; | |
+const Calendar = imports.ui.calendar; | |
//let dummyActor; | |
@@ -23,10 +23,11 @@ function Clock () { | |
Clock.prototype = { | |
_init: function() { | |
this.values = []; | |
- this.values.push({color: "-clock-color", values: []}); | |
- this.values.push({color: "-hours-color", values: []}); | |
- this.values.push({color: "-mins-color", values: []}); | |
- this.values.push({color: "-secs-color", values: []}); | |
+ this.values.push({color: "-clock-color", values: []}); /* 0 */ | |
+ this.values.push({color: "-hours-color", values: []}); /* 1 */ | |
+ this.values.push({color: "-mins-color", values: []}); /* 2 */ | |
+ this.values.push({color: "-secs-color", values: []}); /* 3 */ | |
+ | |
this.now = new Date(); | |
this.actor = new St.DrawingArea({style_class: 'clock-area', reactive: true}); | |
@@ -47,54 +48,66 @@ Clock.prototype = { | |
let themeNode = this.actor.get_theme_node(); | |
let cr = area.get_context(); | |
+ // Clock diameter cut: | |
+ // ,----------------- : center o | |
+ // [##|## o ##|##] : border #### | |
+ // \ `-----------------`--------- : radius |..| | |
+ // `----------------------`------ : drawing area [..] | |
+ let border_size = 2; //FIXME: get from CSS | |
+ let radius = (height - border_size) / 2; | |
+ | |
//draw clock | |
let color = themeNode.get_color(this.values[0].color); | |
Clutter.cairo_set_source_color(cr, color); | |
- cr.translate(Math.floor(width/2), Math.floor(height/2)); | |
+ cr.translate(height/2, radius + border_size/2); | |
cr.save(); | |
- cr.arc(0,0, Math.floor(height/2) - 2, 0, 7); | |
- cr.setLineWidth(2.3); | |
+ cr.arc(0,0, radius, 0, 6.3); // 6.3 == 2*pi + epsilon == full circle and a little bit more. | |
+ cr.setLineWidth(border_size); // was cr.setLineWidth(2.3); | |
cr.stroke(); | |
//hour hand | |
color = themeNode.get_color(this.values[1].color); | |
Clutter.cairo_set_source_color(cr, color); | |
- cr.setLineWidth(2.4); | |
+ cr.setLineWidth(1.0); | |
cr.rotate( (hour + sec/3600 + min/60) * Math.PI/6 + Math.PI); | |
cr.moveTo(0,0); | |
- cr.lineTo(0, Math.floor(height/2)-3); | |
+ cr.lineTo(0, radius - border_size/2 - 2); // == not quite touching the clock frame | |
cr.stroke(); | |
+ //FIXME: add cr.save(); ? as the others ? | |
cr.restore(); | |
// minute hand | |
color = themeNode.get_color(this.values[2].color); | |
Clutter.cairo_set_source_color(cr, color); | |
- cr.setLineWidth(2.1); | |
+ cr.setLineWidth(1.5); | |
- cr.rotate( (min+sec/60) * Math.PI/30 + Math.PI); | |
+ cr.rotate( (min + sec/60) * Math.PI/30 + Math.PI); | |
cr.moveTo(0,0); | |
- cr.lineTo(0, Math.floor(height/2)-1); | |
+ cr.lineTo(0, radius - border_size/2); // == touching the clock frame | |
cr.stroke(); | |
cr.save(); | |
cr.restore(); | |
// second hand | |
+ // --> just a spot on the clock frame | |
+ //FIXME: get from CSS ( positive = lenght, zero = no sec hand, -1 = just a spot) | |
color = themeNode.get_color(this.values[3].color); | |
Clutter.cairo_set_source_color(cr, color); | |
- cr.setLineWidth(1.8); | |
+ cr.setLineWidth(border_size); // was cr.setLineWidth(1.8); | |
- // cr.rotate( (sec/60) * Math.PI/30 + Math.PI); | |
+ // cr.rotate( (sec/60) * Math.PI/30 + Math.PI); | |
cr.rotate( (360/60) * (sec+45) * (3.141593/180)) | |
- // cr.rotate( ( 45 + sec + msec / 1000000.0 ) * 3.141593 / 30 ) | |
- cr.moveTo(0,0); | |
- cr.lineTo(0, Math.floor(height/2)-1.5); | |
+ // cr.rotate( ( 45 + sec + msec / 1000000.0 ) * 3.141593 / 30 ) | |
+ | |
+ cr.moveTo(0, radius - border_size/2); // was (0,0), but we want just a spot on the clock frame | |
+ cr.lineTo(0, radius + border_size/2); // until the other side of the border | |
cr.stroke(); | |
cr.save(); | |
diff --git a/Analog_Clock@l300lvl.co.nr/stylesheet.css b/Analog_Clock@l300lvl.co.nr/stylesheet.css | |
index 204ad02..e3e4cfe 100644 | |
--- a/Analog_Clock@l300lvl.co.nr/stylesheet.css | |
+++ b/Analog_Clock@l300lvl.co.nr/stylesheet.css | |
@@ -1,21 +1,21 @@ | |
.clock-status-icon { | |
- padding: 0px; | |
- border: 0px; | |
+ padding : 0px; | |
+ border : 0px; | |
border-radius: 0px; | |
background-color: rgba(0, 0, 0, 0.0); | |
} | |
.clock-area{ | |
- height: 1.6em; | |
- width: 1.7em; | |
- padding: 0px; | |
- border: 0px; | |
- border-radius: 0px; | |
- -clock-color: #4D4DFF; | |
- -hours-color: #fe0001; | |
- -mins-color: #ff4105; | |
- -secs-color: #6fff00; | |
- background-color: rgba(0, 0, 0, 0.0); | |
+ height : 1.6em; | |
+ width : 1.7em; | |
+ padding : 0 30px 0 30px; | |
+ border : 0.0px; | |
+ border-radius : 0px; | |
+ -clock-color : #555; /* same as top bar icons, disabled */ | |
+ -hours-color : #CCC; /* same as top bar icons, enabled */ | |
+ -mins-color : #CCC; | |
+ -secs-color : rgba(255, 255, 255, 0.2); | |
+ background-color : rgba(255, 255, 255, 0.0); | |
} | |
/* Neon Green: 6FFF00 Neon Pink: FF00FF Neon Yellow: FFFF00 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment