1 /*
2  * Copyright © 2009-2018 Siyan Panayotov <contact@siyanpanayotov.com>
3  *
4  * This file is part of Viewnior.
5  *
6  * Viewnior is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Viewnior is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Viewnior.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __VNR_WINDOW_H__
21 #define __VNR_WINDOW_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 #include <gtk/gtk.h>
26 #include "vnr-prefs.h"
27 
28 G_BEGIN_DECLS
29 
30 typedef struct _VnrWindow VnrWindow;
31 typedef struct _VnrWindowClass VnrWindowClass;
32 
33 #define VNR_TYPE_WINDOW             (vnr_window_get_type ())
34 #define VNR_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), VNR_TYPE_WINDOW, VnrWindow))
35 #define VNR_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass),  VNR_TYPE_WINDOW, VnrWindowClass))
36 #define VNR_IS_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VNR_TYPE_WINDOW))
37 #define VNR_IS_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  VNR_TYPE_WINDOW))
38 #define VNR_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj),  VNR_TYPE_WINDOW, VnrWindowClass))
39 
40 typedef enum {
41     VNR_WINDOW_MODE_NORMAL,
42     VNR_WINDOW_MODE_FULLSCREEN,
43     VNR_WINDOW_MODE_SLIDESHOW,
44 } VnrWindowMode;
45 
46 struct _VnrWindow {
47     GtkWindow win;
48 
49     GtkUIManager *ui_mngr;
50 
51     GtkActionGroup *actions_window;
52     GtkActionGroup *actions_image;
53     GtkActionGroup *actions_static_image;
54     GtkActionGroup *actions_collection;
55     GtkActionGroup *action_save;
56     GtkActionGroup *action_properties;
57     GtkActionGroup *actions_bars;
58     GtkActionGroup *actions_open_with;
59 
60     guint open_with_menu_id;
61 
62     GtkWidget *layout;
63     GtkWidget *menus;
64 
65     GtkWidget *menu_bar;
66     GtkWidget *button_menu;
67     GtkWidget *toolbar;
68     GtkWidget *properties_button;
69     GtkWidget *popup_menu;
70 
71     GtkWidget *msg_area;
72     GtkWidget *props_dlg;
73 
74     GtkWidget *view;
75     GtkWidget *scroll_view;
76 
77     GList *file_list;
78 
79     VnrPrefs *prefs;
80 
81     gint max_width;
82     gint max_height;
83     gchar *writable_format_name;
84 
85     gint current_image_height;
86     gint current_image_width;
87 
88     VnrWindowMode mode;
89     guint8 modifications;
90 
91     gboolean cursor_is_hidden;
92 
93     /* Fullscreen (fs) variables */
94     GtkWidget *fs_controls;
95     GtkWidget *toggle_btn;
96     GtkWidget *fs_seconds_label;
97     GtkWidget *fs_filename_label;
98     GSource *fs_source;
99     gboolean disable_autohide;
100     /* Slideshow (ss) variables */
101     gboolean slideshow;
102     guint ss_source_tag;
103     gint ss_timeout;
104     GtkWidget *ss_timeout_widget;
105 
106     GtkActionGroup *action_wallpaper;
107 };
108 
109 struct _VnrWindowClass {
110     GtkWindowClass parent_class;
111 };
112 
113 GType       vnr_window_get_type (void) G_GNUC_CONST;
114 
115 /* Constructors */
116 GtkWindow*  vnr_window_new      (void);
117 
118 /* Actions */
119 gboolean vnr_window_open     (VnrWindow *win, gboolean fit_to_screen);
120 void     vnr_window_open_from_list (VnrWindow *window, GSList *uri_list);
121 void     vnr_window_close    (VnrWindow *win);
122 
123 void     vnr_window_set_list (VnrWindow *win, GList *list, gboolean free_current);
124 gboolean vnr_window_next     (VnrWindow *win, gboolean rem_timeout);
125 gboolean vnr_window_prev     (VnrWindow *win);
126 gboolean vnr_window_first    (VnrWindow *win);
127 gboolean vnr_window_last     (VnrWindow *win);
128 void     deny_slideshow      (VnrWindow *window);
129 void     vnr_window_apply_preferences (VnrWindow *window);
130 void     vnr_window_toggle_fullscreen (VnrWindow *win);
131 
132 G_END_DECLS
133 #endif /* __VNR_WINDOW_H__ */
134