[gthumb] [desktop_background] added ability to reset or open the preferences



commit 1d72ac04ee3dfc1b073ccd08a4ee26cdf6671017
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jul 21 19:46:11 2010 +0200

    [desktop_background] added ability to reset or open the preferences
    
    after setting a desktop background an info-bar is displayd at the
    bottom of the window to allow the user to reset the previous
    background or to open the background preferences.

 extensions/desktop_background/Makefile.am          |    2 +-
 extensions/desktop_background/actions.c            |  261 +++++++++++++++++++-
 .../desktop_background.extension.in.in             |    1 +
 gthumb/Makefile.am                                 |    4 +
 gthumb/gth-browser.c                               |   28 ++
 gthumb/gth-browser.h                               |    1 +
 gthumb/gth-info-bar.c                              |  223 +++++++++++++++++
 gthumb/gth-info-bar.h                              |   68 +++++
 gthumb/gth-window.c                                |   13 +-
 gthumb/gth-window.h                                |    1 +
 gthumb/gtk-utils.c                                 |    7 +
 gthumb/gtk-utils.h                                 |    6 +-
 po/POTFILES.in                                     |    7 +-
 13 files changed, 603 insertions(+), 19 deletions(-)
---
diff --git a/extensions/desktop_background/Makefile.am b/extensions/desktop_background/Makefile.am
index 8c8e00b..a3e4a67 100644
--- a/extensions/desktop_background/Makefile.am
+++ b/extensions/desktop_background/Makefile.am
@@ -11,7 +11,7 @@ libdesktop_background_la_SOURCES = 	\
 
 libdesktop_background_la_CFLAGS = $(GTHUMB_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libdesktop_background_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libdesktop_background_la_LIBADD = $(GTHUMB_LIBS) 
+libdesktop_background_la_LIBADD = $(GTHUMB_LIBS)  ../image_viewer/libimage_viewer.la
 libdesktop_background_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
index 5a165f4..72c83e6 100644
--- a/extensions/desktop_background/actions.c
+++ b/extensions/desktop_background/actions.c
@@ -24,21 +24,248 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include <gthumb.h>
+#include <extensions/image_viewer/gth-image-viewer-page.h>
+
+
+typedef struct {
+	GthBrowser *browser;
+	GFile      *old_file;
+	GFile      *new_file;
+	gulong      response_id;
+} WallpaperData;
+
+
+static GFile *
+get_wallpaper_file_n (int n)
+{
+	char  *name;
+	char  *filename;
+	GFile *file;
+
+	name = g_strdup_printf ("wallpaper%d.jpeg", n);
+	gth_user_dir_make_dir_for_file (GTH_DIR_DATA, GTHUMB_DIR, name, NULL);
+	filename = gth_user_dir_get_file (GTH_DIR_DATA, GTHUMB_DIR, name, NULL);
+	file = g_file_new_for_path (filename);
+
+	g_free (filename);
+	g_free (name);
+
+	return file;
+}
+
+
+static GFile *
+get_wallpaper_file (void)
+{
+	GFile *wallpaper_file;
+
+	wallpaper_file = get_wallpaper_file_n (1);
+	if (g_file_query_exists (wallpaper_file, NULL)) {
+		/* Use a new filename to force an update. */
+
+		g_object_unref (wallpaper_file);
+
+		wallpaper_file = get_wallpaper_file_n (2);
+		if (g_file_query_exists (wallpaper_file, NULL))
+			g_file_delete (wallpaper_file, NULL, NULL);
+	}
+
+	return 	wallpaper_file;
+}
+
+
+static WallpaperData *
+wallpaper_data_new (GthBrowser *browser)
+{
+	WallpaperData *wdata;
+	char          *path;
+
+	wdata = g_new0 (WallpaperData, 1);
+	wdata->browser = browser;
+
+	path = eel_gconf_get_string ("/desktop/gnome/background/picture_filename", NULL);
+	if (path != NULL) {
+		wdata->old_file = g_file_new_for_path (path);
+		g_free (path);
+	}
+
+	wdata->new_file = get_wallpaper_file ();
+
+	return wdata;
+}
+
+
+static void
+wallpaper_data_free (WallpaperData *wdata)
+{
+	g_signal_handler_disconnect (gth_browser_get_infobar (wdata->browser), wdata->response_id);
+	_g_object_unref (wdata->old_file);
+	_g_object_unref (wdata->new_file);
+	g_free (wdata);
+}
+
+
+enum {
+	_RESPONSE_PREFERENCES = 1,
+	_RESPONSE_UNDO
+};
+
+
+static void
+set_wallpaper_file (GFile *file)
+{
+	char *path;
+
+	path = g_file_get_path (file);
+	if (path != NULL)
+		eel_gconf_set_string ("/desktop/gnome/background/picture_filename", path);
+
+	g_free (path);
+}
+
+
+static void
+infobar_response_cb (GtkInfoBar *info_bar,
+		     int         response_id,
+		     gpointer    user_data)
+{
+	WallpaperData *wdata = user_data;
+	GError        *error = NULL;
+
+	g_return_if_fail (GTH_IS_BROWSER (wdata->browser));
+
+	switch (response_id) {
+	case _RESPONSE_PREFERENCES:
+		if (! g_spawn_command_line_async ("gnome-appearance-properties --show-page=background", &error))
+			_gtk_error_dialog_from_gerror_run (GTK_WINDOW (wdata->browser), _("Could not show the desktop background properties"), &error);
+		break;
+
+	case _RESPONSE_UNDO:
+		if (wdata->old_file != NULL)
+			set_wallpaper_file (wdata->old_file);
+		break;
+	}
+
+	gtk_widget_hide (GTK_WIDGET (info_bar));
+	wallpaper_data_free (wdata);
+}
+
+
+static void
+wallpaper_data_set (WallpaperData *wdata)
+{
+	GtkWidget *infobar;
+
+	set_wallpaper_file (wdata->new_file);
+
+	infobar = gth_browser_get_infobar (wdata->browser);
+	gth_info_bar_set_icon (GTH_INFO_BAR (infobar), GTK_STOCK_DIALOG_INFO);
+
+	{
+		char *name;
+		char *msg;
+
+		name = _g_file_get_display_name (wdata->new_file);
+		msg = g_strdup_printf ("The image \"%s\" has been set as desktop background", name);
+		gth_info_bar_set_primary_text (GTH_INFO_BAR (infobar), msg);
+
+		g_free (msg);
+		g_free (name);
+	}
+
+	_gtk_info_bar_clear_action_area (GTK_INFO_BAR (infobar));
+	gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_info_bar_get_action_area (GTK_INFO_BAR (infobar))), GTK_ORIENTATION_HORIZONTAL);
+	gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
+	gtk_info_bar_add_buttons (GTK_INFO_BAR (infobar),
+				  GTK_STOCK_PREFERENCES, _RESPONSE_PREFERENCES,
+				  GTK_STOCK_UNDO, _RESPONSE_UNDO,
+				  GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+				  NULL);
+	gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (infobar),
+					     _RESPONSE_UNDO,
+					     wdata->old_file != NULL);
+	wdata->response_id = g_signal_connect (infobar,
+			  	  	       "response",
+			  	  	       G_CALLBACK (infobar_response_cb),
+			  	  	       wdata);
+
+	gtk_widget_show (infobar);
+}
+
+
+static void
+wallpaper_save_ready_cb (GthFileData *a,
+			 GError      *error,
+			 gpointer     user_data)
+{
+	WallpaperData *wdata = user_data;
+
+	if (error != NULL) {
+		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (wdata->browser), _("Could not set the desktop background"), &error);
+		wallpaper_data_free (wdata);
+		return;
+	}
+
+	wallpaper_data_set (wdata);
+}
+
+
+static void
+copy_wallpaper_ready_cb (GObject      *source_object,
+			 GAsyncResult *res,
+			 gpointer      user_data)
+{
+	WallpaperData *wdata = user_data;
+	GError        *error = NULL;
+
+	if (! g_file_copy_finish (G_FILE (source_object), res, &error)) {
+		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (wdata->browser), _("Could not set the desktop background"), &error);
+		wallpaper_data_free (wdata);
+		return;
+	}
+
+	wallpaper_data_set (wdata);
+}
 
 
 void
 gth_browser_activate_action_tool_desktop_background (GtkAction  *action,
 					             GthBrowser *browser)
 {
-	GList       *items;
-	GList       *file_list;
-	GthFileData *file_data;
-	char        *path;
-	GError      *error = NULL;
+	WallpaperData *wdata;
+	gboolean       saving_wallpaper = FALSE;
+	GthFileData   *file_data;
+	GList         *items;
+	GList         *file_list;
+
+	wdata = wallpaper_data_new (browser);
+
+	if (gth_main_extension_is_active ("image_viewer") && gth_browser_get_file_modified (browser)) {
+		GtkWidget *viewer_page;
+
+		viewer_page = gth_browser_get_viewer_page (browser);
+		if (viewer_page != NULL) {
+			GdkPixbuf *pixbuf;
+
+			pixbuf = g_object_ref (gth_image_viewer_page_get_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page)));
+			file_data = gth_file_data_new (wdata->new_file, NULL);
+			_gdk_pixbuf_save_async (pixbuf,
+						file_data,
+						"image/jpeg",
+						TRUE,
+						wallpaper_save_ready_cb,
+						wdata);
+			saving_wallpaper = TRUE;
+
+			g_object_unref (pixbuf);
+		}
+	}
+
+	if (saving_wallpaper)
+		return;
 
 	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
 	file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
-
 	if (file_list == NULL)
 		return;
 
@@ -46,14 +273,22 @@ gth_browser_activate_action_tool_desktop_background (GtkAction  *action,
 	if (file_data == NULL)
 		return;
 
-	path = g_file_get_path (file_data->file);
-	if (path != NULL)
-		eel_gconf_set_string ("/desktop/gnome/background/picture_filename", path);
+	if (g_file_is_native (file_data->file)) {
+		_g_object_unref (wdata->new_file);
+		wdata->new_file = g_file_dup (file_data->file);
+		wallpaper_data_set (wdata);
+	}
+	else
+		g_file_copy_async (file_data->file,
+				   wdata->new_file,
+				   G_FILE_COPY_OVERWRITE,
+				   G_PRIORITY_DEFAULT,
+				   NULL,
+				   NULL,
+				   NULL,
+				   copy_wallpaper_ready_cb,
+				   wdata);
 
-	if (! g_spawn_command_line_async ("gnome-appearance-properties --show-page=background", &error))
-		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), _("Could not show the desktop background properties"), &error);
-
-	g_free (path);
 	_g_object_list_unref (file_list);
 	_gtk_tree_path_list_free (items);
 }
diff --git a/extensions/desktop_background/desktop_background.extension.in.in b/extensions/desktop_background/desktop_background.extension.in.in
index d520d4d..3fef5d3 100644
--- a/extensions/desktop_background/desktop_background.extension.in.in
+++ b/extensions/desktop_background/desktop_background.extension.in.in
@@ -10,3 +10,4 @@ Category=List-Tool
 [Loader]
 Type=module
 File=%LIBRARY%
+After=image_viewer
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index 67c0b30..67ab85b 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -73,6 +73,7 @@ PUBLIC_HEADER_FILES = 					\
 	gth-image-selector.h				\
 	gth-image-viewer.h				\
 	gth-image-viewer-tool.h				\
+	gth-info-bar.h					\
 	gth-location-chooser.h				\
 	gth-main.h					\
 	gth-metadata.h					\
@@ -130,6 +131,7 @@ PRIVATE_HEADER_FILES = 					\
 	dlg-sort-order.h				\
 	gth-window-actions-callbacks.h			\
 	gth-window-actions-entries.h			\
+	main-migrate.h					\
 	$(NULL)
 
 gthumb_SOURCES = 					\
@@ -186,6 +188,7 @@ gthumb_SOURCES = 					\
 	gth-image-selector.c				\
 	gth-image-viewer.c				\
 	gth-image-viewer-tool.c				\
+	gth-info-bar.c					\
 	gth-location-chooser.c				\
 	gth-main.c					\
 	gth-main-default-hooks.c			\
@@ -231,6 +234,7 @@ gthumb_SOURCES = 					\
 	gtk-utils.c					\
 	gvaluehash.c					\
 	main.c						\
+	main-migrate-catalogs.c				\
 	pixbuf-cache.c					\
 	pixbuf-io.c					\
 	pixbuf-utils.c					\
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 24e5933..8a719d9 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -42,6 +42,7 @@
 #include "gth-filterbar.h"
 #include "gth-folder-tree.h"
 #include "gth-icon-cache.h"
+#include "gth-info-bar.h"
 #include "gth-image-preloader.h"
 #include "gth-location-chooser.h"
 #include "gth-main.h"
@@ -87,6 +88,7 @@ struct _GthBrowserPrivateData {
 
 	GtkUIManager      *ui;
 	GtkActionGroup    *actions;
+	GtkWidget         *infobar;
 	GtkWidget         *statusbar;
 	GtkWidget         *browser_toolbar;
 	GtkWidget         *browser_container;
@@ -1704,6 +1706,14 @@ mount_volume_ready_cb (GObject      *source_object,
 
 
 static void
+_gth_browser_hide_infobar (GthBrowser *browser)
+{
+	if (gtk_widget_get_visible (browser->priv->infobar))
+		gtk_info_bar_response (GTK_INFO_BAR (browser->priv->infobar), GTK_RESPONSE_CLOSE);
+}
+
+
+static void
 _gth_browser_load (GthBrowser *browser,
 		   GFile      *location,
 		   GFile      *scroll_to_file,
@@ -1713,6 +1723,9 @@ _gth_browser_load (GthBrowser *browser,
 	LoadData *load_data;
 	GFile    *entry_point;
 
+	if (! automatic)
+		_gth_browser_hide_infobar (browser);
+
 	switch (action) {
 	case GTH_ACTION_GO_TO:
 	case GTH_ACTION_GO_INTO:
@@ -2157,6 +2170,7 @@ _gth_browser_real_set_current_page (GthWindow *window,
 		gtk_widget_grab_focus (gth_browser_get_file_list_view (browser));
 	else if (page == GTH_BROWSER_PAGE_VIEWER)
 		_gth_browser_make_file_visible (browser, browser->priv->current_file);
+	_gth_browser_hide_infobar (browser);
 
 	gth_hook_invoke ("gth-browser-set-current-page", browser);
 
@@ -3902,6 +3916,11 @@ _gth_browser_construct (GthBrowser *browser)
 	gth_window_attach_toolbar (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER, browser->priv->browser_toolbar);
 	add_browser_toolbar_menu_buttons (browser);
 
+	/* infobar */
+
+	browser->priv->infobar = gth_info_bar_new (NULL, NULL, NULL);
+	gth_window_attach (GTH_WINDOW (browser), browser->priv->infobar, GTH_WINDOW_INFOBAR);
+
 	/* statusbar */
 
 	browser->priv->statusbar = gth_statusbar_new ();
@@ -4396,6 +4415,13 @@ gth_browser_get_browser_toolbar (GthBrowser *browser)
 
 
 GtkWidget *
+gth_browser_get_infobar (GthBrowser *browser)
+{
+	return browser->priv->infobar;
+}
+
+
+GtkWidget *
 gth_browser_get_statusbar (GthBrowser *browser)
 {
 	return browser->priv->statusbar;
@@ -5209,6 +5235,8 @@ gth_browser_load_file (GthBrowser  *browser,
 {
 	LoadFileData *data;
 
+	_gth_browser_hide_infobar (browser);
+
 	data = load_file_data_new (browser, file_data, view);
 
 	if (browser->priv->load_file_timeout != 0) {
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 81cae90..4159c12 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -102,6 +102,7 @@ GtkWidget *      gth_browser_get_dialog             (GthBrowser       *browser,
 GtkUIManager *   gth_browser_get_ui_manager         (GthBrowser       *browser);
 GthIconCache *   gth_browser_get_menu_icon_cache    (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_browser_toolbar    (GthBrowser       *browser);
+GtkWidget *      gth_browser_get_infobar            (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_statusbar          (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_file_list          (GthBrowser       *browser);
 GtkWidget *      gth_browser_get_file_list_view     (GthBrowser       *browser);
diff --git a/gthumb/gth-info-bar.c b/gthumb/gth-info-bar.c
new file mode 100644
index 0000000..8490698
--- /dev/null
+++ b/gthumb/gth-info-bar.c
@@ -0,0 +1,223 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2009 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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include "gth-info-bar.h"
+
+
+static gpointer parent_class = NULL;
+
+
+struct _GthInfoBarPrivate {
+	GtkWidget *icon_image;
+	GtkWidget *primary_text_label;
+	GtkWidget *secondary_text_label;
+};
+
+
+static void
+gth_info_bar_class_init (GthInfoBarClass *klass)
+{
+	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (klass, sizeof (GthInfoBarPrivate));
+}
+
+
+static void
+gth_info_bar_init (GthInfoBar *self)
+{
+	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_INFO_BAR, GthInfoBarPrivate);
+}
+
+
+GType
+gth_info_bar_get_type (void)
+{
+        static GType type = 0;
+
+        if (! type) {
+                GTypeInfo type_info = {
+			sizeof (GthInfoBarClass),
+			NULL,
+			NULL,
+			(GClassInitFunc) gth_info_bar_class_init,
+			NULL,
+			NULL,
+			sizeof (GthInfoBar),
+			0,
+			(GInstanceInitFunc) gth_info_bar_init
+		};
+
+		type = g_type_register_static (GTK_TYPE_INFO_BAR,
+					       "GthEmbeddedEditorDialog",
+					       &type_info,
+					       0);
+	}
+
+        return type;
+}
+
+
+static void
+gth_info_bar_construct (GthInfoBar *self)
+{
+	GtkWidget *hbox_content;
+	GtkWidget *image;
+	GtkWidget *vbox;
+	GtkWidget *primary_label;
+	GtkWidget *secondary_label;
+	GtkWidget *area;
+	
+	hbox_content = gtk_hbox_new (FALSE, 8);
+	gtk_widget_show (hbox_content);
+
+	self->priv->icon_image = image = gtk_image_new ();
+	gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
+	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.5);
+
+	vbox = gtk_vbox_new (FALSE, 6);
+	gtk_widget_show (vbox);
+	gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
+
+	self->priv->primary_text_label = primary_label = gtk_label_new (NULL);
+	gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
+	GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS);
+	gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+	gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+	gtk_misc_set_padding (GTK_MISC (primary_label), 0, 0);
+	gtk_label_set_ellipsize (GTK_LABEL (primary_label), PANGO_ELLIPSIZE_MIDDLE);
+	gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5);
+	gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+	
+	self->priv->secondary_text_label = secondary_label = gtk_label_new (NULL);
+	gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
+	GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS);
+	gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
+	gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
+	gtk_misc_set_padding (GTK_MISC (secondary_label), 0, 0);
+	gtk_label_set_ellipsize (GTK_LABEL (secondary_label), PANGO_ELLIPSIZE_END);
+	gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
+	gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
+	
+	area = gtk_info_bar_get_action_area (GTK_INFO_BAR (self));
+	gtk_container_set_border_width (GTK_CONTAINER (self), 0);
+	gtk_box_set_homogeneous (GTK_BOX (area), FALSE);
+	gtk_orientable_set_orientation (GTK_ORIENTABLE (area), GTK_ORIENTATION_HORIZONTAL);
+
+	area = gtk_info_bar_get_content_area (GTK_INFO_BAR (self));
+	gtk_container_set_border_width (GTK_CONTAINER (self), 0);
+	gtk_container_add (GTK_CONTAINER (area), hbox_content);
+
+	gtk_widget_set_name (GTK_WIDGET (self), "GthInfoBar");
+	gtk_info_bar_set_message_type (GTK_INFO_BAR (self), GTK_MESSAGE_OTHER);
+	gtk_container_set_border_width (GTK_CONTAINER (self), 0);
+}
+
+
+GtkWidget *
+gth_info_bar_new (const char *icon_stock_id,
+		  const char *primary_text,
+		  const char *secondary_text)
+{
+	GthInfoBar *self;
+
+	self = g_object_new (GTH_TYPE_INFO_BAR, NULL);
+	gth_info_bar_construct (self);
+	gth_info_bar_set_icon (self, icon_stock_id);
+	gth_info_bar_set_primary_text (self, primary_text);
+	gth_info_bar_set_secondary_text (self, secondary_text);
+	
+	return (GtkWidget *) self;
+}
+
+
+void
+gth_info_bar_set_icon (GthInfoBar *self,
+		       const char *icon_stock_id)
+{
+	if (icon_stock_id == NULL) {
+		gtk_widget_hide (self->priv->icon_image);
+		return;
+	}
+
+	gtk_image_set_from_stock (GTK_IMAGE (self->priv->icon_image), icon_stock_id, GTK_ICON_SIZE_BUTTON);
+	gtk_widget_show (self->priv->icon_image);
+}
+
+
+void
+gth_info_bar_set_gicon (GthInfoBar *self,
+			GIcon      *icon)
+{
+	if (icon == NULL) {
+		gtk_widget_hide (self->priv->icon_image);
+		return;
+	}
+
+	gtk_image_set_from_gicon (GTK_IMAGE (self->priv->icon_image), icon, GTK_ICON_SIZE_BUTTON);
+	gtk_widget_show (self->priv->icon_image);
+}
+
+
+void
+gth_info_bar_set_primary_text (GthInfoBar *self,
+			       const char *text)
+{
+	char *escaped;
+	char *markup;
+
+	if (text == NULL) {
+		gtk_widget_hide (self->priv->primary_text_label);
+		return;
+	}
+	
+	escaped = g_markup_escape_text (text, -1);
+	markup = g_strdup_printf ("<b>%s</b>", escaped);
+	gtk_label_set_markup (GTK_LABEL (self->priv->primary_text_label), markup);
+	gtk_widget_show (self->priv->primary_text_label);
+	
+	g_free (markup);
+	g_free (escaped);
+}
+
+
+void
+gth_info_bar_set_secondary_text (GthInfoBar *self,
+				 const char *text)
+{
+	char *escaped;
+	char *markup;
+
+	if (text == NULL) {
+		gtk_widget_hide (self->priv->secondary_text_label);
+		return;
+	}
+	
+	escaped = g_markup_escape_text (text, -1);
+	markup = g_strdup_printf ("<small>%s</small>", escaped);
+	gtk_label_set_markup (GTK_LABEL (self->priv->secondary_text_label), markup);
+	gtk_widget_show (self->priv->secondary_text_label);
+	
+	g_free (markup);
+	g_free (escaped);
+}
diff --git a/gthumb/gth-info-bar.h b/gthumb/gth-info-bar.h
new file mode 100644
index 0000000..f578b7f
--- /dev/null
+++ b/gthumb/gth-info-bar.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2009 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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GTH_INFO_BAR_H
+#define GTH_INFO_BAR_H
+
+#include <gtk/gtk.h>
+#include "gedit-message-area.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_INFO_BAR         (gth_info_bar_get_type ())
+#define GTH_INFO_BAR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTH_TYPE_INFO_BAR, GthInfoBar))
+#define GTH_INFO_BAR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GTH_TYPE_INFO_BAR, GthInfoBarClass))
+#define GTH_IS_INFO_BAR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTH_TYPE_INFO_BAR))
+#define GTH_IS_INFO_BAR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GTH_TYPE_INFO_BAR))
+#define GTH_INFO_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GTH_TYPE_INFO_BAR, GthInfoBarClass))
+
+typedef struct _GthInfoBar         GthInfoBar;
+typedef struct _GthInfoBarPrivate  GthInfoBarPrivate;
+typedef struct _GthInfoBarClass    GthInfoBarClass;
+
+struct _GthInfoBar
+{
+	GtkInfoBar __parent;
+	GthInfoBarPrivate *priv;
+};
+
+struct _GthInfoBarClass
+{
+	GtkInfoBarClass __parent_class;
+};
+
+GType         gth_info_bar_get_type           (void) G_GNUC_CONST;
+GtkWidget *   gth_info_bar_new                (const char *icon_stock_id,
+					       const char *primary_text,
+					       const char *secondary_text);
+void          gth_info_bar_set_icon           (GthInfoBar *dialog,
+					       const char *icon_stock_id);
+void          gth_info_bar_set_gicon          (GthInfoBar *dialog,
+					       GIcon      *icon);
+void          gth_info_bar_set_primary_text   (GthInfoBar *dialog,
+					       const char *primary_text);
+void          gth_info_bar_set_secondary_text (GthInfoBar *dialog,
+					       const char *secondary_text);
+
+G_END_DECLS
+
+#endif /* GTH_INFO_BAR_H */
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index c6965f1..dd9570b 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -45,6 +45,7 @@ struct _GthWindowPrivate {
 	GtkWidget  *notebook;
 	GtkWidget  *menubar;
 	GtkWidget  *toolbar;
+	GtkWidget  *infobar;
 	GtkWidget  *statusbar;
 	GtkWidget **toolbars;
 	GtkWidget **contents;
@@ -59,7 +60,7 @@ gth_window_set_n_pages (GthWindow *self,
 
 	self->priv->n_pages = n_pages;
 
-	self->priv->table = gtk_table_new (4, 1, FALSE);
+	self->priv->table = gtk_table_new (5, 1, FALSE);
 	gtk_table_set_row_spacings (GTK_TABLE (self->priv->table), 0);
 	gtk_table_set_col_spacings (GTK_TABLE (self->priv->table), 0);
 	gtk_widget_show (self->priv->table);
@@ -206,6 +207,7 @@ gth_window_init (GthWindow *window)
 	window->priv->current_page = -1;
 	window->priv->menubar = NULL;
 	window->priv->toolbar = NULL;
+	window->priv->infobar = NULL;
 	window->priv->statusbar = NULL;
 
 	window_list = g_list_prepend (window_list, window);
@@ -268,9 +270,13 @@ gth_window_attach (GthWindow     *window,
 		window->priv->toolbar = child;
 		position = 1;
 		break;
+	case GTH_WINDOW_INFOBAR:
+		window->priv->infobar = child;
+		position = 3;
+		break;
 	case GTH_WINDOW_STATUSBAR:
 		window->priv->statusbar = child;
-		position = 3;
+		position = 4;
 		break;
 	default:
 		return;
@@ -383,6 +389,9 @@ gth_window_get_area (GthWindow     *window,
 	case GTH_WINDOW_TOOLBAR:
 		return window->priv->toolbar;
 		break;
+	case GTH_WINDOW_INFOBAR:
+		return window->priv->infobar;
+		break;
 	case GTH_WINDOW_STATUSBAR:
 		return window->priv->statusbar;
 		break;
diff --git a/gthumb/gth-window.h b/gthumb/gth-window.h
index f00d592..de6c560 100644
--- a/gthumb/gth-window.h
+++ b/gthumb/gth-window.h
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
 typedef enum { /*< skip >*/
 	GTH_WINDOW_MENUBAR,
 	GTH_WINDOW_TOOLBAR,
+	GTH_WINDOW_INFOBAR,
 	GTH_WINDOW_STATUSBAR,
 } GthWindowArea;
 
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index 2c1d12a..2b72e6c 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -1116,3 +1116,10 @@ _gtk_window_resize_to_fit_screen_height (GtkWidget *window,
 		 * with top and bottom panels */
 		gtk_window_set_default_size (GTK_WINDOW (window), default_width, 670);
 }
+
+
+void
+_gtk_info_bar_clear_action_area (GtkInfoBar *info_bar)
+{
+	_gtk_container_remove_children (GTK_CONTAINER (gtk_info_bar_get_action_area (info_bar)), NULL, NULL);
+}
diff --git a/gthumb/gtk-utils.h b/gthumb/gtk-utils.h
index 377147b..4a3d095 100644
--- a/gthumb/gtk-utils.h
+++ b/gthumb/gtk-utils.h
@@ -121,8 +121,10 @@ void        _g_launch_command              (GtkWidget        *parent,
 					    const char       *command,
 					    const char       *name,
 					    GList            *files);
-void        _gtk_window_resize_to_fit_screen_height (GtkWidget *window,
-						     int        default_width);
+void        _gtk_window_resize_to_fit_screen_height
+					   (GtkWidget        *window,
+					    int               default_width);
+void        _gtk_info_bar_clear_action_area (GtkInfoBar      *info_bar);
 
 G_END_DECLS
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ee82c15..1da6a5c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -647,6 +647,8 @@ gthumb/gth-image-viewer.c
 gthumb/gth-image-viewer.h
 gthumb/gth-image-viewer-tool.c
 gthumb/gth-image-viewer-tool.h
+gthumb/gth-info-bar.c
+gthumb/gth-info-bar.h
 gthumb/gth-location-chooser.c
 gthumb/gth-location-chooser.h
 gthumb/gth-main.c
@@ -698,9 +700,10 @@ gthumb/gth-tags-file.h
 gthumb/gth-task.c
 gthumb/gth-task.h
 gthumb/gth-test.c
+gthumb/gth-test-category.c
+gthumb/gth-test-category.h
 gthumb/gth-test-chain.c
 gthumb/gth-test-chain.h
-gthumb/gth-test-category.c
 gthumb/gth-test.h
 gthumb/gth-test-selector.c
 gthumb/gth-test-selector.h
@@ -733,6 +736,8 @@ gthumb/gvaluehash.c
 gthumb/gvaluehash.h
 gthumb/main.c
 gthumb/main.h
+gthumb/main-migrate-catalogs.c
+gthumb/main-migrate.h
 gthumb/pixbuf-cache.c
 gthumb/pixbuf-cache.h
 gthumb/pixbuf-io.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]