changeset 1240:30e207ac22e4

added a status bar button for writting metadata immediately
author nadvornik
date Sun, 11 Jan 2009 18:58:05 +0000
parents 254b09942e68
children 8cb82b33cab8
files src/layout.c src/layout.h src/metadata.c src/metadata.h src/typedefs.h
diffstat 5 files changed, 74 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout.c	Sun Jan 11 12:13:30 2009 +0000
+++ b/src/layout.c	Sun Jan 11 18:58:05 2009 +0000
@@ -523,6 +523,36 @@
 	return button;
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ * write button
+ *-----------------------------------------------------------------------------
+ */
+
+static void layout_write_button_press_cb(GtkWidget *widget, gpointer data)
+{
+	LayoutWindow *lw = data;
+	metadata_write_queue_confirm(NULL, NULL);
+}
+
+static GtkWidget *layout_write_button(LayoutWindow *lw)
+{
+	GtkWidget *button;
+	GtkWidget *image;
+
+	button = gtk_button_new();
+	image = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU);
+	gtk_container_add(GTK_CONTAINER(button), image);
+	gtk_widget_show(image);
+	g_signal_connect(G_OBJECT(button), "clicked",
+			 G_CALLBACK(layout_write_button_press_cb), lw);
+	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+	
+	gtk_widget_set_sensitive(button, metadata_queue_length() > 0);
+	
+	return button;
+}
+
 
 /*
  *-----------------------------------------------------------------------------
@@ -530,6 +560,30 @@
  *-----------------------------------------------------------------------------
  */
 
+void layout_status_update_write(LayoutWindow *lw)
+{
+	if (!layout_valid(&lw)) return;
+	if (!lw->info_write) return;
+
+	gtk_widget_set_sensitive(lw->info_write, metadata_queue_length() > 0);
+	/* FIXME: maybe show also the number of files */
+}
+
+void layout_status_update_write_all(void)
+{
+	GList *work;
+
+	work = layout_window_list;
+	while (work)
+		{
+		LayoutWindow *lw = work->data;
+		work = work->next;
+
+		layout_status_update_write(lw);
+		}
+}
+
+
 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text)
 {
 	if (!layout_valid(&lw)) return;
@@ -667,6 +721,7 @@
 	layout_status_update_progress(lw, 0.0, NULL);
 	layout_status_update_info(lw, NULL);
 	layout_status_update_image(lw);
+	layout_status_update_write(lw);
 }
 
 static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gint start, gint size, gint expand)
@@ -733,7 +788,11 @@
 	lw->info_color = layout_color_button(lw);
 	gtk_widget_show(lw->info_color);
 
+	lw->info_write = layout_write_button(lw);
+	gtk_widget_show(lw->info_write);
+
 	if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0);
+	if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0);
 
 	lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format));
 
@@ -749,6 +808,7 @@
 		}
 	lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE);
 	if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0);
+	if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0);
 	lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE);
 }
 
--- a/src/layout.h	Sun Jan 11 12:13:30 2009 +0000
+++ b/src/layout.h	Sun Jan 11 18:58:05 2009 +0000
@@ -36,8 +36,11 @@
 void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text);
 void layout_status_update_info(LayoutWindow *lw, const gchar *text);
 void layout_status_update_image(LayoutWindow *lw);
+void layout_status_update_write(LayoutWindow *lw);
 void layout_status_update_all(LayoutWindow *lw);
 
+void layout_status_update_write_all(void);
+
 GList *layout_list(LayoutWindow *lw);
 guint layout_list_count(LayoutWindow *lw, gint64 *bytes);
 FileData *layout_list_get_fd(LayoutWindow *lw, gint index);
--- a/src/metadata.c	Sun Jan 11 12:13:30 2009 +0000
+++ b/src/metadata.c	Sun Jan 11 18:58:05 2009 +0000
@@ -53,6 +53,8 @@
 		{
 		metadata_write_queue = g_list_prepend(metadata_write_queue, fd);
 		file_data_ref(fd);
+		
+		layout_status_update_write_all();
 		}
 
 	if (metadata_write_idle_id != -1) 
@@ -79,6 +81,8 @@
 	file_data_send_notification(fd, NOTIFY_TYPE_REREAD);
 
 	file_data_unref(fd);
+
+	layout_status_update_write_all();
 	return TRUE;
 }
 
@@ -157,6 +161,11 @@
 	return success;
 }
 
+gint metadata_queue_length(void)
+{
+	return g_list_length(metadata_write_queue);
+}
+
 static gboolean metadata_check_key(const gchar *keys[], const gchar *key)
 {
 	const gchar **k = keys;
--- a/src/metadata.h	Sun Jan 11 12:13:30 2009 +0000
+++ b/src/metadata.h	Sun Jan 11 18:58:05 2009 +0000
@@ -22,7 +22,7 @@
 gboolean metadata_write_perform(FileData *fd);
 gboolean metadata_write_queue_confirm(FileUtilDoneFunc done_func, gpointer done_data);
 
-
+gint metadata_queue_length(void);
 
 gboolean metadata_write_list(FileData *fd, const gchar *key, const GList *values);
 gboolean metadata_write_string(FileData *fd, const gchar *key, const char *value);
--- a/src/typedefs.h	Sun Jan 11 12:13:30 2009 +0000
+++ b/src/typedefs.h	Sun Jan 11 18:58:05 2009 +0000
@@ -533,6 +533,7 @@
 	GtkWidget *info_status;
 	GtkWidget *info_details;
 	GtkWidget *info_zoom;
+	GtkWidget *info_write;
 
 	/* slide show */