Commit 2e4660e9 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

added option to open files in fullscreen mode

parent 868e3524
......@@ -83,6 +83,9 @@
<key name="single-click-activation" type="b">
<default>true</default>
</key>
<key name="open-files-in-fullscreen" type="b">
<default>false</default>
</key>
<key name="sort-type" type="s">
<default>'file::mtime'</default>
</key>
......@@ -132,6 +135,12 @@
<default>false</default>
<_description>Open files in the active window</_description>
</key>
<key name="fullscreen-sidebar" enum="org.gnome.gthumb.GthSidebarState">
<default>'hidden'</default>
</key>
<key name="fullscreen-thumbnails-visible" type="b">
<default>false</default>
</key>
</schema>
<schema id="org.gnome.gthumb.dialogs" path="/org/gnome/gthumb/dialogs/">
......
......@@ -124,6 +124,22 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="open_in_fullscreen_checkbutton">
<property name="label" translatable="yes">_Open files in fullscreen mode</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -577,6 +577,8 @@ image_navigator_get_child_position_cb (GtkOverlay *overlay,
if (widget == self->priv->overview_revealer) {
allocation->x = main_alloc.width - allocation->width - OVERLAY_MARGIN;
allocation->y = OVERLAY_MARGIN;
if (gth_browser_get_is_fullscreen (self->priv->browser))
allocation->y += gtk_widget_get_allocated_height (gth_browser_get_fullscreen_headerbar (self->priv->browser));
allocation_filled = TRUE;
}
......
......@@ -106,6 +106,14 @@ click_behavior_changed_cb (GtkToggleButton *button,
}
static void
open_in_fullscreen_toggled_cb (GtkToggleButton *button,
BrowserData *data)
{
g_settings_set_boolean (data->browser_settings, PREF_BROWSER_OPEN_FILES_IN_FULLSCREEN, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("open_in_fullscreen_checkbutton"))));
}
void
browser__dlg_preferences_construct_cb (GtkWidget *dialog,
GthBrowser *browser,
......@@ -140,6 +148,9 @@ browser__dlg_preferences_construct_cb (GtkWidget *dialog,
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("double_click_radiobutton")), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("open_in_fullscreen_checkbutton")),
g_settings_get_boolean (data->browser_settings, PREF_BROWSER_OPEN_FILES_IN_FULLSCREEN));
/* other */
gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("thumbnail_size_combobox")),
......@@ -165,6 +176,10 @@ browser__dlg_preferences_construct_cb (GtkWidget *dialog,
"toggled",
G_CALLBACK (click_behavior_changed_cb),
data);
g_signal_connect (G_OBJECT (GET_WIDGET ("open_in_fullscreen_checkbutton")),
"toggled",
G_CALLBACK (open_in_fullscreen_toggled_cb),
data);
g_signal_connect (G_OBJECT (data->thumbnail_caption_chooser),
"changed",
G_CALLBACK (thumbnail_caption_chooser_changed_cb),
......
This diff is collapsed.
......@@ -263,6 +263,8 @@ void gth_browser_save_state (GthBrowser *browser);
gboolean gth_browser_restore_state (GthBrowser *browser);
void gth_browser_apply_editor_changes (GthBrowser *browser);
GthICCProfile gth_browser_get_screen_profile (GthBrowser *browser);
GtkWidget * gth_browser_get_fullscreen_headerbar
(GthBrowser *browser);
/* utilities */
......
......@@ -2692,7 +2692,7 @@ _gth_grid_view_select_single (GthGridView *self,
self->priv->last_selected_pos = pos;
self->priv->last_selected_item = item;
if (self->priv->activate_on_single_click)
if (self->priv->activate_on_single_click && ((event->state & GDK_MOD1_MASK) == 0))
self->priv->activate_pending = TRUE;
}
......@@ -2762,8 +2762,9 @@ gth_grid_view_button_press (GtkWidget *widget,
if ((pos != -1) && (event->button == 1) && (event->type == GDK_2BUTTON_PRESS)) {
/* Double click activates the item */
if (((event->state & GDK_CONTROL_MASK) != GDK_CONTROL_MASK)
&& ((event->state & GDK_SHIFT_MASK) != GDK_SHIFT_MASK))
if (! (event->state & GDK_CONTROL_MASK)
&& ! (event->state & GDK_SHIFT_MASK)
&& ! (event->state & GDK_MOD1_MASK))
{
gth_file_view_activated (GTH_FILE_VIEW (self), pos);
}
......@@ -2774,6 +2775,7 @@ gth_grid_view_button_press (GtkWidget *widget,
if (! (event->state & GDK_CONTROL_MASK)
&& ! (event->state & GDK_SHIFT_MASK)
&& ! (event->state & GDK_MOD1_MASK)
&& self->priv->drag_source_enabled)
{
self->priv->dragging = TRUE;
......@@ -2788,6 +2790,7 @@ gth_grid_view_button_press (GtkWidget *widget,
if (! (event->state & GDK_CONTROL_MASK)
&& ! (event->state & GDK_SHIFT_MASK)
&& ! (event->state & GDK_MOD1_MASK)
&& self->priv->drag_source_enabled)
{
self->priv->dragging = TRUE;
......@@ -3043,8 +3046,8 @@ gth_grid_view_button_release (GtkWidget *widget,
_gth_grid_view_set_item_selected_and_emit_signal (self, TRUE, self->priv->select_pending_pos);
self->priv->last_selected_pos = self->priv->select_pending_pos;
self->priv->last_selected_item = self->priv->select_pending_item;
if (self->priv->activate_on_single_click)
gth_file_view_activated (GTH_FILE_VIEW (self), self->priv->last_selected_pos);
if (self->priv->activate_on_single_click && ((event->state & GDK_MOD1_MASK) == 0))
self->priv->activate_pending = TRUE;
}
if (self->priv->activate_pending) {
......
......@@ -62,6 +62,7 @@ G_BEGIN_DECLS
#define PREF_BROWSER_THUMBNAIL_LIMIT "thumbnail-limit"
#define PREF_BROWSER_THUMBNAIL_CAPTION "thumbnail-caption"
#define PREF_BROWSER_SINGLE_CLICK_ACTIVATION "single-click-activation"
#define PREF_BROWSER_OPEN_FILES_IN_FULLSCREEN "open-files-in-fullscreen"
#define PREF_BROWSER_SORT_TYPE "sort-type"
#define PREF_BROWSER_SORT_INVERSE "sort-inverse"
#define PREF_BROWSER_WINDOW_WIDTH "window-width"
......@@ -79,6 +80,9 @@ G_BEGIN_DECLS
#define PREF_BROWSER_VIEWER_THUMBNAILS_ORIENT "viewer-thumbnails-orientation"
#define PREF_BROWSER_REUSE_ACTIVE_WINDOW "reuse-active-window"
#define PREF_FULLSCREEN_THUMBNAILS_VISIBLE "fullscreen-thumbnails-visible"
#define PREF_FULLSCREEN_SIDEBAR "fullscreen-sidebar"
/* keys: add to catalog */
#define PREF_ADD_TO_CATALOG_LAST_CATALOG "last-catalog"
......
......@@ -41,8 +41,10 @@ struct _GthWindowPrivate {
int n_pages;
gboolean use_header_bar;
int current_page;
GtkWidget *overlay;
GtkWidget *grid;
GtkWidget *stack;
GtkWidget *headerbar_container;
GtkWidget *headerbar;
GtkWidget *title;
GtkWidget *menubar;
......@@ -58,6 +60,25 @@ struct _GthWindowPrivate {
};
static gboolean
overlay_get_child_position_cb (GtkOverlay *overlay,
GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
GtkAllocation main_alloc;
gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (overlay)), &main_alloc);
allocation->x = 0;
allocation->y = 0;
allocation->width = main_alloc.width;
gtk_widget_get_preferred_height (widget, NULL, &allocation->height);
return TRUE;
}
static void
gth_window_set_n_pages (GthWindow *self,
int n_pages)
......@@ -71,9 +92,19 @@ gth_window_set_n_pages (GthWindow *self,
self->priv->n_pages = n_pages;
self->priv->overlay = gtk_overlay_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->overlay), "window-overlay");
gtk_widget_show (self->priv->overlay);
gtk_container_add (GTK_CONTAINER (self), self->priv->overlay);
g_signal_connect (self->priv->overlay,
"get-child-position",
G_CALLBACK (overlay_get_child_position_cb),
self);
self->priv->grid = gtk_grid_new ();
gtk_widget_show (self->priv->grid);
gtk_container_add (GTK_CONTAINER (self), self->priv->grid);
gtk_container_add (GTK_CONTAINER (self->priv->overlay), self->priv->grid);
self->priv->stack = gtk_stack_new ();
gtk_stack_set_transition_type (GTK_STACK (self->priv->stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
......@@ -116,6 +147,8 @@ _gth_window_add_header_bar (GthWindow *self)
gtk_widget_show (self->priv->headerbar);
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self->priv->headerbar), TRUE);
g_object_add_weak_pointer (G_OBJECT (self->priv->headerbar), &self->priv->headerbar);
#if GTK_CHECK_VERSION(3,12,0)
{
gboolean shell_shows_app_menu;
......@@ -145,7 +178,12 @@ _gth_window_add_header_bar (GthWindow *self)
self->priv->title = gth_window_title_new ();
gtk_widget_show (self->priv->title);
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (self->priv->headerbar), self->priv->title);
gtk_window_set_titlebar (GTK_WINDOW (self), self->priv->headerbar);
self->priv->headerbar_container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (self->priv->headerbar_container);
gtk_box_pack_start (GTK_BOX (self->priv->headerbar_container), self->priv->headerbar, TRUE, TRUE, 0);
gtk_window_set_titlebar (GTK_WINDOW (self), self->priv->headerbar_container);
}
......@@ -452,6 +490,10 @@ void
gth_window_set_current_page (GthWindow *window,
int page)
{
g_return_if_fail (window != NULL);
g_return_if_fail (GTH_IS_WINDOW (window));
g_return_if_fail (page >= 0 && page < window->priv->n_pages);
GTH_WINDOW_GET_CLASS (window)->set_current_page (window, page);
}
......@@ -527,6 +569,28 @@ gth_window_get_area (GthWindow *window,
}
void
gth_window_add_overlay (GthWindow *window,
GtkWidget *widget)
{
gtk_overlay_add_overlay (GTK_OVERLAY (window->priv->overlay), widget);
}
void
gth_window_set_header_bar (GthWindow *window,
GtkWidget *header_bar)
{
if (window->priv->headerbar != header_bar) {
if (window->priv->headerbar != NULL)
gtk_widget_destroy (window->priv->headerbar);
window->priv->headerbar = header_bar;
}
gtk_widget_show (window->priv->headerbar);
gtk_box_pack_start (GTK_BOX (window->priv->headerbar_container), window->priv->headerbar, TRUE, TRUE, 0);
}
GtkWidget *
gth_window_get_header_bar (GthWindow *window)
{
......
......@@ -88,6 +88,10 @@ void gth_window_show_only_content (GthWindow *window,
gboolean only_content);
GtkWidget * gth_window_get_area (GthWindow *window,
GthWindowArea area);
void gth_window_add_overlay (GthWindow *window,
GtkWidget *widget);
void gth_window_set_header_bar (GthWindow *window,
GtkWidget *header_bar);
GtkWidget * gth_window_get_header_bar (GthWindow *window);
void gth_window_save_page_size (GthWindow *window,
int page,
......
......@@ -145,3 +145,11 @@ GthToolbox .header-bar {
box-shadow: none;
background-image: none;
}
/* -- header-bar in fullscreen -- */
.window-overlay .header-bar {
border-radius: 0;
box-shadow: none;
background-image: none;
}
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