Skip to content

Commit

Permalink
added keystrokes
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Schneegans committed Jun 24, 2011
1 parent 617f0fb commit 39b4d32
Show file tree
Hide file tree
Showing 28 changed files with 1,821 additions and 302 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pkg_check_modules(X11 REQUIRED x11)
pkg_check_modules(INDICATOR REQUIRED appindicator-0.1)
pkg_check_modules(RSVG REQUIRED librsvg-2.0)
pkg_check_modules(XML REQUIRED libxml-2.0)
pkg_check_modules(XTST REQUIRED xtst)

set(CFLAGS
${GTK_CFLAGS} ${GTK_CFLAGS_OTHER}
Expand All @@ -47,6 +48,7 @@ set(LIBS
${INDICATOR_LIBRARIES}
${RSVG_LIBRARIES}
${XML_LIBRARIES}
${XTST_LIBRARIES}
)
link_libraries(${LIBS})

Expand All @@ -57,6 +59,7 @@ set(LIB_PATHS
${INDICATOR_LIBRARY_DIRS}
${RSVG_LIBRARY_DIRS}
${XML_LIBRARY_DIRS}
${XTST_LIBRARY_DIRS}
)
link_directories(${LIB_PATHS})

Expand All @@ -67,6 +70,7 @@ set(INCLUDE_PATHS
${INDICATOR_INCLUDE_DIRS}
${RSVG_INCLUDE_DIRS}
${XML_INCLUDE_DIRS}
${XTST_INCLUDE_DIRS}
)
include_directories(${INCLUDE_PATHS})

Expand All @@ -93,4 +97,5 @@ message( " GEE_LIBRARIES = ${GEE_LIBRARIES}" )
message( " INDICATOR_LIBRARIES = ${INDICATOR_LIBRARIES}" )
message( " RSVG_LIBRARIES = ${RSVG_LIBRARIES}" )
message( " XML_LIBRARIES = ${XML_LIBRARIES}" )
message( " XTST_LIBRARIES = ${XTST_LIBRARIES}" )
message( "" )
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ this program. If not, see <http://www.gnu.org/licenses/>.

First of all, install all dependancies:

sudo apt-get install libgtk2.0-dev libcairo2-dev libappindicator-dev libgee-dev librsvg2-dev libxml2-dev valac cmake
sudo apt-get install libgtk2.0-dev libcairo2-dev libappindicator-dev libgee-dev librsvg2-dev libxml2-dev libxtst-dev valac cmake

Then build Gnome-Pie:

Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ vala_precompile(
posix
librsvg-2.0
libxml-2.0
xtst
OPTIONS
--vapidir=${CMAKE_SOURCE_DIR}/vapi/
)

add_executable(gnome-pie ${VALA_C})
40 changes: 15 additions & 25 deletions src/action.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,34 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

using GnomePie.Settings;

namespace GnomePie {

public class Action : GLib.Object {
public abstract class Action : GLib.Object {

public Cairo.ImageSurface active_icon {get; private set;}
public Cairo.ImageSurface inactive_icon {get; private set;}
public Color color {get; private set;}
public string name {get; private set;}

private string _command;
private string _icon_name;

public Action(string command, string icon_name) {
_command = command;
_name = icon_name;
public Action(string name, string icon_name) {
_name = name;
_icon_name = icon_name;

int size = (int)(2*setting().theme.slice_radius*setting().theme.max_zoom);
active_icon = IconLoader.load_themed(icon_name, size, true, setting().theme);
inactive_icon = IconLoader.load_themed(icon_name, size, false, setting().theme);
color = new Color.from_icon(active_icon);
reload_icon();

setting().notify["theme"].connect((s, p) => {
size = (int)(2*setting().theme.slice_radius*setting().theme.max_zoom);
active_icon = IconLoader.load_themed(icon_name, size, true, setting().theme);
inactive_icon = IconLoader.load_themed(icon_name, size, false, setting().theme);
color = new Color.from_icon(active_icon);
});
Settings.get.notify["theme"].connect(reload_icon);
Gtk.IconTheme.get_default().changed.connect(reload_icon);
}

public void execute() {
try{
GLib.DesktopAppInfo item = new GLib.DesktopAppInfo(_command);
item.launch (null, new AppLaunchContext());
debug("launched " + _command);
} catch (Error e) {
warning (e.message);
}
public abstract void execute();

private void reload_icon() {
int size = (int)(2*Settings.get.theme.slice_radius*Settings.get.theme.max_zoom);
active_icon = IconLoader.load_themed(_icon_name, size, true, Settings.get.theme);
inactive_icon = IconLoader.load_themed(_icon_name, size, false, Settings.get.theme);
color = new Color.from_icon(active_icon);
}

}
Expand Down
41 changes: 41 additions & 0 deletions src/appAction.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright (c) 2011 by Simon Schneegans
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace GnomePie {

public class AppAction : Action {

private string _command;

public AppAction(string name, string icon_name, string command) {
base(name, icon_name);

_command = command;
}

public override void execute() {

try{
var item = GLib.AppInfo.create_from_commandline(_command, null, GLib.AppInfoCreateFlags.NONE);
item.launch(null, null);
} catch (Error e) {
warning (e.message);
}
}
}

}
7 changes: 3 additions & 4 deletions src/center.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

using GnomePie.Settings;
using GLib.Math;

namespace GnomePie {
Expand All @@ -30,7 +29,7 @@ namespace GnomePie {

public void draw(Cairo.Context ctx, double angle, double distance) {

var layers = setting().theme.center_layers;
var layers = Settings.get.theme.center_layers;

foreach (var layer in layers) {

Expand All @@ -44,7 +43,7 @@ namespace GnomePie {

if (turn_to_mouse) {
double diff = angle-layer.rotation;
double step = max_rotation_speed/setting().refresh_rate;
double step = max_rotation_speed/Settings.get.refresh_rate;

if (fabs(diff) <= step || fabs(diff) >= 2.0*PI - step)
layer.rotation = angle;
Expand All @@ -53,7 +52,7 @@ namespace GnomePie {
else layer.rotation -= step;
}

} else layer.rotation += max_rotation_speed/setting().refresh_rate;
} else layer.rotation += max_rotation_speed/Settings.get.refresh_rate;

layer.rotation = fmod(layer.rotation+2*PI, 2*PI);

Expand Down
59 changes: 31 additions & 28 deletions src/color.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ namespace GnomePie {
a = alpha;
}

public Color.from_gdk(Gdk.Color color) {
Color.from_rgb(
(float)color.red/65535.0f,
(float)color.green/65535.0f,
(float)color.blue/65535.0f
);
}

public Color.from_string(string hex_string) {
Gdk.Color color;
Gdk.Color.parse(hex_string, out color);

r = (float)color.red/65535.0f;
g = (float)color.green/65535.0f;
b = (float)color.blue/65535.0f;
a = 1.0f;
Color.from_gdk(color);
}

// Code from Unity
Expand Down Expand Up @@ -85,8 +89,7 @@ namespace GnomePie {

Color.from_rgb((float)(rtotal/total), (float)(gtotal/total), (float)(btotal/total));

if (s > 0.15f)
s = 0.65f;
if (s > 0.15f) s = 0.65f;

v = 1.0f;
}
Expand Down Expand Up @@ -185,9 +188,9 @@ namespace GnomePie {

private void setHSV(float hue, float saturation, float val) {
if(saturation == 0) {
_r = val;
_g = val;
_b = val;
r = val;
g = val;
b = val;
return;
}
hue = fmodf(hue, 360);
Expand All @@ -197,34 +200,34 @@ namespace GnomePie {

switch(i) {
case 0:
_r = val;
_g = val * (1.0f - saturation * (1.0f - f));
_b = val * (1.0f - saturation);
r = val;
g = val * (1.0f - saturation * (1.0f - f));
b = val * (1.0f - saturation);
break;
case 1:
_r = val * (1.0f - saturation * f);
_g = val;
_b = val * (1.0f - saturation);
r = val * (1.0f - saturation * f);
g = val;
b = val * (1.0f - saturation);
break;
case 2:
_r = val * (1.0f - saturation);
_g = val;
_b = val * (1.0f - saturation * (1.0f - f));
r = val * (1.0f - saturation);
g = val;
b = val * (1.0f - saturation * (1.0f - f));
break;
case 3:
_r = val * (1.0f - saturation);
_g = val * (1.0f - saturation * f);
_b = val;
r = val * (1.0f - saturation);
g = val * (1.0f - saturation * f);
b = val;
break;
case 4:
_r = val * (1.0f - saturation * (1.0f - f));
_g = val * (1.0f - saturation);
_b = val;
r = val * (1.0f - saturation * (1.0f - f));
g = val * (1.0f - saturation);
b = val;
break;
default:
_r = val;
_g = val * (1.0f - saturation);
_b = val * (1.0f - saturation * f);
r = val;
g = val * (1.0f - saturation);
b = val * (1.0f - saturation * f);
break;
}
}
Expand Down
59 changes: 29 additions & 30 deletions src/compositedWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,33 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/

using GnomePie.Settings;
using GLib.Math;

namespace GnomePie {

public abstract class CompositedWindow : Gtk.Window {

public CompositedWindow() {
int size = (int)(fmax(2*setting().theme.radius + 4*setting().theme.slice_radius, 2*setting().theme.center_radius));
int size = (int)(fmax(2*Settings.get.theme.radius + 4*Settings.get.theme.slice_radius, 2*Settings.get.theme.center_radius));

set_title("Gnome-Pie");
set_size_request (size, size);
set_skip_taskbar_hint(true);
set_skip_pager_hint(true);
set_keep_above(true);
set_type_hint(Gdk.WindowTypeHint.SPLASHSCREEN);
set_colormap(screen.get_rgba_colormap());
set_decorated(false);
set_app_paintable(true);
set_resizable(false);
this.set_title("Gnome-Pie");
this.set_size_request (size, size);
this.set_skip_taskbar_hint(true);
this.set_skip_pager_hint(true);
this.set_keep_above(true);
this.set_type_hint(Gdk.WindowTypeHint.SPLASHSCREEN);
this.set_colormap(screen.get_rgba_colormap());
this.set_decorated(false);
this.set_app_paintable(true);
this.set_resizable(false);

setting().notify["open-at-mouse"].connect((s, p) => {
if(setting().open_at_mouse) position = Gtk.WindowPosition.MOUSE;
else position = Gtk.WindowPosition.CENTER;
Settings.get.notify["open-at-mouse"].connect((s, p) => {
if(Settings.get.open_at_mouse) this.set_position(Gtk.WindowPosition.MOUSE);
else this.set_position(Gtk.WindowPosition.CENTER);
});

if(setting().open_at_mouse) position = Gtk.WindowPosition.MOUSE;
else position = Gtk.WindowPosition.CENTER;
if(Settings.get.open_at_mouse) this.set_position(Gtk.WindowPosition.MOUSE);
else this.set_position(Gtk.WindowPosition.CENTER);

add_events(Gdk.EventMask.BUTTON_RELEASE_MASK);

Expand All @@ -51,16 +50,19 @@ namespace GnomePie {
return true;
});

expose_event.connect(draw);
destroy.connect(Gtk.main_quit);
this.expose_event.connect(this.draw);
this.destroy.connect(Gtk.main_quit);
}

protected abstract bool draw(Gtk.Widget da, Gdk.EventExpose event);
protected abstract void mouseReleased(int button, int x, int y);

public override void show() {
base.show();
grab_total_focus();

Timeout.add ((uint)(1000.0/setting().refresh_rate), () => {
queue_draw();
Timeout.add ((uint)(1000.0/Settings.get.refresh_rate), () => {
this.queue_draw();
return visible;
});
}
Expand All @@ -69,16 +71,13 @@ namespace GnomePie {
base.hide();
ungrab_total_focus();
}

protected abstract bool draw(Gtk.Widget da, Gdk.EventExpose event);
protected abstract void mouseReleased(int button, int x, int y);


// Code from Gnome-Do/Synapse
private void grab_total_focus() {
protected void grab_total_focus() {
uint32 timestamp = Gtk.get_current_event_time();
present_with_time(timestamp);
get_window().raise();
get_window().focus(timestamp);
this.present_with_time(timestamp);
this.get_window().raise();
this.get_window().focus(timestamp);

int i = 0;
Timeout.add (100, ()=>{
Expand All @@ -89,7 +88,7 @@ namespace GnomePie {
}

// Code from Gnome-Do/Synapse
private void ungrab_total_focus() {
protected void ungrab_total_focus() {
uint32 time = Gtk.get_current_event_time();
Gdk.pointer_ungrab(time);
Gdk.keyboard_ungrab(time);
Expand Down
Loading

0 comments on commit 39b4d32

Please sign in to comment.