initial config window, prepare for notes support
* split ControlBar class into its own file * add ConfigWindow class * add HPaned with Textview for the Notes * update TODOmaster
parent
7cdbd0cf4e
commit
bf3201b5cd
11
TODO
11
TODO
|
@ -1,10 +1,3 @@
|
||||||
* Configuration Window
|
* Working Configuration Window
|
||||||
- Fullscreen Option for Control Window [checkbutton]
|
* Add Support for Notes
|
||||||
- Auto Transition [checkbutton]
|
|
||||||
- Monitor Selection Control [combobox]
|
|
||||||
- Monitor Selection Presentation [combobox]
|
|
||||||
- Keybindings
|
|
||||||
* Add Notes Mode
|
|
||||||
* Add Slide Overview Mode
|
|
||||||
* Use Monitor Class
|
* Use Monitor Class
|
||||||
* Improved Build System
|
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* pdf-presenter - advanced pdf presentation util
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Sebastian Reichel <sre@ring0.de>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
class ConfigWindow : Dialog {
|
||||||
|
Gtk.CheckButton fullscreen_control_window;
|
||||||
|
Gtk.CheckButton auto_transition;
|
||||||
|
|
||||||
|
public ConfigWindow() {
|
||||||
|
title = "PDF Presentator (Config)";
|
||||||
|
position = WindowPosition.CENTER;
|
||||||
|
|
||||||
|
var table = new Gtk.Table(1,4,false);
|
||||||
|
vbox.pack_start(table, false, true, 10);
|
||||||
|
|
||||||
|
fullscreen_control_window = new Gtk.CheckButton.with_label("Fullscreen Configuration Window");
|
||||||
|
table.attach(fullscreen_control_window, 0, 2, 0, 1, Gtk.AttachOptions.FILL, 0, 0, 0);
|
||||||
|
|
||||||
|
auto_transition = new Gtk.CheckButton.with_label("Auto Transition");
|
||||||
|
table.attach(auto_transition, 0, 2, 1, 2, Gtk.AttachOptions.FILL, 0, 0, 0);
|
||||||
|
|
||||||
|
table.attach(new Gtk.Label("Control Monitor"), 0, 1, 2, 3, Gtk.AttachOptions.FILL, 0, 0, 0);
|
||||||
|
table.attach(new Gtk.ComboBox(), 1, 2, 2, 3, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
table.attach(new Gtk.Label("Presentation Monitor"), 0, 1, 3, 4, Gtk.AttachOptions.FILL, 0, 0, 0);
|
||||||
|
table.attach(new Gtk.ComboBox(), 1, 2, 3, 4, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
// FIXME: add keybindings
|
||||||
|
|
||||||
|
add_button(STOCK_OK, ResponseType.OK);
|
||||||
|
add_button(STOCK_CANCEL, ResponseType.CANCEL);
|
||||||
|
|
||||||
|
response.connect(response_handler);
|
||||||
|
show_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void response_handler(int id) {
|
||||||
|
if(id == ResponseType.OK) {
|
||||||
|
message("SAVE...");
|
||||||
|
message("Fullscreen: %s", fullscreen_control_window.get_active() ? "true" : "false");
|
||||||
|
message("Transition: %s", auto_transition.get_active() ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
/*
|
||||||
|
* pdf-presenter - advanced pdf presentation util
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Sebastian Reichel <sre@ring0.de>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
class ControlToolbar : Toolbar {
|
||||||
|
private ToolButton prev;
|
||||||
|
private Entry entry;
|
||||||
|
private ToolButton next;
|
||||||
|
private Label curr_time;
|
||||||
|
private Label pres_time;
|
||||||
|
private ToolButton config;
|
||||||
|
|
||||||
|
private int page = 1;
|
||||||
|
private int pages = 0;
|
||||||
|
|
||||||
|
private int timestamp1 = 0;
|
||||||
|
private int timestamp2 = 0;
|
||||||
|
|
||||||
|
public signal void clicked(string button);
|
||||||
|
public signal void page_changed(int page);
|
||||||
|
|
||||||
|
public ControlToolbar(int n_pages) {
|
||||||
|
/* Toolbar Configuration */
|
||||||
|
set_show_arrow(false);
|
||||||
|
|
||||||
|
pages = n_pages;
|
||||||
|
|
||||||
|
/* Init Toolbar Elements */
|
||||||
|
prev = new ToolButton.from_stock(STOCK_GO_BACK);
|
||||||
|
entry = new Entry();
|
||||||
|
entry.set_width_chars(3);
|
||||||
|
next = new ToolButton.from_stock(STOCK_GO_FORWARD);
|
||||||
|
config = new ToolButton.from_stock(STOCK_PREFERENCES);
|
||||||
|
curr_time = new Label("Time");
|
||||||
|
pres_time = new Label("Duration");
|
||||||
|
pres_time.set_markup("<b>Duration</b>");
|
||||||
|
|
||||||
|
var separator1 = new SeparatorToolItem();
|
||||||
|
var separator2 = new SeparatorToolItem();
|
||||||
|
|
||||||
|
var entry_container = new ToolItem();
|
||||||
|
entry_container.add(entry);
|
||||||
|
|
||||||
|
var vbox_container = new ToolItem();
|
||||||
|
var vbox = new VBox(false, 0);
|
||||||
|
vbox.add(curr_time);
|
||||||
|
vbox.add(pres_time);
|
||||||
|
vbox_container.add(vbox);
|
||||||
|
|
||||||
|
/* Fill Toolbar */
|
||||||
|
add(prev);
|
||||||
|
add(entry_container);
|
||||||
|
add(next);
|
||||||
|
add(separator1);
|
||||||
|
add(vbox_container);
|
||||||
|
add(separator2);
|
||||||
|
add(config);
|
||||||
|
|
||||||
|
update_toolbar();
|
||||||
|
|
||||||
|
/* we don't want focus on a button */
|
||||||
|
entry.grab_focus();
|
||||||
|
|
||||||
|
/* update clock */
|
||||||
|
Timeout.add_seconds(1,update_time);
|
||||||
|
timestamp2 = (int) time_t();
|
||||||
|
update_time();
|
||||||
|
|
||||||
|
/* bind button signals */
|
||||||
|
next.clicked.connect(() => {clicked("next");});
|
||||||
|
prev.clicked.connect(() => {clicked("previous");});
|
||||||
|
config.clicked.connect(() => {clicked("config");});
|
||||||
|
|
||||||
|
this.clicked.connect(button_handler);
|
||||||
|
entry.key_press_event.connect(entry_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool entry_handler(Gdk.EventKey event) {
|
||||||
|
if(event.keyval == Gdk.keyval_from_name("Return")) {
|
||||||
|
int new_page = entry.get_text().to_int();
|
||||||
|
if(page < 1) page = 1;
|
||||||
|
if(page > pages) page = pages;
|
||||||
|
set_page(new_page);
|
||||||
|
page_changed(new_page-1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(event.keyval < '0' || event.keyval > '9' && event.keyval != Gdk.keyval_from_name("BackSpace")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void button_handler(string btn) {
|
||||||
|
if(btn == "next")
|
||||||
|
set_page(page+1);
|
||||||
|
if(btn == "previous")
|
||||||
|
set_page(page-1);
|
||||||
|
|
||||||
|
page_changed(page-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
string int2time(int timestamp, bool local=false) {
|
||||||
|
Time t;
|
||||||
|
|
||||||
|
if(local)
|
||||||
|
t = Time.local((time_t) timestamp);
|
||||||
|
else
|
||||||
|
t = Time.gm((time_t) timestamp);
|
||||||
|
|
||||||
|
return "%02d:%02d:%02d".printf(t.hour, t.minute, t.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool update_time() {
|
||||||
|
timestamp1++;
|
||||||
|
timestamp2++;
|
||||||
|
|
||||||
|
pres_time.set_markup("<b>"+int2time(timestamp1)+"</b>");
|
||||||
|
curr_time.set_text(int2time(timestamp2,true));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_toolbar() {
|
||||||
|
if(page <= 1) prev.set_sensitive(false);
|
||||||
|
else prev.set_sensitive(true);
|
||||||
|
|
||||||
|
if(page >= pages) next.set_sensitive(false);
|
||||||
|
else next.set_sensitive(true);
|
||||||
|
|
||||||
|
entry.set_text("%d".printf(page));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set_page(int n) {
|
||||||
|
page = n;
|
||||||
|
update_toolbar();
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,148 +25,6 @@
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using Cairo;
|
using Cairo;
|
||||||
|
|
||||||
class ControlToolbar : Toolbar {
|
|
||||||
private ToolButton prev;
|
|
||||||
private Entry entry;
|
|
||||||
private ToolButton next;
|
|
||||||
private ToolButton notes;
|
|
||||||
private ToolButton slides;
|
|
||||||
private Label curr_time;
|
|
||||||
private Label pres_time;
|
|
||||||
private ToolButton config;
|
|
||||||
|
|
||||||
private int page = 1;
|
|
||||||
private int pages = 0;
|
|
||||||
|
|
||||||
private int timestamp1 = 0;
|
|
||||||
private int timestamp2 = 0;
|
|
||||||
|
|
||||||
public signal void clicked(string button);
|
|
||||||
public signal void page_changed(int page);
|
|
||||||
|
|
||||||
public ControlToolbar(int n_pages) {
|
|
||||||
/* Toolbar Configuration */
|
|
||||||
set_show_arrow(false);
|
|
||||||
|
|
||||||
pages = n_pages;
|
|
||||||
|
|
||||||
/* Init Toolbar Elements */
|
|
||||||
prev = new ToolButton.from_stock(STOCK_GO_BACK);
|
|
||||||
entry = new Entry();
|
|
||||||
entry.set_width_chars(3);
|
|
||||||
next = new ToolButton.from_stock(STOCK_GO_FORWARD);
|
|
||||||
notes = new ToolButton.from_stock(STOCK_FILE);
|
|
||||||
notes.set_label("Notes");
|
|
||||||
slides = new ToolButton.from_stock(STOCK_DIALOG_INFO);
|
|
||||||
slides.set_label("Slides");
|
|
||||||
config = new ToolButton.from_stock(STOCK_PREFERENCES);
|
|
||||||
curr_time = new Label("Time");
|
|
||||||
pres_time = new Label("Duration");
|
|
||||||
pres_time.set_markup("<b>Duration</b>");
|
|
||||||
|
|
||||||
var separator1 = new SeparatorToolItem();
|
|
||||||
var separator2 = new SeparatorToolItem();
|
|
||||||
|
|
||||||
var entry_container = new ToolItem();
|
|
||||||
entry_container.add(entry);
|
|
||||||
|
|
||||||
var vbox_container = new ToolItem();
|
|
||||||
var vbox = new VBox(false, 0);
|
|
||||||
vbox.add(curr_time);
|
|
||||||
vbox.add(pres_time);
|
|
||||||
vbox_container.add(vbox);
|
|
||||||
|
|
||||||
/* Fill Toolbar */
|
|
||||||
add(prev);
|
|
||||||
add(entry_container);
|
|
||||||
add(next);
|
|
||||||
add(notes);
|
|
||||||
add(slides);
|
|
||||||
add(separator1);
|
|
||||||
add(vbox_container);
|
|
||||||
add(separator2);
|
|
||||||
add(config);
|
|
||||||
|
|
||||||
update_toolbar();
|
|
||||||
|
|
||||||
/* we don't want focus on a button */
|
|
||||||
entry.grab_focus();
|
|
||||||
|
|
||||||
/* update clock */
|
|
||||||
Timeout.add_seconds(1,update_time);
|
|
||||||
timestamp2 = (int) time_t();
|
|
||||||
update_time();
|
|
||||||
|
|
||||||
/* bind button signals */
|
|
||||||
next.clicked.connect(() => {clicked("next");});
|
|
||||||
prev.clicked.connect(() => {clicked("previous");});
|
|
||||||
config.clicked.connect(() => {clicked("config");});
|
|
||||||
|
|
||||||
this.clicked.connect(button_handler);
|
|
||||||
entry.key_press_event.connect(entry_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool entry_handler(Gdk.EventKey event) {
|
|
||||||
if(event.keyval == Gdk.keyval_from_name("Return")) {
|
|
||||||
int new_page = entry.get_text().to_int();
|
|
||||||
if(page < 1) page = 1;
|
|
||||||
if(page > pages) page = pages;
|
|
||||||
set_page(new_page);
|
|
||||||
page_changed(new_page-1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(event.keyval < '0' || event.keyval > '9' && event.keyval != Gdk.keyval_from_name("BackSpace")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void button_handler(string btn) {
|
|
||||||
if(btn == "next")
|
|
||||||
set_page(page+1);
|
|
||||||
if(btn == "previous")
|
|
||||||
set_page(page-1);
|
|
||||||
|
|
||||||
page_changed(page-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
string int2time(int timestamp, bool local=false) {
|
|
||||||
Time t;
|
|
||||||
|
|
||||||
if(local)
|
|
||||||
t = Time.local((time_t) timestamp);
|
|
||||||
else
|
|
||||||
t = Time.gm((time_t) timestamp);
|
|
||||||
|
|
||||||
return "%02d:%02d:%02d".printf(t.hour, t.minute, t.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool update_time() {
|
|
||||||
timestamp1++;
|
|
||||||
timestamp2++;
|
|
||||||
|
|
||||||
pres_time.set_markup("<b>"+int2time(timestamp1)+"</b>");
|
|
||||||
curr_time.set_text(int2time(timestamp2,true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update_toolbar() {
|
|
||||||
if(page <= 1) prev.set_sensitive(false);
|
|
||||||
else prev.set_sensitive(true);
|
|
||||||
|
|
||||||
if(page >= pages) next.set_sensitive(false);
|
|
||||||
else next.set_sensitive(true);
|
|
||||||
|
|
||||||
entry.set_text("%d".printf(page));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set_page(int n) {
|
|
||||||
page = n;
|
|
||||||
update_toolbar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ControlView : DrawingArea {
|
class ControlView : DrawingArea {
|
||||||
Poppler.Document document;
|
Poppler.Document document;
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
@ -212,7 +70,10 @@ class ControlView : DrawingArea {
|
||||||
width = (int) width2;
|
width = (int) width2;
|
||||||
height = (int) height2;
|
height = (int) height2;
|
||||||
|
|
||||||
get_parent_window().get_size(out window_w, out window_h);
|
Gtk.Allocation rect = Gtk.Allocation();
|
||||||
|
get_allocation(rect);
|
||||||
|
window_w = rect.width;
|
||||||
|
window_h = rect.height;
|
||||||
|
|
||||||
double wf = (window_w * 11/20) / width2;
|
double wf = (window_w * 11/20) / width2;
|
||||||
double hf = (window_h * 7/10) / height2;
|
double hf = (window_h * 7/10) / height2;
|
||||||
|
@ -237,7 +98,11 @@ class ControlView : DrawingArea {
|
||||||
int y = y_diff + 25; // 25px below of the last item
|
int y = y_diff + 25; // 25px below of the last item
|
||||||
int w,h;
|
int w,h;
|
||||||
|
|
||||||
get_parent_window().get_size(out w, out h);
|
Gtk.Allocation rect = Gtk.Allocation();
|
||||||
|
get_allocation(rect);
|
||||||
|
w = rect.width;
|
||||||
|
h = rect.height;
|
||||||
|
|
||||||
w -= x + 25; // 25px from the right window border
|
w -= x + 25; // 25px from the right window border
|
||||||
|
|
||||||
if((n > page && n < pages) || (n < page && n >= 0)) {
|
if((n > page && n < pages) || (n < page && n >= 0)) {
|
||||||
|
@ -305,18 +170,21 @@ class ControlView : DrawingArea {
|
||||||
|
|
||||||
class ControlWindow : Window {
|
class ControlWindow : Window {
|
||||||
public void button_clicked(string btn) {
|
public void button_clicked(string btn) {
|
||||||
if(btn != "next" && btn != "previous")
|
if(btn == "config")
|
||||||
|
new ConfigWindow();
|
||||||
|
else if(btn != "next" && btn != "previous")
|
||||||
message("%s clicked!", btn);
|
message("%s clicked!", btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public signal void page_changed(int page);
|
public signal void page_changed(int page);
|
||||||
|
|
||||||
public ControlWindow(Poppler.Document document) {
|
public ControlWindow(Poppler.Document document) {
|
||||||
this.title = "PDF Presentator (Control)";
|
title = "PDF Presentator (Control)";
|
||||||
this.position = WindowPosition.CENTER;
|
position = WindowPosition.CENTER;
|
||||||
this.destroy.connect(Gtk.main_quit);
|
destroy.connect(Gtk.main_quit);
|
||||||
set_default_size(800, 600);
|
set_default_size(800, 600);
|
||||||
var vbox = new VBox(false, 0);
|
var vbox = new VBox(false, 0);
|
||||||
|
var hpaned = new HPaned();
|
||||||
|
|
||||||
var drawingarea = new ControlView(document);
|
var drawingarea = new ControlView(document);
|
||||||
|
|
||||||
|
@ -324,7 +192,10 @@ class ControlWindow : Window {
|
||||||
var toolbar = new ControlToolbar(document.get_n_pages());
|
var toolbar = new ControlToolbar(document.get_n_pages());
|
||||||
aspect.add(toolbar);
|
aspect.add(toolbar);
|
||||||
|
|
||||||
vbox.pack_start(drawingarea, true, true, 0);
|
hpaned.pack1(drawingarea, true, false);
|
||||||
|
hpaned.pack2(new TextView(), false, true);
|
||||||
|
|
||||||
|
vbox.pack_start(hpaned, true, true, 0);
|
||||||
vbox.pack_start(aspect, false, true, 0);
|
vbox.pack_start(aspect, false, true, 0);
|
||||||
|
|
||||||
add(vbox);
|
add(vbox);
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(string[] args) {
|
int main(string[] args) {
|
||||||
/* FIXME: use first parameter */
|
|
||||||
string filename;
|
string filename;
|
||||||
Poppler.Document document = null;
|
Poppler.Document document = null;
|
||||||
Gtk.init(ref args);
|
Gtk.init(ref args);
|
||||||
|
|
Loading…
Reference in New Issue