New function (verb_SlideShow_cb): Register for hide signal of the

2003-11-24  Jens Finke  <jens@triq.net>

	* collection/eog-collection-view.c (slideshow_hide_cb): New function
	(verb_SlideShow_cb): Register for hide signal of the fullscreen widget.

	* collection/eog-wrap-list.c (eog_wrap_list_set_current_image):
	New function.

	* libeog/eog-full-screen.[ch] (eog_full_screen_hide): Don't
	destroy widget.
	(prepare_data): Set current iter also in the single image case.
	(eog_full_screen_get_last_image): New public function.

	* libeog/eog-image-list.c (eog_image_list_iter_valid): Check for iter != NULL.

	* viewer/eog-image-view.c (verb_FullScreen_cb): Destroy fullscreen
	widget on hide signal.
This commit is contained in:
Jens Finke 2003-11-24 17:28:00 +00:00 committed by Jens Finke
parent b8b034a41e
commit 937feae0b6
8 changed files with 128 additions and 13 deletions

View file

@ -1,3 +1,21 @@
2003-11-24 Jens Finke <jens@triq.net>
* collection/eog-collection-view.c (slideshow_hide_cb): New function
(verb_SlideShow_cb): Register for hide signal of the fullscreen widget.
* collection/eog-wrap-list.c (eog_wrap_list_set_current_image):
New function.
* libeog/eog-full-screen.[ch] (eog_full_screen_hide): Don't
destroy widget.
(prepare_data): Set current iter also in the single image case.
(eog_full_screen_get_last_image): New public function.
* libeog/eog-image-list.c (eog_image_list_iter_valid): Check for iter != NULL.
* viewer/eog-image-view.c (verb_FullScreen_cb): Destroy fullscreen
widget on hide signal.
===== 2.5.0.1 ====
2003-11-10 Jens Finke <jens@triq.net>

View file

@ -114,6 +114,8 @@ enum {
LAST_SIGNAL
};
static void handle_selection_changed (EogWrapList *list, EogCollectionView *view);
static guint eog_collection_view_signals [LAST_SIGNAL];
BONOBO_CLASS_BOILERPLATE (EogCollectionView, eog_collection_view,
@ -130,6 +132,34 @@ free_image_list (GList *list)
g_list_free (list);
}
static void
slideshow_hide_cb (GtkWidget *widget, gpointer data)
{
EogImage *last_image;
EogFullScreen *fs;
EogCollectionView *view;
EogCollectionViewPrivate *priv;
fs = EOG_FULL_SCREEN (widget);
view = EOG_COLLECTION_VIEW (data);
priv = view->priv;
last_image = eog_full_screen_get_last_image (fs);
if (last_image != NULL) {
g_signal_handlers_block_by_func(G_OBJECT (priv->wraplist),
G_CALLBACK (handle_selection_changed), view);
eog_wrap_list_set_current_image (EOG_WRAP_LIST (priv->wraplist), last_image, FALSE);
eog_scroll_view_set_image (EOG_SCROLL_VIEW (priv->scroll_view), last_image);
g_signal_handlers_unblock_by_func(G_OBJECT (priv->wraplist),
G_CALLBACK (handle_selection_changed), view);
g_object_unref (last_image);
}
gtk_widget_destroy (widget);
}
static void
verb_SlideShow_cb (BonoboUIComponent *uic,
@ -157,6 +187,8 @@ verb_SlideShow_cb (BonoboUIComponent *uic,
start_image = eog_wrap_list_get_first_selected_image (EOG_WRAP_LIST (view->priv->wraplist));
show = eog_full_screen_new (list, start_image);
g_signal_connect (G_OBJECT (show), "hide", G_CALLBACK (slideshow_hide_cb), view);
g_object_unref (start_image);
g_object_unref (list);

View file

@ -1269,3 +1269,45 @@ eog_wrap_list_get_selected_images (EogWrapList *wlist)
return list;
}
/* eog_wrap_list_set_current_image
*
* This function makes sure that the corresponding item to image is in
* the list of selected items. Also it is marked as the last clicked
* item. If the flag deselect_other is TRUE than all other selected
* item will be deselected.
*/
void
eog_wrap_list_set_current_image (EogWrapList *wlist, EogImage *image, gboolean deselect_other)
{
EogWrapListPrivate *priv;
EogCollectionItem *item;
gboolean selection_changed = FALSE;
int pos;
g_return_if_fail (EOG_IS_WRAP_LIST (wlist));
g_return_if_fail (EOG_IS_IMAGE (image));
priv = wlist->priv;
/* Warning: We rely on the fact that the model list and the
view_order list are totally in sync wrt to the
sequence. AFAICS this is a valid assumption currently. */
pos = eog_image_list_get_pos_by_img (priv->model, image);
if (pos == -1) return;
item = g_list_nth_data (priv->view_order, pos);
priv->last_item_clicked = GNOME_CANVAS_ITEM (item);
if (deselect_other || (priv->n_selected_items == 1)) {
deselect_all (wlist);
}
selection_changed = set_select_status (wlist, item, TRUE);
if (selection_changed) {
g_signal_emit (G_OBJECT (wlist), eog_wrap_list_signals [SELECTION_CHANGED], 0);
}
ensure_item_is_visible (wlist, GNOME_CANVAS_ITEM (item));
}

View file

@ -72,6 +72,7 @@ GList* eog_wrap_list_get_selected_images (EogWrapList *wlist);
void eog_wrap_list_select_left (EogWrapList *wlist);
void eog_wrap_list_select_right (EogWrapList *wlist);
void eog_wrap_list_set_current_image (EogWrapList *wlist, EogImage *image, gboolean deselect_other);

View file

@ -217,8 +217,6 @@ eog_full_screen_hide (GtkWidget *widget)
}
GNOME_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget));
gtk_widget_destroy (widget);
}
static void
@ -571,22 +569,23 @@ prepare_data (EogFullScreen *fs, EogImageList *image_list, EogImage *start_image
priv->list = g_object_ref (image_list);
priv->current = NULL;
/* determine first image to show */
if (start_image != NULL)
priv->current = eog_image_list_get_iter_by_img (image_list, start_image);
if (priv->current == NULL)
priv->current = eog_image_list_get_first_iter (image_list);
/* special case if we only have one image */
if (eog_image_list_length (image_list) == 1) {
EogImage *single_image;
single_image = eog_image_list_get_img_by_pos (image_list, 0);
single_image = eog_image_list_get_img_by_iter (image_list, priv->current);
eog_scroll_view_set_image (EOG_SCROLL_VIEW (priv->view),
single_image);
g_object_unref (single_image);
}
else {
/* determine first image to show */
priv->direction = EOG_DIRECTION_FORWARD;
if (start_image != NULL)
priv->current = eog_image_list_get_iter_by_img (image_list, start_image);
if (priv->current == NULL)
priv->current = eog_image_list_get_first_iter (image_list);
priv->first_iter = eog_image_list_iter_copy (image_list, priv->current);
priv->first_image = TRUE;
prepare_load_image (fs, priv->current);
@ -653,3 +652,18 @@ eog_full_screen_enable_SunF36 (void)
{
return (XKeysymToKeycode (GDK_DISPLAY (), SunXK_F36) != 0);
}
EogImage*
eog_full_screen_get_last_image (EogFullScreen *fs)
{
EogFullScreenPrivate *priv;
EogImage *image;
g_return_val_if_fail (EOG_IS_FULL_SCREEN (fs), NULL);
priv = fs->priv;
image = eog_image_list_get_img_by_iter (priv->list, priv->current);
return image;
}

View file

@ -63,6 +63,8 @@ GtkWidget *eog_full_screen_new (EogImageList *list, EogImage *start_image);
gboolean eog_full_screen_enable_SunF36 (void);
EogImage* eog_full_screen_get_last_image (EogFullScreen *fs);
G_END_DECLS
#endif /* _EOG_FULL_SCREEN_H_ */

View file

@ -638,9 +638,13 @@ gboolean
eog_image_list_iter_valid (EogImageList *list, EogIter *iter)
{
g_return_val_if_fail (EOG_IS_IMAGE_LIST (list), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
return eog_iter_is_valid_private (list, iter);
if (iter == NULL) {
return FALSE;
}
else {
return eog_iter_is_valid_private (list, iter);
}
}
/* Points the iter to the previous position in the list. If loop is

View file

@ -184,6 +184,8 @@ verb_FullScreen_cb (BonoboUIComponent *uic, gpointer data, const char *name)
list = eog_image_list_new ();
eog_image_list_add_image (list, EOG_IMAGE (image_view->priv->image));
fs = eog_full_screen_new (list, NULL);
g_signal_connect (G_OBJECT (fs), "hide", G_CALLBACK (gtk_widget_destroy), NULL);
g_object_unref (list);
gtk_widget_show_all (fs);