Commit 67e41c54 authored by Jim Nelson's avatar Jim Nelson

#191: Accelerators for fullscreen view. Crop button (but no implementation!) added.

parent 912a935b
......@@ -2,13 +2,35 @@
public class FullscreenWindow : Gtk.Window {
public static const int TOOLBAR_DISMISSAL_MSEC = 2500;
private const Gtk.ActionEntry[] ACTIONS = {
{ "LeaveFullscreen", Gtk.STOCK_LEAVE_FULLSCREEN, "Leave _Fullscreen", "Escape", "Leave fullscreen", on_close }
};
private Gtk.Window toolbar_window = new Gtk.Window(Gtk.WindowType.POPUP);
private Gtk.UIManager ui = new Gtk.UIManager();
private PhotoPage photo_page = new PhotoPage();
private Gtk.ToolButton close_button = new Gtk.ToolButton.from_stock(Gtk.STOCK_CLOSE);
private Gtk.ToolButton close_button = new Gtk.ToolButton.from_stock(Gtk.STOCK_LEAVE_FULLSCREEN);
private Gtk.ToggleToolButton pin_button = new Gtk.ToggleToolButton();
private bool is_toolbar_shown = false;
public FullscreenWindow(Gdk.Screen screen, CheckerboardPage controller, Thumbnail start) {
File ui_file = AppWindow.get_ui_dir().get_child("fullscreen.ui");
try {
ui.add_ui_from_file(ui_file.get_path());
} catch (Error err) {
error("Error loading UI file %s: %s", ui_file.get_path(), err.message);
}
Gtk.ActionGroup action_group = new Gtk.ActionGroup("FullscreenActionGroup");
action_group.add_actions(ACTIONS, this);
ui.insert_action_group(action_group, 0);
ui.ensure_update();
Gtk.AccelGroup accel_group = ui.get_accel_group();
if (accel_group != null)
add_accel_group(accel_group);
set_screen(screen);
set_border_width(0);
......@@ -187,6 +209,17 @@ public class AppWindow : Gtk.Window {
return subdir;
}
public static File get_ui_dir() {
// TODO: Programatically determine where runtime data is stored from API calls ...
// for now, this uses the installed data if running from /usr, otherwise looks for
// them in the executable's folder
if (AppWindow.get_exec_dir().get_path().has_prefix("/usr")) {
return File.new_for_path("/usr/local/share/shotwell");
} else {
return AppWindow.get_exec_dir();
}
}
// this needs to be ref'd the lifetime of the application
private Hal.Context halContext = new Hal.Context();
private DBus.Connection halConn = null;
......
......@@ -29,7 +29,8 @@ VAPI_FILES = \
RESOURCE_FILES = \
photo.ui \
collection.ui \
import.ui
import.ui \
fullscreen.ui
HEADER_FILES = \
gphoto.h
......
......@@ -26,7 +26,6 @@ public abstract class Page : Gtk.ScrolledWindow {
public static const Gdk.Color BG_COLOR = parse_color("#777");
private static Gtk.IconFactory factory = null;
private static File data_dir = null;
private static void addStockIcon(File file, string stockID) {
debug("Adding icon %s", file.get_path());
......@@ -48,16 +47,7 @@ public abstract class Page : Gtk.ScrolledWindow {
factory = new Gtk.IconFactory();
// TODO: Programatically determine where runtime data is stored from API calls ...
// for now, this uses the installed data if running from /usr, otherwise looks for
// them in the executable's folder
if (AppWindow.get_exec_dir().get_path().has_prefix("/usr")) {
data_dir = File.new_for_path("/usr/local/share/shotwell");
} else {
data_dir = AppWindow.get_exec_dir();
}
File icons_dir = data_dir.get_child("icons");
File icons_dir = AppWindow.get_ui_dir().get_child("icons");
addStockIcon(icons_dir.get_child("object-rotate-right.svg"), STOCK_CLOCKWISE);
addStockIcon(icons_dir.get_child("object-rotate-left.svg"), STOCK_COUNTERCLOCKWISE);
......@@ -122,7 +112,7 @@ public abstract class Page : Gtk.ScrolledWindow {
}
protected void init_load_ui(string ui_filename) {
File ui_file = data_dir.get_child(ui_filename);
File ui_file = AppWindow.get_ui_dir().get_child(ui_filename);
try {
ui.add_ui_from_file(ui_file.get_path());
......
......@@ -6,6 +6,7 @@ public class PhotoPage : Page {
private Gtk.Viewport viewport = new Gtk.Viewport(null, null);
private Gtk.Toolbar toolbar = new Gtk.Toolbar();
private Gtk.ToolButton rotateButton = null;
private Gtk.ToggleToolButton crop_button = null;
private Gtk.ToolButton prevButton = new Gtk.ToolButton.from_stock(Gtk.STOCK_GO_BACK);
private Gtk.ToolButton nextButton = new Gtk.ToolButton.from_stock(Gtk.STOCK_GO_FORWARD);
private Gtk.Image image = new Gtk.Image();
......@@ -46,6 +47,12 @@ public class PhotoPage : Page {
rotateButton.clicked += on_rotate_clockwise;
toolbar.insert(rotateButton, -1);
// crop tool
crop_button = new Gtk.ToggleToolButton();
crop_button.set_label("Crop");
crop_button.toggled += on_crop_toggled;
toolbar.insert(crop_button, -1);
// separator to force next/prev buttons to right side of toolbar
Gtk.SeparatorToolItem separator = new Gtk.SeparatorToolItem();
separator.set_expand(true);
......@@ -217,6 +224,9 @@ public class PhotoPage : Page {
return false;
}
private void on_crop_toggled() {
}
private void on_next_photo() {
this.thumbnail = (Thumbnail) controller.get_next_item(thumbnail);
update_display();
......
<ui>
<accelerator name="LeaveFullscreen" action="LeaveFullscreen" />
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment