Commit c10105a2 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

save and restore the thumbnail list size

[new feature]
parent 7a85ec3d
......@@ -125,6 +125,9 @@
<key name="thumbnail-list-visible" type="b">
<default>true</default>
</key>
<key name="thumbnail-list-size" type="i">
<default>0</default>
</key>
<key name="browser-sidebar-width" type="i">
<default>285</default>
</key>
......
......@@ -88,6 +88,7 @@ PUBLIC_HEADER_FILES = \
gth-monitor.h \
gth-multipage.h \
gth-overwrite-dialog.h \
gth-paned.h \
gth-preferences.h \
gth-progress-dialog.h \
gth-request-dialog.h \
......@@ -227,6 +228,7 @@ gthumb_SOURCES = \
gth-monitor.c \
gth-multipage.c \
gth-overwrite-dialog.c \
gth-paned.c \
gth-preferences.c \
gth-progress-dialog.c \
gth-request-dialog.c \
......
......@@ -50,6 +50,7 @@
#include "gth-marshal.h"
#include "gth-menu-action.h"
#include "gth-metadata-provider.h"
#include "gth-paned.h"
#include "gth-preferences.h"
#include "gth-progress-dialog.h"
#include "gth-sidebar.h"
......@@ -2227,6 +2228,22 @@ _gth_browser_close_final_step (gpointer user_data)
if (allocation.width > MIN_SIDEBAR_SIZE)
g_settings_set_int (browser->priv->browser_settings, PREF_BROWSER_VIEWER_SIDEBAR_WIDTH, allocation.width);
switch (gth_file_list_get_mode (GTH_FILE_LIST (browser->priv->thumbnail_list))) {
case GTH_FILE_LIST_MODE_H_SIDEBAR:
g_settings_set_int (browser->priv->browser_settings,
PREF_BROWSER_THUMBNAIL_LIST_SIZE,
_gtk_paned_get_position2 (GTK_PANED (browser->priv->viewer_thumbnails_pane)));
break;
case GTH_FILE_LIST_MODE_V_SIDEBAR:
g_settings_set_int (browser->priv->browser_settings,
PREF_BROWSER_THUMBNAIL_LIST_SIZE,
gtk_paned_get_position (GTK_PANED (browser->priv->viewer_thumbnails_pane)));
break;
default:
g_warning ("Wrong thumbnail list mode");
break;
}
g_settings_set_enum (browser->priv->browser_settings, PREF_BROWSER_VIEWER_SIDEBAR, browser->priv->viewer_sidebar);
}
......@@ -4371,17 +4388,21 @@ gth_browser_init (GthBrowser *browser)
gtk_paned_pack1 (GTK_PANED (browser->priv->viewer_sidebar_pane), browser->priv->viewer_container, TRUE, FALSE);
browser->priv->viewer_sidebar_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
_gtk_paned_set_position2 (GTK_PANED (browser->priv->viewer_sidebar_pane), g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_BROWSER_SIDEBAR_WIDTH));
gth_paned_set_position2 (GTH_PANED (browser->priv->viewer_sidebar_pane), g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_BROWSER_SIDEBAR_WIDTH));
gtk_paned_pack2 (GTK_PANED (browser->priv->viewer_sidebar_pane), browser->priv->viewer_sidebar_alignment, FALSE, FALSE);
browser->priv->thumbnail_list = gth_file_list_new (gth_grid_view_new (), (viewer_thumbnails_orientation == GTK_ORIENTATION_HORIZONTAL) ? GTH_FILE_LIST_MODE_H_SIDEBAR : GTH_FILE_LIST_MODE_V_SIDEBAR, TRUE);
gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->thumbnail_list), "none");
gth_grid_view_set_cell_spacing (GTH_GRID_VIEW (gth_file_list_get_view (GTH_FILE_LIST (browser->priv->thumbnail_list))), 0);
gth_file_list_set_thumb_size (GTH_FILE_LIST (browser->priv->thumbnail_list), 95);
if (viewer_thumbnails_orientation == GTK_ORIENTATION_HORIZONTAL)
if (viewer_thumbnails_orientation == GTK_ORIENTATION_HORIZONTAL) {
gth_paned_set_position2 (GTH_PANED (browser->priv->viewer_thumbnails_pane), g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_THUMBNAIL_LIST_SIZE));
gtk_paned_pack2 (GTK_PANED (browser->priv->viewer_thumbnails_pane), browser->priv->thumbnail_list, FALSE, FALSE);
else
}
else {
gtk_paned_set_position (GTK_PANED (browser->priv->viewer_thumbnails_pane), g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_THUMBNAIL_LIST_SIZE));
gtk_paned_pack1 (GTK_PANED (browser->priv->viewer_thumbnails_pane), browser->priv->thumbnail_list, FALSE, FALSE);
}
_gth_browser_set_thumbnail_list_visibility (browser, g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_THUMBNAIL_LIST_VISIBLE));
g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (browser->priv->thumbnail_list)),
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2012 The Free Software Foundation, Inc.
*
* 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.
*
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <gtk/gtk.h>
#include "gth-paned.h"
G_DEFINE_TYPE (GthPaned, gth_paned, GTK_TYPE_PANED)
enum {
PROP_0,
PROP_POSITION2
};
struct _GthPanedPrivate {
int child2_size;
gboolean position2_set;
};
static void
gth_paned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GthPaned *self;
self = GTH_PANED (widget);
if (self->priv->position2_set) {
self->priv->position2_set = FALSE;
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget))) {
case GTK_ORIENTATION_HORIZONTAL:
gtk_paned_set_position (GTK_PANED (self), allocation->width - self->priv->child2_size);
break;
case GTK_ORIENTATION_VERTICAL:
gtk_paned_set_position (GTK_PANED (self), allocation->height - self->priv->child2_size);
break;
}
}
GTK_WIDGET_CLASS (gth_paned_parent_class)->size_allocate (widget, allocation);
}
static void
gth_paned_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GthPaned *self;
self = GTH_PANED (object);
switch (prop_id) {
case PROP_POSITION2:
gth_paned_set_position2 (self, g_value_get_int (value));
break;
default:
break;
}
}
static void
gth_paned_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GthPaned *self;
self = GTH_PANED (object);
switch (prop_id) {
case PROP_POSITION2:
g_value_set_int (value, self->priv->child2_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gth_paned_class_init (GthPanedClass *paned_class)
{
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
g_type_class_add_private (paned_class, sizeof (GthPanedPrivate));
gobject_class = (GObjectClass*) paned_class;
gobject_class->set_property = gth_paned_set_property;
gobject_class->get_property = gth_paned_get_property;
widget_class = (GtkWidgetClass*) paned_class;
widget_class->size_allocate = gth_paned_size_allocate;
/* Properties */
g_object_class_install_property (gobject_class,
PROP_POSITION2,
g_param_spec_int ("position2",
"Position 2",
"Position starting from the end",
0,
G_MAXINT32,
0,
G_PARAM_READWRITE));
}
static void
gth_paned_init (GthPaned *self)
{
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_PANED, GthPanedPrivate);
self->priv->position2_set = FALSE;
self->priv->child2_size = 0;
}
GtkWidget *
gth_paned_new (GtkOrientation orientation)
{
return g_object_new (GTH_TYPE_PANED, "orientation", orientation, NULL);
}
void
gth_paned_set_position2 (GthPaned *self,
int position)
{
g_return_if_fail (GTH_IS_PANED (self));
if (position >= 0) {
self->priv->child2_size = position;
self->priv->position2_set = TRUE;
}
else
self->priv->position2_set = FALSE;
g_object_notify (G_OBJECT (self), "position2");
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (self));
}
int
gth_paned_get_position2 (GthPaned *self)
{
g_return_val_if_fail (GTH_IS_PANED (self), 0);
return self->priv->child2_size;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2012 The Free Software Foundation, Inc.
*
* 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.
*
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GTH_PANED_H
#define GTH_PANED_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GTH_TYPE_PANED (gth_paned_get_type ())
#define GTH_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_PANED, GthPaned))
#define GTH_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_PANED, GthPanedClass))
#define GTH_IS_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_PANED))
#define GTH_IS_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_PANED))
#define GTH_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTH_TYPE_PANED, GthPanedClass))
typedef struct _GthPaned GthPaned;
typedef struct _GthPanedClass GthPanedClass;
typedef struct _GthPanedPrivate GthPanedPrivate;
struct _GthPaned {
GtkPaned __parent;
GthPanedPrivate *priv;
};
struct _GthPanedClass {
GtkPanedClass __parent_class;
};
GType gth_paned_get_type (void);
GtkWidget * gth_paned_new (GtkOrientation orientation);
void gth_paned_set_position2 (GthPaned *paned,
int position);
int gth_paned_get_position2 (GthPaned *paned);
G_END_DECLS
#endif /* GTH_PANED_H */
......@@ -76,6 +76,7 @@ G_BEGIN_DECLS
#define PREF_BROWSER_PROPERTIES_VISIBLE "properties-visible"
#define PREF_BROWSER_PROPERTIES_ON_THE_RIGHT "properties-on-the-right"
#define PREF_BROWSER_THUMBNAIL_LIST_VISIBLE "thumbnail-list-visible"
#define PREF_BROWSER_THUMBNAIL_LIST_SIZE "thumbnail-list-size"
#define PREF_BROWSER_BROWSER_SIDEBAR_WIDTH "browser-sidebar-width"
#define PREF_BROWSER_VIEWER_SIDEBAR "viewer-sidebar"
#define PREF_BROWSER_VIEWER_SIDEBAR_WIDTH "viewer-sidebar-width"
......
......@@ -761,10 +761,9 @@ _gtk_tree_path_list_free (GList *list)
int
_gtk_paned_get_position2 (GtkPaned *paned)
{
int pos;
GtkWidget *w;
GtkRequisition requisition;
int size;
int pos;
GtkAllocation allocation;
int size;
if (! gtk_widget_get_visible (GTK_WIDGET (paned)))
return 0;
......@@ -773,15 +772,11 @@ _gtk_paned_get_position2 (GtkPaned *paned)
if (pos == 0)
return 0;
w = gtk_widget_get_toplevel (GTK_WIDGET (paned));
if (! gtk_widget_is_toplevel (w))
return 0;
gtk_window_get_size (GTK_WINDOW (w), &(requisition.width), &(requisition.height));
gtk_widget_get_allocation (GTK_WIDGET (paned), &allocation);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
size = requisition.width;
size = allocation.width;
else
size = requisition.height;
size = allocation.height;
if (size == 0)
return 0;
......@@ -790,29 +785,6 @@ _gtk_paned_get_position2 (GtkPaned *paned)
}
void
_gtk_paned_set_position2 (GtkPaned *paned,
int pos)
{
GtkWidget *top_level;
GtkAllocation allocation;
int size;
top_level = gtk_widget_get_toplevel (GTK_WIDGET (paned));
if (! gtk_widget_is_toplevel (top_level))
return;
gtk_widget_get_allocation (top_level, &allocation);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
size = allocation.width;
else
size = allocation.height;
if (pos > 0)
gtk_paned_set_position (paned, size - pos);
}
void
_g_launch_command (GtkWidget *parent,
const char *command,
......
......@@ -114,8 +114,6 @@ int _gtk_widget_lookup_for_size (GtkWidget *wi
GtkIconSize icon_size);
void _gtk_tree_path_list_free (GList *list);
int _gtk_paned_get_position2 (GtkPaned *paned);
void _gtk_paned_set_position2 (GtkPaned *paned,
int pos);
void _g_launch_command (GtkWidget *parent,
const char *command,
const char *name,
......
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