main_window.c 159 KB
Newer Older
Stephan Arts's avatar
Stephan Arts committed
1
/*
Stephan Arts's avatar
Stephan Arts committed
2
 *  Copyright (c) Stephan Arts 2006-2012 <stephan@xfce.org>
Stephan Arts's avatar
Stephan Arts committed
3
 *
Stephan Arts's avatar
Stephan Arts committed
4 5 6 7 8
 *  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 2
 *  of the License, or (at your option) any later version.
 * 
Stephan Arts's avatar
Stephan Arts committed
9 10 11
 *  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
Stephan Arts's avatar
Stephan Arts committed
12 13
 *  GNU General Public License for more details.
 * 
Stephan Arts's avatar
Stephan Arts committed
14
 *  You should have received a copy of the GNU General Public License
Stephan Arts's avatar
Stephan Arts committed
15 16 17 18
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 *  02110-1301, USA.
 */
Stephan Arts's avatar
Stephan Arts committed
19 20

#include <config.h>
Stephan Arts's avatar
Stephan Arts committed
21
#include <gdk/gdkkeysyms.h>
Stephan Arts's avatar
Stephan Arts committed
22 23 24 25
#include <X11/Xlib.h>
#include <string.h>

#include <gio/gio.h>
26
#include <gio/gdesktopappinfo.h>
Stephan Arts's avatar
Stephan Arts committed
27

28
#include <libxfce4ui/libxfce4ui.h>
Stephan Arts's avatar
Stephan Arts committed
29 30
#include <libexif/exif-data.h>

Stephan Arts's avatar
Stephan Arts committed
31 32
#include <cairo/cairo.h>

Stephan Arts's avatar
Stephan Arts committed
33
#include "settings.h"
34
#include "mime_db.h"
Stephan Arts's avatar
Stephan Arts committed
35
#include "util.h"
Stephan Arts's avatar
Stephan Arts committed
36
#include "file.h"
Stephan Arts's avatar
Stephan Arts committed
37
#include "icon_bar.h"
38
#include "thumbnailer.h"
39
#include "image_viewer.h"
Stephan Arts's avatar
Stephan Arts committed
40 41
#include "main_window.h"
#include "main_window_ui.h"
42
#include "wallpaper_manager.h"
43

44
#include "xfce_wallpaper_manager.h"
45
#include "gnome_wallpaper_manager.h"
Stephan Arts's avatar
Stephan Arts committed
46

Stephan Arts's avatar
Stephan Arts committed
47
#include "privacy_dialog.h"
48
#include "properties_dialog.h"
Stephan Arts's avatar
Stephan Arts committed
49
#include "preferences_dialog.h"
50
#include "app_menu_item.h"
Stephan Arts's avatar
Stephan Arts committed
51 52

#ifndef RISTRETTO_APP_TITLE
Stephan Arts's avatar
Stephan Arts committed
53
#define RISTRETTO_APP_TITLE _("Image Viewer")
Stephan Arts's avatar
Stephan Arts committed
54 55
#endif

Stephan Arts's avatar
Stephan Arts committed
56
#define RISTRETTO_DESKTOP_ID "ristretto.desktop"
57

58 59 60
#define RSTTO_RECENT_FILES_APP_NAME "ristretto"
#define RSTTO_RECENT_FILES_GROUP "Graphics"

61 62 63 64 65 66 67 68 69 70 71
enum
{
    EDITOR_CHOOSER_MODEL_COLUMN_NAME = 0,
    EDITOR_CHOOSER_MODEL_COLUMN_PIXBUF,
    EDITOR_CHOOSER_MODEL_COLUMN_APPLICATION,
    EDITOR_CHOOSER_MODEL_COLUMN_STYLE,
    EDITOR_CHOOSER_MODEL_COLUMN_STYLE_SET,
    EDITOR_CHOOSER_MODEL_COLUMN_WEIGHT,
    EDITOR_CHOOSER_MODEL_COLUMN_WEIGHT_SET
};

Stephan Arts's avatar
Stephan Arts committed
72

Stephan Arts's avatar
Stephan Arts committed
73 74
struct _RsttoMainWindowPriv
{
75
    RsttoImageList        *image_list;
Stephan Arts's avatar
Stephan Arts committed
76

77
    RsttoMimeDB           *db;
78

Eric Koegel's avatar
Eric Koegel committed
79
    GDBusProxy            *filemanager_proxy;
80 81

    guint                  show_fs_toolbar_timeout_id;
Igor's avatar
Igor committed
82
    guint                  hide_fs_mouse_cursor_timeout_id;
83
    gint                   window_save_geometry_timer_id;
Igor's avatar
Igor committed
84

85
    gboolean               fs_toolbar_sticky;
Stephan Arts's avatar
Stephan Arts committed
86

87
    RsttoImageListIter    *iter;
Stephan Arts's avatar
Stephan Arts committed
88

89 90 91 92
    GtkActionGroup        *action_group;
    GtkUIManager          *ui_manager;
    GtkRecentManager      *recent_manager;
    RsttoSettings         *settings_manager;
93
    RsttoWallpaperManager *wallpaper_manager;
94
    RsttoThumbnailer      *thumbnailer;
Stephan Arts's avatar
Stephan Arts committed
95

96 97 98 99 100 101 102 103
    GtkWidget             *menubar;
    GtkWidget             *toolbar;
    GtkWidget             *warning;
    GtkWidget             *warning_label;
    GtkWidget             *image_viewer_menu;
    GtkWidget             *position_menu;
    GtkWidget             *image_viewer;
    GtkWidget             *p_viewer_s_window;
Igor's avatar
Igor committed
104
    GtkWidget             *grid;
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
    GtkWidget             *t_bar_s_window;
    GtkWidget             *thumbnailbar;
    GtkWidget             *statusbar;
    guint                  statusbar_context_id;

    GtkWidget             *back;
    GtkWidget             *forward;

    guint                  t_open_merge_id;
    guint                  recent_merge_id;
    guint                  play_merge_id;
    guint                  pause_merge_id;
    guint                  toolbar_play_merge_id;
    guint                  toolbar_pause_merge_id;
    guint                  toolbar_fullscreen_merge_id;
    guint                  toolbar_unfullscreen_merge_id;

    GtkAction             *play_action;
    GtkAction             *pause_action;
    GtkAction             *recent_action;

    gboolean               playing;
    gint                   play_timeout_id;

    GtkFileFilter         *filter;
130 131

    gchar                 *last_copy_folder_uri;
Stephan Arts's avatar
Stephan Arts committed
132 133 134 135 136
};

enum
{
    PROP_0,
137
    PROP_IMAGE_LIST,
Stephan Arts's avatar
Stephan Arts committed
138 139 140 141 142 143 144 145
};

static void
rstto_main_window_init (RsttoMainWindow *);
static void
rstto_main_window_class_init(RsttoMainWindowClass *);
static void
rstto_main_window_dispose(GObject *object);
Stephan Arts's avatar
Stephan Arts committed
146

147 148 149
static void
rstto_main_window_size_allocate (GtkWidget *, GtkAllocation *);

Stephan Arts's avatar
Stephan Arts committed
150

Stephan Arts's avatar
Stephan Arts committed
151 152 153 154
static gboolean
key_press_event (
        GtkWidget *widget,
        GdkEventKey *event);
Stephan Arts's avatar
Stephan Arts committed
155

Stephan Arts's avatar
Stephan Arts committed
156 157 158 159
static void
cb_icon_bar_selection_changed (
        RsttoIconBar *icon_bar,
        gpointer user_data);
160 161 162 163
static gint
cb_compare_app_infos (
        gconstpointer a,
        gconstpointer b);
164 165 166 167 168
static void
cb_rstto_thumbnailer_ready(
        RsttoThumbnailer *thumbnailer,
        RsttoFile *file,
        gpointer user_data);
Stephan Arts's avatar
Stephan Arts committed
169

Stephan Arts's avatar
Stephan Arts committed
170
static gboolean
Igor's avatar
Igor committed
171 172 173
rstto_main_window_save_geometry_timer (gpointer user_data);
static void
rstto_main_window_save_geometry_timer_destroy (gpointer user_data);
Stephan Arts's avatar
Stephan Arts committed
174

175 176 177
static void
rstto_main_window_image_list_iter_changed (RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
178 179 180 181
static void
rstto_main_window_launch_editor_chooser (
        RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
182 183
static gboolean
cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *event);
Igor's avatar
Igor committed
184
static gboolean
Stephan Arts's avatar
Stephan Arts committed
185
cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data);
186 187
static gboolean
cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
188
static void
Igor's avatar
Igor committed
189
cb_rstto_main_window_show_fs_toolbar_timeout_destroy (gpointer user_data);
190
static gboolean
Igor's avatar
Igor committed
191
cb_rstto_main_window_hide_fs_mouse_cursor_timeout (RsttoMainWindow *window);
192
static void
Igor's avatar
Igor committed
193
cb_rstto_main_window_hide_fs_mouse_cursor_timeout_destroy (gpointer user_data);
Igor's avatar
Igor committed
194
static void
195
cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window);
196 197
static void
rstto_main_window_update_statusbar (RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212

static void
cb_rstto_main_window_zoom_100 (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_zoom_fit (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_zoom_in (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_zoom_out (GtkWidget *widget, RsttoMainWindow *window);

static void
cb_rstto_main_window_rotate_cw (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window);

213 214 215 216 217
static void
cb_rstto_main_window_flip_hz (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_flip_vt (GtkWidget *widget, RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
218 219 220 221 222 223 224 225 226
static void
cb_rstto_main_window_next_image (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_previous_image (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_first_image (GtkWidget *widget, RsttoMainWindow *window);
static void
cb_rstto_main_window_last_image (GtkWidget *widget, RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
227 228 229
static void
cb_rstto_main_window_open_with_other_app (GtkWidget *widget, RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
230 231 232
static void
cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window);
static void
Stephan Arts's avatar
Stephan Arts committed
233 234
cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window);
static void
235 236
cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window);
static void
Stephan Arts's avatar
Stephan Arts committed
237 238
cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window);
static void
Stephan Arts's avatar
Stephan Arts committed
239 240
cb_rstto_main_window_edit (GtkWidget *widget, RsttoMainWindow *window);
static void
Stephan Arts's avatar
Stephan Arts committed
241
cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
242 243
static void
cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window);
Eric Koegel's avatar
Eric Koegel committed
244
static void
245 246 247 248
cb_rstto_main_window_refresh (
        GtkWidget *widget,
        RsttoMainWindow *window );
static void
Eric Koegel's avatar
Eric Koegel committed
249
cb_rstto_main_window_dnd_files (GtkWidget *widget, gchar **uris, RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
250

251 252 253
static void
cb_rstto_main_window_set_as_wallpaper (GtkWidget *widget, RsttoMainWindow *window);
static void
254 255
cb_rstto_main_window_sorting_function_changed (GtkRadioAction *action, GtkRadioAction *current,  RsttoMainWindow *window);
static void
256
cb_rstto_main_window_navigationtoolbar_position_changed (GtkRadioAction *, GtkRadioAction *,  RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
257

258
static void
Stephan Arts's avatar
Stephan Arts committed
259 260 261 262 263 264
cb_rstto_main_window_thumbnail_size_changed (
        GtkRadioAction *action,
        GtkRadioAction *current,
        RsttoMainWindow *window);

static gboolean
265
cb_rstto_main_window_navigationtoolbar_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
266 267
static void
cb_rstto_main_window_update_statusbar (GtkWidget *widget, RsttoMainWindow *window);
268

Stephan Arts's avatar
Stephan Arts committed
269
static void
270 271 272
cb_rstto_main_window_play (
        GtkWidget *widget,
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
273
static void
274 275 276
cb_rstto_main_window_pause(
        GtkWidget *widget,
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
277
static gboolean
278 279
cb_rstto_main_window_play_slideshow (
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
280 281

static void
282
cb_rstto_main_window_toggle_show_toolbar (
283 284
        GtkWidget *widget,
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
285
static void
286 287 288
cb_rstto_main_window_toggle_show_thumbnailbar (
        GtkWidget *widget,
        RsttoMainWindow *window);
David Schneider's avatar
David Schneider committed
289 290 291 292
static void
cb_rstto_main_window_toggle_show_statusbar (
        GtkWidget *widget,
        RsttoMainWindow *window);
293

294
static void
295 296 297
cb_rstto_main_window_fullscreen (
        GtkWidget *widget,
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
298
static void
299 300 301 302
cb_rstto_main_window_preferences (
        GtkWidget *widget,
        RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
303
static void
304 305 306 307
cb_rstto_main_window_clear_private_data (
        GtkWidget *widget,
        RsttoMainWindow *window);

308
static void
309 310 311 312
cb_rstto_main_window_about (
        GtkWidget *widget,
        RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
313
static void
314 315 316 317
cb_rstto_main_window_contents (
        GtkWidget *widget,
        RsttoMainWindow *window);

Stephan Arts's avatar
Stephan Arts committed
318
static void
319 320 321
cb_rstto_main_window_quit (
        GtkWidget *widget,
        RsttoMainWindow *window);
Stephan Arts's avatar
Stephan Arts committed
322

323
static gboolean 
324 325 326 327 328
cb_rstto_main_window_motion_notify_event (
        RsttoMainWindow *window,
        GdkEventMotion *event,
        gpointer user_data);

Stephan Arts's avatar
Stephan Arts committed
329
static gboolean
330 331 332 333 334
cb_rstto_main_window_image_viewer_enter_notify_event (
        GtkWidget *widget,
        GdkEventCrossing *event,
        gpointer user_data);

335
static gboolean
336 337 338 339
cb_rstto_main_window_image_viewer_scroll_event (
        GtkWidget *widget,
        GdkEventScroll *event,
        gpointer user_data);
340

Igor's avatar
Igor committed
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
static void
rstto_main_activate_file_menu_actions (
        RsttoMainWindow *window,
        gboolean activate);

static void
rstto_main_activate_go_menu_actions (
        RsttoMainWindow *window,
        gboolean activate);

static void
rstto_main_activate_view_menu_actions (
        RsttoMainWindow *window,
        gboolean activate);

static void
rstto_main_activate_popup_menu_actions (
        RsttoMainWindow *window,
        gboolean activate);

static void
rstto_main_activate_toolbar_actions (
        RsttoMainWindow *window,
        gboolean activate);

Stephan Arts's avatar
Stephan Arts committed
366
static void
367 368 369
rstto_main_window_update_buttons (
        RsttoMainWindow *window);

370
static void
371 372 373
rstto_main_window_set_navigationbar_position (
        RsttoMainWindow *window,
        guint orientation);
Stephan Arts's avatar
Stephan Arts committed
374

Stephan Arts's avatar
Stephan Arts committed
375 376 377 378 379
static void
rstto_main_window_set_thumbnail_size (
        RsttoMainWindow *window,
        RsttoThumbnailSize size);

380 381 382 383 384
static void
cb_rstto_wrap_images_changed (
        GObject *object,
        GParamSpec *pspec,
        gpointer user_data);
Stephan Arts's avatar
Stephan Arts committed
385

386 387 388 389 390
static void
cb_rstto_desktop_type_changed (
        GObject *object,
        GParamSpec *pspec,
        gpointer user_data);
391

392 393


Stephan Arts's avatar
Stephan Arts committed
394 395 396 397 398
static GtkWidgetClass *parent_class = NULL;

static GtkActionEntry action_entries[] =
{
/* File Menu */
Stephan Arts's avatar
Stephan Arts committed
399 400 401
  { "file-menu",
            NULL,
            N_ ("_File"),
Igor's avatar
Igor committed
402 403
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
404 405 406 407 408 409 410 411
            NULL, },
  { "open",
            "document-open", /* Icon-name */
            N_ ("_Open..."), /* Label-text */
            "<control>O", /* Keyboard shortcut */
            N_ ("Open an image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_open_image), },
  { "save-copy",
412
            "document-save-as", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
413 414 415 416 417
            N_ ("_Save copy..."), /* Label-text */
            "<control>s", /* Keyboard shortcut */
            N_ ("Save a copy of the image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_save_copy), },
  { "properties",
418
            "document-properties", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
419 420 421 422 423
            N_ ("_Properties..."), /* Label-text */
            NULL, /* Keyboard shortcut */
            N_ ("Show file properties"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_properties), },
  { "edit",
424
            "gtk-edit", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
425 426 427 428 429
            N_ ("_Edit"), /* Label-text */
            NULL, /* Keyboard shortcut */
            N_ ("Edit this image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_edit), },
  { "close",
430
            "window-close", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
431 432 433 434 435
            N_ ("_Close"), /* Label-text */
            "<control>W", /* Keyboard shortcut */
            N_ ("Close this image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_close), },
  { "quit",
436
            "application-exit", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
437 438 439 440
            N_ ("_Quit"), /* Label-text */
            "<control>Q", /* Keyboard shortcut */
            N_ ("Quit Ristretto"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_quit), },
Stephan Arts's avatar
Stephan Arts committed
441
/* Edit Menu */
Stephan Arts's avatar
Stephan Arts committed
442 443 444
  { "edit-menu",
            NULL,
            N_ ("_Edit"),
Igor's avatar
Igor committed
445 446
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
447 448 449 450
            NULL, },
  { "open-with-menu",
            NULL,
            N_ ("_Open with"),
Igor's avatar
Igor committed
451 452
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
453 454 455
            NULL, },
  { "sorting-menu",
            NULL,
Igor's avatar
Igor committed
456
            N_ ("_Sort by"),
Igor's avatar
Igor committed
457 458
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
459 460
            NULL, },
  { "delete",
461
            "edit-delete", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
462 463 464 465 466
            N_ ("_Delete"), /* Label-text */
            "Delete", /* Keyboard shortcut */
            N_ ("Delete this image from disk"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_delete), },
  { "clear-private-data",
467
            "edit-clear", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
468 469 470 471 472
            N_ ("_Clear private data..."), /* Label-text */
            "<control><shift>Delete", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK(cb_rstto_main_window_clear_private_data), },
  { "preferences",
473
            "preferences-system", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
474 475 476 477
            N_ ("_Preferences..."), /* Label-text */
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_preferences), },
Stephan Arts's avatar
Stephan Arts committed
478
/* View Menu */
Stephan Arts's avatar
Stephan Arts committed
479 480 481
  { "view-menu",
            NULL,
            N_ ("_View"),
Igor's avatar
Igor committed
482 483
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
484 485
            NULL, },
  { "fullscreen",
486
            "view-fullscreen", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
487 488 489 490 491
            N_ ("_Fullscreen"), /* Label-text */
            "F11", /* Keyboard shortcut */
            N_ ("Switch to fullscreen"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_fullscreen), },
  { "unfullscreen",
492
            "view-restore", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
493 494 495 496 497 498
            N_ ("_Leave Fullscreen"), /* Label-text */
            NULL, /* Keyboard shortcut */
            N_ ("Leave Fullscreen"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_fullscreen), },
  { "set-as-wallpaper",
            "preferences-desktop-wallpaper", /* Icon-name */
499
            N_ ("Set as _Wallpaper..."), /* Label-text */
Stephan Arts's avatar
Stephan Arts committed
500 501 502
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_set_as_wallpaper), },
Stephan Arts's avatar
Stephan Arts committed
503
/* Zoom submenu */
Stephan Arts's avatar
Stephan Arts committed
504 505 506
  { "zoom-menu",
            NULL,
            N_ ("_Zoom"),
Igor's avatar
Igor committed
507 508
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
509 510
            NULL, },
  { "zoom-in",
511
            "zoom-in", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
512 513 514 515 516
            N_ ("Zoom _In"), /* Label-text */
            "<control>plus", /* Keyboard shortcut */
            N_ ("Zoom in"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_zoom_in),},
  { "zoom-out",
517
            "zoom-out", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
518 519 520 521 522
            N_ ("Zoom _Out"), /* Label-text */
            "<control>minus", /* Keyboard shortcut */
            N_ ("Zoom out"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_zoom_out), },
  { "zoom-fit",
523
            "zoom-fit-best", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
524 525 526 527 528
            N_ ("Zoom _Fit"), /* Label-text */
            "<control>equal", /* Keyboard shortcut */
            N_ ("Zoom to fit window"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_zoom_fit), },
  { "zoom-100",
529
            "zoom-original", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
530 531 532 533
            N_ ("_Normal Size"), /* Label-text */
            "<control>0", /* Keyboard shortcut */
            N_ ("Zoom to 100%"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_zoom_100), },
Stephan Arts's avatar
Stephan Arts committed
534
/* Rotation submenu */
Stephan Arts's avatar
Stephan Arts committed
535 536 537
  { "rotation-menu",
            NULL,
            N_ ("_Rotation"),
Igor's avatar
Igor committed
538 539
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
540 541 542 543 544 545 546 547 548 549 550 551 552
            NULL, },
  { "rotate-cw",
            "object-rotate-right", /* Icon-name */
            N_ ("Rotate _Right"), /* Label-text */
            "<control>bracketright", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_rotate_cw), },
  { "rotate-ccw",
            "object-rotate-left", /* Icon-name */
            N_ ("Rotate _Left"), /* Label-text */
            "<control>bracketleft", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_rotate_ccw), },
553 554 555 556
/* Flip submenu */
  { "flip-menu",
            NULL,
            N_ ("_Flip"),
Igor's avatar
Igor committed
557 558
            NULL,
            NULL,
559 560 561 562 563 564 565 566 567 568 569 570 571
            NULL, },
  { "flip-horizontally",
            "object-flip-horizontal",
            N_ ("Flip _Horizontally"), /* Label-text */
            "<control>braceright", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_flip_hz), },
  { "flip-vertically",
            "object-flip-vertical",
            N_ ("Flip _Vertically"), /* Label-text */
            "<control>braceleft", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_flip_vt), },
Stephan Arts's avatar
Stephan Arts committed
572
/* Go Menu */
Stephan Arts's avatar
Stephan Arts committed
573 574 575
  { "go-menu",
            NULL,
            N_ ("_Go"),
Igor's avatar
Igor committed
576 577
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
578 579
            NULL, },
  { "forward",
580
            "go-next", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
581 582 583 584 585
            N_ ("_Forward"), /* Label-text */
            "space", /* Keyboard shortcut */
            N_("Next image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_next_image), },
  { "back",
586
            "go-previous", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
587 588 589 590 591
            N_ ("_Back"), /* Label-text */
            "BackSpace", /* Keyboard shortcut */
            N_("Previous image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_previous_image), },
  { "first",
592
            "go-first", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
593 594 595 596 597
            N_ ("F_irst"), /* Label-text */
            "Home", /* Keyboard shortcut */
            N_("First image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_first_image), },
  { "last",
598
            "go-last", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
599 600 601 602
            N_ ("_Last"), /* Label-text */
            "End", /* Keyboard shortcut */
            N_("Last image"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_last_image), },
Stephan Arts's avatar
Stephan Arts committed
603
/* Help Menu */
Stephan Arts's avatar
Stephan Arts committed
604 605 606
  { "help-menu",
            NULL,
            N_ ("_Help"),
Igor's avatar
Igor committed
607 608
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
609 610
            NULL, },
  { "contents",
611
            "help-browser", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
612 613 614 615 616
            N_ ("_Contents"), /* Label-text */
            "F1", /* Keyboard shortcut */
            N_ ("Display ristretto user manual"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_contents), },
  { "about",
617
            "help-about",  /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
618 619 620 621
            N_ ("_About"), /* Label-text */
            NULL, /* Keyboard shortcut */
            N_ ("Display information about ristretto"), /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_about), },
622
/* Position Menu */
Stephan Arts's avatar
Stephan Arts committed
623 624 625
  { "position-menu",
            NULL,
            N_ ("_Position"),
Igor's avatar
Igor committed
626 627
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
628 629 630 631
            NULL, },
  { "size-menu",
            NULL,
            N_ ("_Size"),
Igor's avatar
Igor committed
632 633
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
634 635 636 637
            NULL, },
  { "thumbnailbar-position-menu",
            NULL,
            N_ ("Thumbnail Bar _Position"),
Igor's avatar
Igor committed
638 639
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
640 641 642
            NULL, },
  { "thumbnailbar-size-menu",
            NULL,
643
            N_ ("Thumb_nail Size"),
Igor's avatar
Igor committed
644 645
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
646
            NULL, },
647
/* Misc */
Stephan Arts's avatar
Stephan Arts committed
648
  { "leave-fullscreen",
649
            "view-restore", /* Icon-name */
Stephan Arts's avatar
Stephan Arts committed
650 651 652 653 654
            N_ ("Leave _Fullscreen"), /* Label-text */
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_fullscreen), },
  { "tb-menu",
Igor's avatar
Igor committed
655 656
            NULL,
            NULL,
Stephan Arts's avatar
Stephan Arts committed
657 658 659
            NULL,
            NULL,
            NULL, }
Stephan Arts's avatar
Stephan Arts committed
660 661
};

662
/** Toggle Action Entries */
Stephan Arts's avatar
Stephan Arts committed
663 664
static const GtkToggleActionEntry toggle_action_entries[] =
{
665
    /* Toggle visibility of the main file toolbar */
Stephan Arts's avatar
Stephan Arts committed
666 667 668 669 670 671 672
    { "show-toolbar",
            NULL, /* Icon-name */
            N_ ("_Show Toolbar"), /* Label-text */
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_toggle_show_toolbar),
            TRUE, },
673
    /* Toggle visibility of the main navigation toolbar */
Stephan Arts's avatar
Stephan Arts committed
674 675 676 677 678 679 680
    { "show-thumbnailbar",
            NULL, /* Icon-name */
            N_ ("Show _Thumbnail Bar"), /* Label-text */
            "<control>M", /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_toggle_show_thumbnailbar),
            TRUE, },
David Schneider's avatar
David Schneider committed
681
    /* Toggle visibility of the statusbar*/
Stephan Arts's avatar
Stephan Arts committed
682 683
    { "show-statusbar",
            NULL, /* Icon-name */
684
            N_ ("Show Status _Bar"), /* Label-text */
Stephan Arts's avatar
Stephan Arts committed
685 686 687 688
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            G_CALLBACK (cb_rstto_main_window_toggle_show_statusbar),
            TRUE, },
Stephan Arts's avatar
Stephan Arts committed
689 690
};

691
/** Image sorting options*/
Stephan Arts's avatar
Stephan Arts committed
692 693
static const GtkRadioActionEntry radio_action_sort_entries[] = 
{
Stephan Arts's avatar
Stephan Arts committed
694 695
    {"sort-filename",
            NULL, /* Icon-name */
Igor's avatar
Igor committed
696
            N_("file name"), /* Label-text */
Stephan Arts's avatar
Stephan Arts committed
697 698
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
Igor's avatar
Igor committed
699 700 701
            SORT_TYPE_NAME},
    {"sort-filetype",
            NULL, /* Icon-name */
Igor's avatar
Igor committed
702
            N_("file type"), /* Label-text */
Igor's avatar
Igor committed
703 704 705
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            SORT_TYPE_TYPE},
Stephan Arts's avatar
Stephan Arts committed
706 707
    {"sort-date",
            NULL, /* Icon-name */
Igor's avatar
Igor committed
708
            N_("date"), /* Label-text */
Stephan Arts's avatar
Stephan Arts committed
709 710
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
Igor's avatar
Igor committed
711
            SORT_TYPE_DATE},
Stephan Arts's avatar
Stephan Arts committed
712 713
};

714
/** Navigationbar+Thumbnailbar positioning options*/
715 716
static const GtkRadioActionEntry radio_action_pos_entries[] = 
{
Stephan Arts's avatar
Stephan Arts committed
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
    { "pos-left",
            NULL, /* Icon-name */
            N_("Left"), /* Label-text */
            NULL, /* Keyboard shortcut */
            NULL, /* Tooltip text */
            0},
    { "pos-right",
            NULL,
            N_("Right"),
            NULL,
            NULL,
            1},
    { "pos-top",
            NULL,
            N_("Top"),
            NULL,
            NULL,
            2},
    { "pos-bottom",
            NULL,
            N_("Bottom"),
            NULL,
            NULL,
            3},
741 742
};

Stephan Arts's avatar
Stephan Arts committed
743 744 745
/** Thumbnail-size options*/
static const GtkRadioActionEntry radio_action_size_entries[] = 
{
Stephan Arts's avatar
Stephan Arts committed
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
    { "size-very-small",
            NULL,
            N_("Very Small"),
            NULL,
            NULL,
            0},
    { "size-smaller",
            NULL,
            N_("Smaller"),
            NULL,
            NULL,
            1},
    { "size-small",
            NULL,
            N_("Small"),
            NULL,
            NULL,
            2},
    { "size-normal",
            NULL,
            N_("Normal"),
            NULL,
            NULL,
            3},
    { "size-large",
            NULL,
            N_("Large"),
            NULL,
            NULL,
            4},
    { "size-larger",
            NULL,
            N_("Larger"),
            NULL,
            NULL,
            5},
    { "size-very-large",
            NULL,
            N_("Very Large"),
            NULL,
            NULL,
            6},
Stephan Arts's avatar
Stephan Arts committed
788 789
};

Stephan Arts's avatar
Stephan Arts committed
790 791

GType
Stephan Arts's avatar
Stephan Arts committed
792
rstto_main_window_get_type (void)
Stephan Arts's avatar
Stephan Arts committed
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
{
    static GType rstto_main_window_type = 0;

    if (!rstto_main_window_type)
    {
        static const GTypeInfo rstto_main_window_info = 
        {
            sizeof (RsttoMainWindowClass),
            (GBaseInitFunc) NULL,
            (GBaseFinalizeFunc) NULL,
            (GClassInitFunc) rstto_main_window_class_init,
            (GClassFinalizeFunc) NULL,
            NULL,
            sizeof (RsttoMainWindow),
            0,
            (GInstanceInitFunc) rstto_main_window_init,
            NULL
        };

        rstto_main_window_type = g_type_register_static (GTK_TYPE_WINDOW, "RsttoMainWindow", &rstto_main_window_info, 0);
Stephan Arts's avatar
Stephan Arts committed
813

Stephan Arts's avatar
Stephan Arts committed
814
    }
Stephan Arts's avatar
Stephan Arts committed
815 816 817



Stephan Arts's avatar
Stephan Arts committed
818 819 820 821 822 823
    return rstto_main_window_type;
}

static void
rstto_main_window_init (RsttoMainWindow *window)
{
Stephan Arts's avatar
Stephan Arts committed
824
    GtkAccelGroup   *accel_group;
825
    GtkWidget       *separator;
Igor's avatar
Igor committed
826
    GtkWidget       *main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
Stephan Arts's avatar
Stephan Arts committed
827
    GtkRecentFilter *recent_filter;
828
    guint            window_width, window_height;
Stephan Arts's avatar
Stephan Arts committed
829
    gchar           *desktop_type = NULL;
Stephan Arts's avatar
Stephan Arts committed
830
    GtkWidget       *info_bar_content_area;
Stephan Arts's avatar
Stephan Arts committed
831

832
    GClosure        *toggle_fullscreen_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_fullscreen, window, NULL);
Stephan Arts's avatar
Stephan Arts committed
833 834 835
    GClosure        *leave_fullscreen_closure = g_cclosure_new_swap ((GCallback)gtk_window_unfullscreen, window, NULL);
    GClosure        *next_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_next_image, window, NULL);
    GClosure        *previous_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_previous_image, window, NULL);
836
    GClosure        *quit_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_quit, window, NULL);
837
    GClosure        *delete_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_delete, window, NULL);
838
    GClosure        *refresh_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_refresh, window, NULL);
Stephan Arts's avatar
Stephan Arts committed
839

840
    guint navigationbar_position = 3;
Stephan Arts's avatar
Stephan Arts committed
841
    guint thumbnail_size = 3;
842
    gchar *db_path = NULL;
843

Stephan Arts's avatar
Stephan Arts committed
844 845
    gtk_window_set_title (GTK_WINDOW (window), RISTRETTO_APP_TITLE);

846
    window->priv = g_new0 (RsttoMainWindowPriv, 1);
847

848
    db_path = xfce_resource_save_location (XFCE_RESOURCE_DATA, "ristretto/mime.db", TRUE);
849 850
    if (db_path != NULL)
    {
851
        window->priv->db = rstto_mime_db_new (db_path, NULL);
852
    }
Stephan Arts's avatar
Stephan Arts committed
853 854 855

    window->priv->iter = NULL;

856
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Stephan Arts's avatar
Stephan Arts committed
857
    window->priv->ui_manager = gtk_ui_manager_new ();
858 859 860 861
G_GNUC_END_IGNORE_DEPRECATIONS
    window->priv->recent_manager = gtk_recent_manager_get_default ();
    window->priv->settings_manager = rstto_settings_new ();
    window->priv->thumbnailer = rstto_thumbnailer_new ();
Stephan Arts's avatar
Stephan Arts committed
862

863 864
    window->priv->last_copy_folder_uri = NULL;

Eric Koegel's avatar
Eric Koegel committed
865 866 867 868
    /* Setup the image filter list for drag and drop */
    window->priv->filter = gtk_file_filter_new ();
    g_object_ref_sink (window->priv->filter);
    gtk_file_filter_add_pixbuf_formats (window->priv->filter);
Igor's avatar
Igor committed
869 870
    /* see https://bugs.launchpad.net/ubuntu/+source/ristretto/+bug/1778695 */
    gtk_file_filter_add_mime_type (window->priv->filter, "image/x-canon-cr2");
Eric Koegel's avatar
Eric Koegel committed
871

872 873
    /* D-Bus stuff */

Eric Koegel's avatar
Eric Koegel committed
874 875 876 877 878 879 880 881 882
    window->priv->filemanager_proxy =
            g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                           G_DBUS_PROXY_FLAGS_NONE,
                                           NULL,
                                           "org.xfce.FileManager",
                                           "/org/xfce/FileManager",
                                           "org.xfce.FileManager",
                                           NULL,
                                           NULL);
883

Stephan Arts's avatar
Stephan Arts committed
884 885 886
    desktop_type = rstto_settings_get_string_property (window->priv->settings_manager, "desktop-type");
    if (desktop_type)
    {
887
        if (!g_ascii_strcasecmp (desktop_type, "xfce"))
Stephan Arts's avatar
Stephan Arts committed
888 889 890 891
        {
            window->priv->wallpaper_manager = rstto_xfce_wallpaper_manager_new();
        }

892
        if (!g_ascii_strcasecmp (desktop_type, "gnome"))
Stephan Arts's avatar
Stephan Arts committed
893
        {
894
            window->priv->wallpaper_manager = rstto_gnome_wallpaper_manager_new();
Stephan Arts's avatar
Stephan Arts committed
895 896
        }

897
        if (!g_ascii_strcasecmp (desktop_type, "none"))
898 899 900 901
        {
            window->priv->wallpaper_manager = NULL;
        }

Stephan Arts's avatar
Stephan Arts committed
902 903 904
        g_free (desktop_type);
        desktop_type = NULL;
    }
905 906 907
    else
    {
        /* Default to xfce */
908
        window->priv->wallpaper_manager = rstto_xfce_wallpaper_manager_new ();
909
    }
Stephan Arts's avatar
Stephan Arts committed
910 911


Stephan Arts's avatar
Stephan Arts committed
912
    navigationbar_position = rstto_settings_get_navbar_position (window->priv->settings_manager);
Stephan Arts's avatar
Stephan Arts committed
913
    thumbnail_size = rstto_settings_get_uint_property (window->priv->settings_manager, "thumbnail-size");
Stephan Arts's avatar
Stephan Arts committed
914

915
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Stephan Arts's avatar
Stephan Arts committed
916
    accel_group = gtk_ui_manager_get_accel_group (window->priv->ui_manager);
917
G_GNUC_END_IGNORE_DEPRECATIONS
Stephan Arts's avatar
Stephan Arts committed
918 919
    gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);

920
    gtk_accel_group_connect_by_path (accel_group, "<Window>/fullscreen", toggle_fullscreen_closure);
Stephan Arts's avatar
Stephan Arts committed
921 922 923
    gtk_accel_group_connect_by_path (accel_group, "<Window>/unfullscreen", leave_fullscreen_closure);
    gtk_accel_group_connect_by_path (accel_group, "<Window>/next-image", next_image_closure);
    gtk_accel_group_connect_by_path (accel_group, "<Window>/previous-image", previous_image_closure);
924
    gtk_accel_group_connect_by_path (accel_group, "<Window>/quit", quit_closure);
925
    gtk_accel_group_connect_by_path (accel_group, "<Window>/delete", delete_closure);
926
    gtk_accel_group_connect_by_path (accel_group, "<Window>/refresh", refresh_closure);
927

Stephan Arts's avatar
Stephan Arts committed
928 929
    /* Set default accelerators */

930
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
931
    /* Create mergeid's for adding ui-components */
932
    window->priv->recent_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
Stephan Arts's avatar
Stephan Arts committed
933 934
    window->priv->play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
    window->priv->pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
Stephan Arts's avatar
Stephan Arts committed
935 936 937 938
    window->priv->toolbar_play_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
    window->priv->toolbar_pause_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
    window->priv->toolbar_fullscreen_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
    window->priv->toolbar_unfullscreen_merge_id = gtk_ui_manager_new_merge_id (window->priv->ui_manager);
Stephan Arts's avatar
Stephan Arts committed
939

940
    /* Create Play/Pause Slideshow actions */
941 942
    window->priv->play_action = gtk_action_new ("play", _("_Play"), _("Play slideshow"), "gtk-media-play");
    window->priv->pause_action = gtk_action_new ("pause", _("_Pause"), _("Pause slideshow"), "gtk-media-pause");
943 944

    /* Create Recently used items Action */
945 946
    window->priv->recent_action = gtk_recent_action_new_for_manager ("document-open-recent", _("_Recently used"), _("Recently used"),
                                                                     0, GTK_RECENT_MANAGER (window->priv->recent_manager));
947
G_GNUC_END_IGNORE_DEPRECATIONS
948

949 950
    gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (window->priv->recent_action), GTK_RECENT_SORT_MRU);

951 952
    /* Add a filter to the recent-chooser */
    recent_filter = gtk_recent_filter_new ();
Stephan Arts's avatar
Stephan Arts committed
953
    gtk_recent_filter_add_application (recent_filter, "ristretto");
954
    gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (window->priv->recent_action), recent_filter);
Stephan Arts's avatar
Stephan Arts committed
955

956
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Stephan Arts's avatar
Stephan Arts committed
957 958 959
    /* Add the same accelerator path to play and pause, so the same kb-shortcut will be used for starting and stopping the slideshow */
    gtk_action_set_accel_path (window->priv->pause_action, "<Actions>/RsttoWindow/play");
    gtk_action_set_accel_path (window->priv->play_action, "<Actions>/RsttoWindow/play");
Stephan Arts's avatar
Stephan Arts committed
960

Stephan Arts's avatar
Stephan Arts committed
961
    /* Add the play and pause actions to the actiongroup */
Stephan Arts's avatar
Stephan Arts committed
962
    window->priv->action_group = gtk_action_group_new ("RsttoWindow");
963 964 965
    gtk_action_group_add_action (window->priv->action_group, window->priv->play_action);
    gtk_action_group_add_action (window->priv->action_group, window->priv->pause_action);
    gtk_action_group_add_action (window->priv->action_group, window->priv->recent_action);
966
G_GNUC_END_IGNORE_DEPRECATIONS
967

Stephan Arts's avatar
Stephan Arts committed
968 969 970
    /* Connect signal-handlers */
    g_signal_connect(G_OBJECT(window->priv->play_action), "activate", G_CALLBACK(cb_rstto_main_window_play), window);
    g_signal_connect(G_OBJECT(window->priv->pause_action), "activate", G_CALLBACK(cb_rstto_main_window_pause), window);
Stephan Arts's avatar
Stephan Arts committed
971
    g_signal_connect(G_OBJECT(window->priv->recent_action), "item-activated", G_CALLBACK(cb_rstto_main_window_open_recent), window);
Stephan Arts's avatar
Stephan Arts committed
972

973
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Stephan Arts's avatar
Stephan Arts committed
974 975 976
    gtk_ui_manager_insert_action_group (window->priv->ui_manager, window->priv->action_group, 0);

    gtk_action_group_set_translation_domain (window->priv->action_group, GETTEXT_PACKAGE);
977 978 979 980 981 982 983 984 985 986 987 988 989 990
    gtk_action_group_add_actions (window->priv->action_group, action_entries,
                                  G_N_ELEMENTS (action_entries), GTK_WIDGET (window));
    gtk_action_group_add_toggle_actions (window->priv->action_group, toggle_action_entries,
                                         G_N_ELEMENTS (toggle_action_entries), GTK_WIDGET (window));
    gtk_action_group_add_radio_actions (window->priv->action_group, radio_action_sort_entries,
                                        G_N_ELEMENTS (radio_action_sort_entries), 0,
                                        G_CALLBACK (cb_rstto_main_window_sorting_function_changed), GTK_WIDGET (window));
    gtk_action_group_add_radio_actions (window->priv->action_group, radio_action_pos_entries,
                                        G_N_ELEMENTS (radio_action_pos_entries), navigationbar_position,
                                        G_CALLBACK (cb_rstto_main_window_navigationtoolbar_position_changed), GTK_WIDGET (window));
    gtk_action_group_add_radio_actions (window->priv->action_group, radio_action_size_entries,
                                        G_N_ELEMENTS (radio_action_size_entries), thumbnail_size,
                                        G_CALLBACK (cb_rstto_main_window_thumbnail_size_changed), GTK_WIDGET (window));

Igor's avatar
Igor committed
991
    gtk_ui_manager_add_ui_from_string (window->priv->ui_manager, main_window_ui, main_window_ui_length, NULL);
Stephan Arts's avatar
Stephan Arts committed
992
    window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
993
    window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");