[Rawstudio-commit] r928 - trunk/src

Anders Brander anders at brander.dk
Fri Nov 3 11:41:57 CET 2006


Author: abrander
Date: 2006-11-03 11:41:56 +0100 (Fri, 03 Nov 2006)
New Revision: 928

Added:
   trunk/src/gtk-progress.c
   trunk/src/gtk-progress.h
Modified:
   trunk/src/Makefile.am
Log:
Adding progress bar.

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2006-11-01 13:06:28 UTC (rev 927)
+++ trunk/src/Makefile.am	2006-11-03 10:41:56 UTC (rev 928)
@@ -19,6 +19,7 @@
 	gtk-helper.c gtk-helper.h \
 	gtk-interface.c gtk-interface.h \
 	gtk-save-dialog.c gtk-save-dialog.h \
+	gtk-progress.c gtk-progress.h \
 	conf_interface.c conf_interface.h \
 	rs-cache.c rs-cache.h \
 	rs-batch.c rs-batch.h \

Added: trunk/src/gtk-progress.c
===================================================================
--- trunk/src/gtk-progress.c	2006-11-01 13:06:28 UTC (rev 927)
+++ trunk/src/gtk-progress.c	2006-11-03 10:41:56 UTC (rev 928)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2006 Anders Brander <anders at brander.dk> and 
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <gtk/gtk.h>
+#include <string.h> /* memset() */
+#include "gtk-progress.h"
+
+RS_PROGRESS *
+gui_progress_new(const gchar *title, gint items)
+{
+	extern GtkWidget *hbox;
+	RS_PROGRESS *rsp;
+	rsp = g_new(RS_PROGRESS, 1);
+	rsp->progressbar = gtk_progress_bar_new();
+	rsp->items = items;
+	rsp->current = 0;
+	rsp->title = title;
+	if (rsp->title)
+		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(rsp->progressbar), title);
+	gtk_box_pack_end(GTK_BOX (hbox), rsp->progressbar, FALSE, TRUE, 0);
+	gtk_widget_show_all(rsp->progressbar);
+	return(rsp);
+}
+
+void
+gui_progress_free(RS_PROGRESS *rsp)
+{
+	gtk_widget_destroy(rsp->progressbar);
+	g_free(rsp);
+}
+
+void
+gui_progress_advance_one(RS_PROGRESS *rsp)
+{
+	rsp->current++;
+	gui_progress_set_current(rsp, rsp->current);
+}
+
+void
+gui_progress_set_current(RS_PROGRESS *rsp, gint current)
+{
+	GString *gs;
+	rsp->current = current;
+	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rsp->progressbar),
+		((gdouble)rsp->current)/((gdouble)rsp->items));
+	if (!rsp->title)
+	{
+		gs = g_string_new(NULL);
+		g_string_printf(gs, "%d/%d", rsp->current, rsp->items);
+		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(rsp->progressbar), gs->str);
+		g_string_free(gs, TRUE);
+	}
+	while (gtk_events_pending())
+		gtk_main_iteration();
+}

Added: trunk/src/gtk-progress.h
===================================================================
--- trunk/src/gtk-progress.h	2006-11-01 13:06:28 UTC (rev 927)
+++ trunk/src/gtk-progress.h	2006-11-03 10:41:56 UTC (rev 928)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Anders Brander <anders at brander.dk> and 
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+typedef struct _rs_progress {
+	GtkWidget *progresswindow;
+	GtkWidget *progressbar;
+	gint items;
+	gint current;
+	const gchar *title;
+} RS_PROGRESS;
+
+RS_PROGRESS *gui_progress_new(const gchar *title, gint items);
+void gui_progress_free(RS_PROGRESS *rsp);
+void gui_progress_advance_one(RS_PROGRESS *rsp);
+void gui_progress_set_current(RS_PROGRESS *rsp, gint current);




More information about the Rawstudio-commit mailing list