2335
2335
LibraryPhoto.global.item_destroyed.connect (on_photo_destroyed);
2336
2336
LibraryPhoto.global.items_altered.connect (on_metadata_altered);
2338
// watch for updates to the external app settings
2339
Config.Facade.get_instance ().external_app_changed.connect (on_external_app_changed);
2341
2338
// Filter out trashed files.
2342
2339
get_view ().install_view_filter (filter);
2343
2340
LibraryPhoto.global.items_unlinking.connect (on_photo_unlinking);
2347
2344
~LibraryPhotoPage () {
2348
2345
LibraryPhoto.global.item_destroyed.disconnect (on_photo_destroyed);
2349
2346
LibraryPhoto.global.items_altered.disconnect (on_metadata_altered);
2350
Config.Facade.get_instance ().external_app_changed.disconnect (on_external_app_changed);
2353
2349
public bool not_trashed_view_filter (DataView view) {
2524
2520
adjust_date_time.label = Resources.ADJUST_DATE_TIME_MENU;
2525
2521
actions += adjust_date_time;
2527
Gtk.ActionEntry external_edit = { "ExternalEdit", Gtk.Stock.EDIT, TRANSLATABLE,
2528
"<Ctrl>Return", TRANSLATABLE, on_external_edit
2530
external_edit.label = Resources.EXTERNAL_EDIT_MENU;
2531
actions += external_edit;
2533
Gtk.ActionEntry edit_raw = { "ExternalEditRAW", null, TRANSLATABLE, "<Ctrl><Shift>Return",
2534
TRANSLATABLE, on_external_edit_raw
2536
edit_raw.label = Resources.EXTERNAL_EDIT_RAW_MENU;
2537
actions += edit_raw;
2539
2523
Gtk.ActionEntry send_to = { "SendTo", "document-send", TRANSLATABLE, null,
2540
2524
TRANSLATABLE, on_send_to
2673
2657
raw_developer.label = _ ("_Developer");
2674
2658
actions += raw_developer;
2660
Gtk.ActionEntry open_with = { "OpenWith", null, TRANSLATABLE, null, null, null };
2661
open_with.label = Resources.OPEN_WITH_MENU;
2662
actions += open_with;
2664
Gtk.ActionEntry open_with_raw = { "OpenWithRaw", null, TRANSLATABLE, null, null, null };
2665
open_with_raw.label = Resources.OPEN_WITH_RAW_MENU;
2666
actions += open_with_raw;
2676
2668
// These are identical to add_tags and send_to, except that they have
2677
2669
// different mnemonics and are _only_ for use in the context menu.
2678
2670
Gtk.ActionEntry send_to_context_menu = { "SendToContextMenu", "document-send", TRANSLATABLE, null,
2764
2756
bool rotate_possible = has_photo () ? is_rotate_available (get_photo ()) : false;
2765
2757
bool is_raw = has_photo () && get_photo ().get_master_file_format () == PhotoFileFormat.RAW;
2767
set_action_sensitive ("ExternalEdit",
2768
has_photo () && Config.Facade.get_instance ().get_external_photo_app () != "");
2759
set_action_sensitive ("OpenWith",
2770
2762
set_action_sensitive ("Revert", has_photo () ?
2771
2763
(get_photo ().has_transformations () || get_photo ().has_editable ()) : false);
2796
2788
update_flag_action ();
2798
set_action_visible ("ExternalEditRAW",
2799
is_raw && Config.Facade.get_instance ().get_external_raw_app () != "");
2790
set_action_visible ("OpenWithRaw",
2801
2793
base.update_actions (selected_count, count);
2961
2953
set_action_sensitive ("Adjust", sensitivity);
2962
2954
set_action_sensitive ("EditTitle", sensitivity);
2963
2955
set_action_sensitive ("AdjustDateTime", sensitivity);
2964
set_action_sensitive ("ExternalEdit", sensitivity);
2965
set_action_sensitive ("ExternalEditRAW", sensitivity);
2956
set_action_sensitive ("OpenWith", sensitivity);
2957
set_action_sensitive ("OpenWithRaw", sensitivity);
2966
2958
set_action_sensitive ("Revert", sensitivity);
2968
2960
set_action_sensitive ("Rate", sensitivity);
3088
3080
private Gtk.Menu get_context_menu () {
3089
3081
Gtk.Menu menu = (Gtk.Menu) ui.get_widget ("/PhotoContextMenu");
3090
3082
assert (menu != null);
3084
Gtk.MenuItem open_with_menu_item = (Gtk.MenuItem) ui.get_widget ("/PhotoContextMenu/OpenWith");
3085
populate_external_app_menu ((Gtk.Menu)open_with_menu_item.get_submenu (), false);
3086
open_with_menu_item.show ();
3088
if (has_photo () && get_photo ().get_master_file_format () == PhotoFileFormat.RAW) {
3089
Gtk.MenuItem open_with_raw_menu_item = (Gtk.MenuItem) ui.get_widget ("/PhotoContextMenu/OpenWithRaw");
3090
populate_external_app_menu ((Gtk.Menu)open_with_raw_menu_item.get_submenu (), true);
3091
open_with_raw_menu_item.show ();
3108
private void populate_external_app_menu (Gtk.Menu menu, bool raw) {
3109
Gtk.MenuItem parent = menu.get_attach_widget () as Gtk.MenuItem;
3110
SortedList<AppInfo> external_apps;
3111
string[] mime_types;
3113
// get list of all applications for the given mime types
3115
mime_types = PhotoFileFormat.RAW.get_mime_types ();
3117
mime_types = PhotoFileFormat.get_editable_mime_types ();
3118
assert (mime_types.length != 0);
3119
external_apps = DesktopIntegration.get_apps_for_mime_types (mime_types);
3121
if (external_apps.size == 0) {
3122
parent.sensitive = false;
3126
foreach (Gtk.Widget item in menu.get_children ())
3128
parent.sensitive = true;
3130
foreach (AppInfo app in external_apps) {
3131
Gtk.ImageMenuItem item_app = new Gtk.ImageMenuItem.with_label (app.get_name ());
3132
Gtk.Image image = new Gtk.Image.from_gicon (app.get_icon (), Gtk.IconSize.MENU);
3133
item_app.always_show_image = true;
3134
item_app.set_image (image);
3135
item_app.activate.connect ( () => {
3137
on_open_with_raw (app.get_commandline ());
3139
on_open_with (app.get_commandline ());
3141
menu.add (item_app);
3146
private void on_open_with (string app) {
3151
AppWindow.get_instance ().set_busy_cursor ();
3152
get_photo ().open_with_external_editor (app);
3153
AppWindow.get_instance ().set_normal_cursor ();
3154
} catch (Error err) {
3155
AppWindow.get_instance ().set_normal_cursor ();
3156
open_external_editor_error_dialog (err, get_photo ());
3160
private void on_open_with_raw (string app) {
3164
if (get_photo ().get_master_file_format () != PhotoFileFormat.RAW)
3168
AppWindow.get_instance ().set_busy_cursor ();
3169
get_photo ().open_with_raw_external_editor (app);
3170
AppWindow.get_instance ().set_normal_cursor ();
3171
} catch (Error err) {
3172
AppWindow.get_instance ().set_normal_cursor ();
3173
AppWindow.error_message (Resources.launch_editor_failed (err));
3106
3177
private void return_to_collection () {
3107
3178
// Return to the previous page if it exists.
3108
3179
if (null != return_page)
3195
private void on_external_app_changed () {
3196
set_action_sensitive ("ExternalEdit", has_photo () &&
3197
Config.Facade.get_instance ().get_external_photo_app () != "");
3200
private void on_external_edit () {
3205
AppWindow.get_instance ().set_busy_cursor ();
3206
get_photo ().open_with_external_editor ();
3207
AppWindow.get_instance ().set_normal_cursor ();
3208
} catch (Error err) {
3209
AppWindow.get_instance ().set_normal_cursor ();
3210
open_external_editor_error_dialog (err, get_photo ());
3215
private void on_external_edit_raw () {
3219
if (get_photo ().get_master_file_format () != PhotoFileFormat.RAW)
3223
AppWindow.get_instance ().set_busy_cursor ();
3224
get_photo ().open_with_raw_external_editor ();
3225
AppWindow.get_instance ().set_normal_cursor ();
3226
} catch (Error err) {
3227
AppWindow.get_instance ().set_normal_cursor ();
3228
AppWindow.error_message (Resources.launch_editor_failed (err));
3232
3266
private void on_send_to () {
3233
3267
if (has_photo ())
3234
3268
DesktopIntegration.send_to ((Gee.Collection<Photo>) get_view ().get_selected_sources ());