[Xfce4-commits] <ristretto:master> Save sort-style and update statusbar on zoom-event.
Stephan Arts
noreply at xfce.org
Thu Dec 29 17:52:01 CET 2011
Updating branch refs/heads/master
to b51d24193333fee0f84a466ba815cdbb0abcf583 (commit)
from c77e2c2eac16181d189bc00ca0e79f212e403966 (commit)
commit b51d24193333fee0f84a466ba815cdbb0abcf583
Author: Stephan Arts <stephan at xfce.org>
Date: Thu Dec 29 17:48:46 2011 +0100
Save sort-style and update statusbar on zoom-event.
src/image_viewer.c | 23 +++++++++++++++-----
src/main_window.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++----
src/settings.c | 32 +++++++++++++++++++++++++++++
src/util.h | 9 +++++++-
4 files changed, 109 insertions(+), 12 deletions(-)
diff --git a/src/image_viewer.c b/src/image_viewer.c
index b7f5611..2749b6d 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -363,12 +363,21 @@ rstto_image_viewer_class_init(RsttoImageViewerClass *viewer_class)
G_TYPE_NONE, 2,
GTK_TYPE_ADJUSTMENT,
GTK_TYPE_ADJUSTMENT);
- g_signal_new ("size-ready", G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new (
+ "size-ready",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ g_signal_new ("scale-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
/**
@@ -2067,6 +2076,8 @@ rstto_scroll_event (
widget->window,
NULL,
FALSE);
+
+ g_signal_emit_by_name(viewer, "scale-changed");
}
return TRUE;
}
diff --git a/src/main_window.c b/src/main_window.c
index 933c58b..bfda034 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -529,6 +529,7 @@ rstto_main_window_init (RsttoMainWindow *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_ui_manager_add_ui_from_string (window->priv->ui_manager,main_window_ui, main_window_ui_length, NULL);
window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/file-toolbar");
@@ -569,9 +570,6 @@ rstto_main_window_init (RsttoMainWindow *window)
RSTTO_IMAGE_VIEWER(window->priv->image_viewer),
GTK_MENU(window->priv->image_viewer_menu));
-
-
-
//rstto_picture_viewer_set_menu (RSTTO_PICTURE_VIEWER (window->priv->picture_viewer), GTK_MENU(window->priv->image_viewer_menu));
window->priv->thumbnailbar = rstto_thumbnail_bar_new (NULL);
@@ -698,6 +696,32 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_widget_hide (window->priv->thumbnailbar);
}
+ /**
+ * Set sort-type
+ */
+ switch (rstto_settings_get_uint_property (window->priv->settings_manager, "sort-type"))
+ {
+ case SORT_TYPE_NAME:
+ gtk_check_menu_item_set_active (
+ GTK_CHECK_MENU_ITEM (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/edit-menu/sorting-menu/sort-filename")),
+ TRUE);
+ break;
+ case SORT_TYPE_DATE:
+ gtk_check_menu_item_set_active (
+ GTK_CHECK_MENU_ITEM (
+ gtk_ui_manager_get_widget (
+ window->priv->ui_manager,
+ "/main-menu/edit-menu/sorting-menu/sort-date")),
+ TRUE);
+ break;
+ default:
+ g_warning("Sort type unsupported");
+ break;
+ }
+
g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(cb_rstto_main_window_motion_notify_event), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "enter-notify-event", G_CALLBACK(cb_rstto_main_window_image_viewer_enter_notify_event), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "scroll-event", G_CALLBACK(cb_rstto_main_window_image_viewer_scroll_event), window);
@@ -707,6 +731,7 @@ rstto_main_window_init (RsttoMainWindow *window)
g_signal_connect(G_OBJECT(window->priv->image_list_toolbar), "button-press-event", G_CALLBACK(cb_rstto_main_window_navigationtoolbar_button_press_event), window);
g_signal_connect(G_OBJECT(window->priv->thumbnailbar), "button-press-event", G_CALLBACK(cb_rstto_main_window_navigationtoolbar_button_press_event), window);
g_signal_connect(G_OBJECT(window->priv->image_viewer), "size-ready", G_CALLBACK(cb_rstto_main_window_update_statusbar), window);
+ g_signal_connect(G_OBJECT(window->priv->image_viewer), "scale-changed", G_CALLBACK(cb_rstto_main_window_update_statusbar), window);
if ( TRUE == rstto_settings_get_boolean_property (window->priv->settings_manager, "merge-toolbars"))
{
@@ -833,6 +858,20 @@ rstto_main_window_new (RsttoImageList *image_list, gboolean fullscreen)
window->priv->image_list = image_list;
g_object_ref (image_list);
+ switch (rstto_settings_get_uint_property (window->priv->settings_manager, "sort-type"))
+ {
+ case SORT_TYPE_NAME:
+ rstto_image_list_set_sort_by_name (window->priv->image_list);
+ break;
+ case SORT_TYPE_DATE:
+ rstto_image_list_set_sort_by_date (window->priv->image_list);
+ break;
+ default:
+ g_warning("Sort type unsupported");
+ break;
+ }
+
+
window->priv->iter = rstto_image_list_get_iter (window->priv->image_list);
g_signal_connect (
G_OBJECT (window->priv->iter),
@@ -1788,10 +1827,18 @@ cb_rstto_main_window_sorting_function_changed (GtkRadioAction *action, GtkRadioA
{
case 0: /* Sort by filename */
default:
- rstto_image_list_set_sort_by_name (window->priv->image_list);
+ if (window->priv->image_list != NULL)
+ {
+ rstto_image_list_set_sort_by_name (window->priv->image_list);
+ rstto_settings_set_uint_property (window->priv->settings_manager, "sort-type", SORT_TYPE_NAME);
+ }
break;
case 1: /* Sort by date */
- rstto_image_list_set_sort_by_date (window->priv->image_list);
+ if (window->priv->image_list != NULL)
+ {
+ rstto_image_list_set_sort_by_date (window->priv->image_list);
+ rstto_settings_set_uint_property (window->priv->settings_manager, "sort-type", SORT_TYPE_DATE);
+ }
break;
}
}
diff --git a/src/settings.c b/src/settings.c
index f467061..1d89aca 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -23,6 +23,7 @@
#include <xfconf/xfconf.h>
#include <libxfce4util/libxfce4util.h>
+#include "util.h"
#include "settings.h"
static void
@@ -72,6 +73,7 @@ enum
PROP_MAXIMIZE_ON_STARTUP,
PROP_MERGE_TOOLBARS,
PROP_ERROR_MISSING_THUMBNAILER,
+ PROP_SORT_TYPE,
};
GType
@@ -123,6 +125,8 @@ struct _RsttoSettingsPriv
gboolean maximize_on_startup;
gboolean merge_toolbars;
+ RsttoSortType sort_type;
+
struct {
gboolean missing_thumbnailer;
} errors;
@@ -198,6 +202,13 @@ rstto_settings_init (GObject *object)
xfconf_g_property_bind (
settings->priv->channel,
+ "/window/navigationbar/sort-type",
+ G_TYPE_UINT,
+ settings,
+ "sort-type");
+
+ xfconf_g_property_bind (
+ settings->priv->channel,
"/window/navigationbar/position",
G_TYPE_STRING,
settings,
@@ -523,6 +534,19 @@ rstto_settings_class_init (GObjectClass *object_class)
object_class,
PROP_ERROR_MISSING_THUMBNAILER,
pspec);
+
+ pspec = g_param_spec_uint (
+ "sort-type",
+ "",
+ "",
+ 0,
+ SORT_TYPE_COUNT,
+ 0,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (
+ object_class,
+ PROP_SORT_TYPE,
+ pspec);
}
/**
@@ -682,6 +706,9 @@ rstto_settings_set_property (GObject *object,
case PROP_ERROR_MISSING_THUMBNAILER:
settings->priv->errors.missing_thumbnailer = g_value_get_boolean (value);
break;
+ case PROP_SORT_TYPE:
+ settings->priv->sort_type = g_value_get_uint ( value );
+ break;
default:
break;
}
@@ -757,6 +784,11 @@ rstto_settings_get_property (GObject *object,
value,
settings->priv->errors.missing_thumbnailer);
break;
+ case PROP_SORT_TYPE:
+ g_value_set_uint (
+ value,
+ settings->priv->sort_type);
+ break;
default:
break;
diff --git a/src/util.h b/src/util.h
index 71328b7..c8d76f9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -37,9 +37,16 @@ typedef enum
typedef enum {
DESKTOP_TYPE_NONE = 0,
DESKTOP_TYPE_XFCE,
- DESKTOP_TYPE_GNOME
+ DESKTOP_TYPE_GNOME,
+ DESKTOP_TYPE_COUNT
} RsttoDesktopType;
+typedef enum {
+ SORT_TYPE_NAME = 0,
+ SORT_TYPE_DATE,
+ SORT_TYPE_COUNT,
+} RsttoSortType;
+
gboolean
rstto_launch_help (void);
More information about the Xfce4-commits
mailing list