Author: post
Date: 2011-02-13 21:01:30 +0100 (Sun, 13 Feb 2011)
New Revision: 3815
Modified:
trunk/src/gtk-interface.c
trunk/src/gtk-interface.h
trunk/src/rs-actions.c
trunk/src/rs-store.c
trunk/src/rs-store.h
Log:
Better selection of next file when selecting next photo on deletion, and fix
fullscreen mode settings.
Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c 2011-02-06 18:02:43 UTC (rev 3814)
+++ trunk/src/gtk-interface.c 2011-02-13 20:01:30 UTC (rev 3815)
@@ -57,8 +57,7 @@
static gboolean open_photo(RS_BLOB *rs, const gchar *filename);
static void gui_preview_bg_color_changed(GtkColorButton *widget, RS_BLOB *rs);
-static gboolean gui_fullscreen_iconbox_callback(GtkWidget *widget,
GdkEventWindowState *event, GtkWidget *iconbox);
-static gboolean gui_fullscreen_toolbox_callback(GtkWidget *widget,
GdkEventWindowState *event, GtkWidget *toolbox);
+gboolean gui_fullscreen_changed_callback(GtkWidget *widget, gboolean
fullscreen, const gchar *conf_fullscreen_key, const gchar *conf_windowed_key);
//static void gui_preference_iconview_show_filenames_changed(GtkToggleButton
*togglebutton, gpointer user_data);
static GtkWidget *gui_make_menubar(RS_BLOB *rs);
static void drag_data_received(GtkWidget *widget, GdkDragContext
*drag_context, gint x, gint y, GtkSelectionData *selection_data, guint info,
guint t, RS_BLOB *rs);
@@ -282,7 +281,6 @@
gint i, num_selected;
GString *gs;
const gchar* next_name = NULL;
-
gui_set_busy(TRUE);
GTK_CATCHUP();
@@ -297,9 +295,13 @@
next_name = (const
gchar*)(g_list_last(selected_names)->data);
else if (rs->photo)
next_name = rs->photo->filename;
+
+ /* Load next image if deleting */
+ if (next_name)
+ next_name = rs_store_get_prevnext(rs->store, next_name,
2);
}
-
- /* Iterate throuh all selected thumbnails */
+
+/* Iterate throuh all selected thumbnails */
for(i=0;i<num_selected;i++)
{
rs_store_set_flags(rs->store, NULL, g_list_nth_data(selected,
i), &prio, NULL);
@@ -326,8 +328,8 @@
/* Load next image if deleting */
if (next_name)
- rs_store_select_prevnext(rs->store, next_name, 2);
-
+ rs_store_set_selected_name(rs->store, next_name, TRUE);
+
g_string_free(gs, TRUE);
gui_set_busy(FALSE);
}
@@ -354,51 +356,30 @@
return;
}
-static gboolean
-gui_fullscreen_iconbox_callback(GtkWidget *widget, GdkEventWindowState *event,
GtkWidget *iconbox)
+gboolean
+gui_fullscreen_changed(GtkWidget *widget, gboolean is_fullscreen, const gchar
*action,
+
gboolean default_fullscreen,
gboolean default_windowed,
+
const gchar
*conf_fullscreen_key, const gchar *conf_windowed_key)
{
- gboolean show_iconbox;
- if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
+ gboolean show_widget;
+ if (is_fullscreen)
{
- gboolean show_iconbox_default;
- rs_conf_get_boolean_with_default(CONF_SHOW_ICONBOX,
&show_iconbox_default, DEFAULT_CONF_SHOW_ICONBOX_FULLSCREEN);
- rs_conf_get_boolean_with_default(CONF_SHOW_ICONBOX_FULLSCREEN,
&show_iconbox, show_iconbox_default);
+ gboolean show_widget_default;
+ rs_conf_get_boolean_with_default(conf_windowed_key,
&show_widget_default, default_fullscreen);
+ rs_conf_get_boolean_with_default(conf_fullscreen_key,
&show_widget, show_widget_default);
fullscreen = TRUE;
- gui_widget_show(iconbox, show_iconbox,
CONF_SHOW_ICONBOX_FULLSCREEN, CONF_SHOW_ICONBOX);
+ gui_widget_show(widget, show_widget,
CONF_SHOW_ICONBOX_FULLSCREEN, CONF_SHOW_ICONBOX);
}
- if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN))
+ else
{
- rs_conf_get_boolean_with_default(CONF_SHOW_ICONBOX,
&show_iconbox, DEFAULT_CONF_SHOW_ICONBOX);
+ rs_conf_get_boolean_with_default(CONF_SHOW_ICONBOX,
&show_widget, default_windowed);
fullscreen = FALSE;
- gui_widget_show(iconbox, show_iconbox,
CONF_SHOW_ICONBOX_FULLSCREEN, CONF_SHOW_ICONBOX);
+ gui_widget_show(widget, show_widget,
CONF_SHOW_ICONBOX_FULLSCREEN, CONF_SHOW_ICONBOX);
}
-
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(rs_core_action_group_get_action("Iconbox"))
,show_iconbox);
+
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(rs_core_action_group_get_action(action))
,show_widget);
return(FALSE);
}
-static gboolean
-gui_fullscreen_toolbox_callback(GtkWidget *widget, GdkEventWindowState *event,
GtkWidget *toolbox)
-{
- gboolean show_toolbox;
- if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
- {
- fullscreen = TRUE;
- /* Retrieve defaults */
- gboolean show_toolbox_default;
- rs_conf_get_boolean_with_default(CONF_SHOW_TOOLBOX,
&show_toolbox_default, DEFAULT_CONF_SHOW_TOOLBOX_FULLSCREEN);
- /* Get actual state */
- rs_conf_get_boolean_with_default(CONF_SHOW_TOOLBOX_FULLSCREEN,
&show_toolbox, show_toolbox_default);
- gui_widget_show(toolbox, show_toolbox,
CONF_SHOW_TOOLBOX_FULLSCREEN, CONF_SHOW_TOOLBOX);
- }
- if (!(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN))
- {
- rs_conf_get_boolean_with_default(CONF_SHOW_TOOLBOX,
&show_toolbox, DEFAULT_CONF_SHOW_TOOLBOX);
- fullscreen = FALSE;
- gui_widget_show(toolbox, show_toolbox,
CONF_SHOW_TOOLBOX_FULLSCREEN, CONF_SHOW_TOOLBOX);
- }
-
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(rs_core_action_group_get_action("Toolbox"))
,show_toolbox);
- return(FALSE);
-}
static gboolean
gui_histogram_height_changed(GtkAdjustment *caller, RS_BLOB *rs)
@@ -1490,10 +1471,6 @@
gtk_misc_set_padding (GTK_MISC(infobox), 7,3);
rs_toolbox_add_widget(RS_TOOLBOX(rs->tools), infobox, NULL);
- /* Catch window state changes (un/fullscreen) */
- g_signal_connect((gpointer) rs->window, "window-state-event",
G_CALLBACK(gui_fullscreen_iconbox_callback), rs->iconbox);
- g_signal_connect((gpointer) rs->window, "window-state-event",
G_CALLBACK(gui_fullscreen_toolbox_callback), rs->toolbox);
-
/* Build menubar */
menubar = gui_make_menubar(rs);
Modified: trunk/src/gtk-interface.h
===================================================================
--- trunk/src/gtk-interface.h 2011-02-06 18:02:43 UTC (rev 3814)
+++ trunk/src/gtk-interface.h 2011-02-13 20:01:30 UTC (rev 3815)
@@ -38,6 +38,9 @@
extern int gui_init(int argc, char **argv, RS_BLOB *rs);
extern void gui_setprio(RS_BLOB *rs, guint prio);
extern void gui_widget_show(GtkWidget *widget, gboolean show, const gchar
*conf_fullscreen_key, const gchar *conf_windowed_key);
+extern gboolean gui_fullscreen_changed(GtkWidget *widget, gboolean
is_fullscreen, const gchar *action,
+
gboolean default_fullscreen,
gboolean default_windowed,
+
const gchar
*conf_fullscreen_key, const gchar *conf_windowed_key);
extern void gui_make_preference_window(RS_BLOB *rs);
extern void rs_window_set_title(const char *str);
extern void gui_select_preview_screen(RS_BLOB *rs);
Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c 2011-02-06 18:02:43 UTC (rev 3814)
+++ trunk/src/rs-actions.c 2011-02-13 20:01:30 UTC (rev 3815)
@@ -978,8 +978,15 @@
rs->window_fullscreen = FALSE;
gtk_window_unfullscreen(GTK_WINDOW(rs->window));
}
+ rs_conf_set_boolean(CONF_FULLSCREEN, rs->window_fullscreen);
- rs_conf_set_boolean(CONF_FULLSCREEN, rs->window_fullscreen);
+ /* Update Toolox and Iconbox */
+ gui_fullscreen_changed(rs->iconbox, rs->window_fullscreen, "Iconbox",
+
DEFAULT_CONF_SHOW_ICONBOX_FULLSCREEN,
DEFAULT_CONF_SHOW_ICONBOX,
+
CONF_SHOW_ICONBOX_FULLSCREEN, CONF_SHOW_ICONBOX);
+ gui_fullscreen_changed(rs->toolbox, rs->window_fullscreen, "Toolbox",
+
DEFAULT_CONF_SHOW_TOOLBOX_FULLSCREEN,
DEFAULT_CONF_SHOW_TOOLBOX,
+
CONF_SHOW_TOOLBOX_FULLSCREEN, CONF_SHOW_TOOLBOX);
rs_core_action_group_set_sensivity("Lightsout", !rs->window_fullscreen);
}
Modified: trunk/src/rs-store.c
===================================================================
--- trunk/src/rs-store.c 2011-02-06 18:02:43 UTC (rev 3814)
+++ trunk/src/rs-store.c 2011-02-13 20:01:30 UTC (rev 3815)
@@ -1484,6 +1484,13 @@
return FALSE;
}
+GtkIconView*
+rs_store_get_current_iconview(RSStore *store)
+{
+ g_return_val_if_fail(RS_IS_STORE(store), NULL);
+ return GTK_ICON_VIEW(store->current_iconview);
+}
+
/**
* Select a image
* @param store A RSStore
@@ -1513,12 +1520,9 @@
GtkTreePath *iconpath =
gtk_tree_model_filter_convert_child_path_to_path(GTK_TREE_MODEL_FILTER(model),
path);
gtk_tree_path_free(path);
- /* Scroll to the icon */
- if (deselect_others)
-
gtk_icon_view_scroll_to_path(GTK_ICON_VIEW(store->current_iconview), iconpath,
FALSE, 0.0, 0.0);
-
/* Select the icon */
gtk_icon_view_select_path(GTK_ICON_VIEW(store->current_iconview), iconpath);
+
gtk_icon_view_set_cursor(GTK_ICON_VIEW(store->current_iconview), iconpath,
NULL, FALSE);
/* Free the iconview path */
gtk_tree_path_free(iconpath);
@@ -1675,19 +1679,22 @@
}
/**
- * Selects the previous or next thumbnail
+ * Get the filename of the previous or next thumbnail
* @param store A RSStore
* @param current_filename Current filename or NULL if none
* @param direction 1: previous, 2: next
+ * @return filename of next or previous file, NULL if none.
*/
-gboolean
-rs_store_select_prevnext(RSStore *store, const gchar *current_filename, guint
direction)
+const gchar*
+rs_store_get_prevnext(RSStore *store, const gchar *current_filename, guint
direction)
{
gboolean ret = FALSE;
GList *selected;
GtkIconView *iconview;
GtkTreeIter iter;
GtkTreePath *path = NULL, *newpath = NULL;
+ gchar *new_name = NULL;
+ GtkTreeModel *model = gtk_icon_view_get_model
(GTK_ICON_VIEW(store->current_iconview));
g_assert(RS_IS_STORE(store));
@@ -1702,73 +1709,54 @@
newpath = gtk_tree_path_copy(path);
if (direction == 1) /* Previous */
{
- if (gtk_tree_path_prev(newpath))
- {
- gtk_icon_view_unselect_path(iconview, path);
- ret = TRUE;
- }
+ ret = gtk_tree_path_prev(newpath);
}
else /* Next */
{
gtk_tree_path_next(newpath);
- if (gtk_tree_model_get_iter(gtk_icon_view_get_model
(iconview), &iter, newpath))
- {
- gtk_icon_view_unselect_path(iconview, path);
- ret = TRUE;
- }
+ ret = gtk_tree_model_get_iter(gtk_icon_view_get_model
(iconview), &iter, newpath);
}
}
- else if (g_list_length(selected) == 0)
+ /* If we got a filename, try to select prev/next from that */
+ else if (current_filename)
{
/* Get current GtkTreeModelFilter */
- GtkTreeModel *model = gtk_icon_view_get_model
(GTK_ICON_VIEW(store->current_iconview));
-
- /* If we got a filename, try to select prev/next from that */
- if (current_filename)
+ if (tree_find_filename(GTK_TREE_MODEL(store->store),
current_filename, NULL, &newpath))
{
- if (tree_find_filename(GTK_TREE_MODEL(store->store),
current_filename, NULL, &newpath))
+ if ((path =
gtk_tree_model_filter_convert_child_path_to_path(GTK_TREE_MODEL_FILTER(model),
newpath)))
{
- while (!(path =
gtk_tree_model_filter_convert_child_path_to_path(GTK_TREE_MODEL_FILTER(model),
newpath)))
+ ret = TRUE;
+ if (direction == 1) /* Previous */
{
- ret = FALSE;
- if (direction == 1) /* Previous */
- {
- if
(!gtk_tree_path_prev(newpath))
- break;
- }
- else
- {
- gtk_tree_path_next(newpath);
- if
(!gtk_tree_model_get_iter(GTK_TREE_MODEL(store->store), &iter, newpath))
- break;
- }
- ret = TRUE;
+ if (!gtk_tree_path_prev(path))
+ ret = FALSE;
}
- if (newpath)
- gtk_tree_path_free(newpath);
- newpath = path;
+ else
+ {
+ gtk_tree_path_next(path);
+ if
(!gtk_tree_model_get_iter(GTK_TREE_MODEL(store->store), &iter, path))
+ ret = FALSE;
+ }
}
+ if (newpath)
+ gtk_tree_path_free(newpath);
+ newpath = path;
}
+ }
- /* If we got no hit, fall back to this */
- if (ret == FALSE)
- {
- /* If nothing is selected, select first thumbnail */
- newpath = gtk_tree_path_new_first();
- if (gtk_tree_model_get_iter(gtk_icon_view_get_model
(iconview), &iter, newpath))
- ret = TRUE;
- }
+ /* If we got no hit, fall back to this */
+ if (ret == FALSE)
+ {
+ /* If nothing is selected, select first thumbnail */
+ newpath = gtk_tree_path_new_first();
+ if (gtk_tree_model_get_iter(model, &iter, newpath))
+ ret = TRUE;
}
-
if (newpath && ret)
{
-#if GTK_CHECK_VERSION(2,8,0)
- /* Scroll to the new path */
- gtk_icon_view_scroll_to_path(iconview, newpath, FALSE, 0.5f,
0.5f);
-#endif
- gtk_icon_view_select_path(iconview, newpath);
- gtk_icon_view_set_cursor (iconview, newpath, NULL, FALSE);
- gtk_widget_grab_focus(GTK_WIDGET(iconview));
+ GtkTreeIter i;
+ if (gtk_tree_model_get_iter(model, &i, newpath))
+ gtk_tree_model_get(model, &i, FULLNAME_COLUMN,
&new_name, -1);
/* Free the new path */
gtk_tree_path_free(newpath);
}
@@ -1776,8 +1764,26 @@
/* Free list of selected */
g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected);
+ return new_name;
+
+}
- return ret;
+/**
+ * Selects the previous or next thumbnail
+ * @param store A RSStore
+ * @param current_filename Current filename or NULL if none
+ * @param direction 1: previous, 2: next
+ */
+gboolean
+rs_store_select_prevnext(RSStore *store, const gchar *current_filename, guint
direction)
+{
+ g_assert(RS_IS_STORE(store));
+ const gchar* new_name = rs_store_get_prevnext(store, current_filename,
direction);
+
+ if (new_name)
+ return rs_store_set_selected_name(store, new_name, TRUE);
+
+ return FALSE;
}
/**
Modified: trunk/src/rs-store.h
===================================================================
--- trunk/src/rs-store.h 2011-02-06 18:02:43 UTC (rev 3814)
+++ trunk/src/rs-store.h 2011-02-13 20:01:30 UTC (rev 3815)
@@ -161,6 +161,16 @@
rs_store_get_name(RSStore *store, GtkTreeIter *iter);
/**
+ * Get the filename of the previous or next thumbnail
+ * @param store A RSStore
+ * @param current_filename Current filename or NULL if none
+ * @param direction 1: previous, 2: next
+ * @return filename of next or previous file, NULL if none.
+ */
+const gchar*
+rs_store_get_prevnext(RSStore *store, const gchar *current_filename, guint
direction);
+
+/**
* Selects the previous or next thumbnail
* @param store A RSStore
* @param current_filename Current filename or NULL if none
@@ -263,4 +273,7 @@
extern gboolean
rs_store_is_photo_selected(RSStore *store, const gchar *filename);
+extern GtkIconView*
+rs_store_get_current_iconview(RSStore *store);
+
#endif /* RS_STORE_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit