diff --git a/data/org.stronnag.wayfarer.gschema.xml b/data/org.stronnag.wayfarer.gschema.xml
index d8c1646..ce70d85 100644
--- a/data/org.stronnag.wayfarer.gschema.xml
+++ b/data/org.stronnag.wayfarer.gschema.xml
@@ -40,5 +40,10 @@
false
Use notifications to stop recording
+
+
+ true
+ Show a hint message on area selection
+
diff --git a/data/wayfarer.blp b/data/wayfarer.blp
index 820bbe0..1f600e5 100644
--- a/data/wayfarer.blp
+++ b/data/wayfarer.blp
@@ -256,6 +256,15 @@ Gtk.Box prefsstuff {
halign: fill;
}
}
+ Gtk.Box {
+ spacing: 4;
+ orientation: horizontal;
+ [start]
+ Gtk.CheckButton prefs_hint {
+ label: "Show area selection hint";
+ halign: fill;
+ }
+ }
}
/*
diff --git a/src/selection.vala b/src/selection.vala
index 78b2a9d..74a9c5f 100644
--- a/src/selection.vala
+++ b/src/selection.vala
@@ -4,10 +4,12 @@ public class AreaWindow : Gtk.Window {
private const int BLOB_RADIUS=20;
private const int LINE_RELAX=4;
private const float LINE_WIDTH=2.0f;
+ private const string ENDTEXT = "Save the area :\n - Press Enter or Space, or\n - Click Button 2 or Button 3\nQuit : Press ESCape";
private enum DrawMode {
- NONE,
- RECT,
+ NONE = 0,
+ RECT = 1,
+ TEXT = 2,
}
private enum DragMode {
@@ -54,17 +56,22 @@ public class AreaWindow : Gtk.Window {
private Gdk.RGBA fill;
private Gdk.RGBA stroke;
private Gdk.RGBA bfill;
+ private Gdk.RGBA dfill;
public signal void area_set(int x0, int y0, int x1, int y1);
public signal void area_quit();
- bool ingrab = false;
+ private bool show_hint;
+ private bool ingrab = false;
private DrawMode drawmode;
private DragMode dragmode;
- public AreaWindow() {
+ public AreaWindow(bool _show_hint) {
+ show_hint = _show_hint;
fill = Gdk.RGBA(){red = 1.0f, green = 1.0f, blue = 1.0f, alpha= 0.2f};
stroke = Gdk.RGBA(){red = 1.0f, green = 1.0f, blue = 1.0f, alpha = 0.5f};
bfill = Gdk.RGBA(){red = 1.0f, green = 1.0f, blue = 1.0f, alpha = 0.8f};
+ dfill = Gdk.RGBA(){red = 0.0f, green = 0.0f, blue = 0.0f, alpha= 0.5f};
+
title = "Wayfarer";
drawmode = DrawMode.NONE;
dragmode = DragMode.FREE;
@@ -135,6 +142,8 @@ public class AreaWindow : Gtk.Window {
if (dragmode == DragMode.GRAB) {
dragmode = set_cursor_mode(absx, absy);
}
+ drawmode = DrawMode.TEXT;
+ queue_draw();
});
gestd.drag_update.connect((x,y) => {
@@ -257,25 +266,64 @@ public class AreaWindow : Gtk.Window {
snap.pop();
}
+ private void show_message(Gtk.Snapshot snap) {
+ var width = ((endx-spx)*9)/10;
+ var height = ((endy - spy)*9)/10;
+ var font = new Pango.FontDescription();
+ font.set_family("Sans");
+ var fsize = 20 * Pango.SCALE;
+ var context = this.get_pango_context();
+ var layout = new Pango.Layout(context);
+ font.set_size(fsize);
+ layout.set_font_description(font);
+ layout.set_text(ENDTEXT, -1);
+ int lwidth;
+ int lheight;
+ layout.get_pixel_size(out lwidth, out lheight);
+ var fw = fsize * width / lwidth;
+ var fh = fsize * height / lheight ;
+ fsize = (fw < fh) ? fw : fh;
+ font.set_size(fsize);
+ layout.set_font_description(font);
+ layout.set_text(ENDTEXT, -1);
+ layout.get_pixel_size(out lwidth, out lheight);
+ var point = Graphene.Point();
+ point.x = spx + (endx-spx)/20;
+ var bh = (endy- spy);
+ point.y = spy + (endy-spy)/20 + (bh-lheight)/2;
+ snap.save();
+ snap.translate(point);
+ snap.append_layout(layout, bfill);
+ snap.restore();
+ }
+
public override void snapshot (Gtk.Snapshot snap) {
- if (drawmode == DrawMode.RECT) {
+ if (drawmode == DrawMode.NONE) {
+ var rect = Graphene.Rect.zero();
+ snap.append_color(bfill, rect);
+ } else {
float[] lwidths = {LINE_WIDTH, LINE_WIDTH, LINE_WIDTH, LINE_WIDTH};
Gdk.RGBA[] lcols = {stroke, stroke, stroke, stroke};
-
var rect = Graphene.Rect.zero();
var rrect = Gsk.RoundedRect(){};
rect.init(spx, spy, endx-spx, endy-spy);
rrect.init_from_rect(rect, 0.0f);
- snap.append_color(fill, rect);
+ if (drawmode == DrawMode.TEXT) {
+ snap.append_color(dfill, rect);
+ } else {
+ snap.append_color(fill, rect);
+ }
snap.append_border(rrect, lwidths, lcols);
add_corner(snap, spx, spy);
add_corner(snap, endx, spy);
add_corner(snap, endx, endy);
add_corner(snap, spx, endy);
- } else {
- var rect = Graphene.Rect.zero();
- snap.append_color(bfill, rect);
- }
+ if (drawmode == DrawMode.TEXT) {
+ if(show_hint) {
+ show_message(snap);
+ }
+ }
+ }
}
private void set_bg() {
diff --git a/src/settings.vala b/src/settings.vala
index daff3c8..158c283 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -1,15 +1,17 @@
[Compact]
public class Conf : Object {
public string audio_device { get; set; }
- public string video_dir { get; set; }
- public string media_type { get; set; }
- public string restore_token { get; set; }
+ public string video_dir { get; set; }
+ public string media_type { get; set; }
+ public string restore_token { get; set; }
- public uint32 audio_rate { get; set; }
- public uint32 frame_rate { get; set; }
+ public uint32 audio_rate { get; set; }
+ public uint32 frame_rate { get; set; }
- public bool notify_start { get; set; }
- public bool notify_stop { get; set; }
+ public bool notify_start { get; set; }
+ public bool notify_stop { get; set; }
+
+ public bool show_hint { get; set; }
private Settings s;
@@ -24,5 +26,6 @@ public class Conf : Object {
s.bind("frame-rate", this, "frame-rate", SettingsBindFlags.DEFAULT);
s.bind("notify-start", this, "notify_start", SettingsBindFlags.DEFAULT);
s.bind("notify-stop", this, "notify_stop", SettingsBindFlags.DEFAULT);
+ s.bind("show-hint", this, "show-hint", SettingsBindFlags.DEFAULT);
}
}
diff --git a/src/wayfarer.vala b/src/wayfarer.vala
index 7cb7343..8b3b233 100644
--- a/src/wayfarer.vala
+++ b/src/wayfarer.vala
@@ -101,6 +101,7 @@ public class Wayfarer : Gtk.Application {
Gtk.Button prefapply = builder.get_object("prefsapply") as Button;
CheckButton prefs_not = builder.get_object("prefs_not") as CheckButton;
CheckButton prefs_notall = builder.get_object("prefs_notall") as CheckButton;
+ CheckButton prefs_hint = builder.get_object("prefs_hint") as CheckButton;
Gtk.Entry prefs_audiorate = builder.get_object("prefs_audiorate") as Entry;
mediasel = builder.get_object("media_sel") as ComboBoxText;
@@ -193,6 +194,7 @@ public class Wayfarer : Gtk.Application {
prefapply.clicked.connect(() => {
conf.notify_start = prefs_not.active;
conf.notify_stop = prefs_notall.active;
+ conf.show_hint = prefs_hint.active;
conf.audio_rate = int.parse(prefs_audiorate.text);
prefs.hide();
});
@@ -331,6 +333,7 @@ public class Wayfarer : Gtk.Application {
prefs_not.active = conf.notify_start;
prefs_notall.active = conf.notify_stop;
+ prefs_hint.active = conf.show_hint;
audiosource.changed.connect(() => {
conf.audio_device = audiosource.active_id;
@@ -482,7 +485,7 @@ public class Wayfarer : Gtk.Application {
if(ctrlseta) {
window.hide();
}
- sw = new AreaWindow ();
+ sw = new AreaWindow (conf.show_hint);
sw.area_set.connect((x0, y0, x1, y1) => {
var swh = sw.get_allocated_height();
var offset = sources[0].height - swh;