[Xfce4-commits] r25359 - squeeze/trunk/src

Stephan Arts stephan at xfce.org
Mon Apr 2 12:04:22 CEST 2007


Author: stephan
Date: 2007-04-02 10:04:22 +0000 (Mon, 02 Apr 2007)
New Revision: 25359

Added:
   squeeze/trunk/src/message_dialog.c
   squeeze/trunk/src/message_dialog.h
Modified:
   squeeze/trunk/src/Makefile.am
   squeeze/trunk/src/application.c
   squeeze/trunk/src/main_window.c
Log:
add message dialog for operations

Modified: squeeze/trunk/src/Makefile.am
===================================================================
--- squeeze/trunk/src/Makefile.am	2007-04-02 05:36:31 UTC (rev 25358)
+++ squeeze/trunk/src/Makefile.am	2007-04-02 10:04:22 UTC (rev 25359)
@@ -23,6 +23,7 @@
 	$(PATHBAR_FILES) \
 	settings.c settings.h \
 	archive_store.c archive_store.h \
+	message_dialog.c message_dialog.h \
 	new_dialog.c new_dialog.h \
 	add_dialog.c add_dialog.h \
 	extract_dialog.c extract_dialog.h \

Modified: squeeze/trunk/src/application.c
===================================================================
--- squeeze/trunk/src/application.c	2007-04-02 05:36:31 UTC (rev 25358)
+++ squeeze/trunk/src/application.c	2007-04-02 10:04:22 UTC (rev 25359)
@@ -23,6 +23,7 @@
 
 #include "new_dialog.h"
 #include "add_dialog.h"
+#include "message_dialog.h"
 #include "extract_dialog.h"
 
 #include "settings.h"
@@ -181,7 +182,9 @@
 		return 1;
 	}
 	g_signal_connect(G_OBJECT(lp_archive), "command-terminated", G_CALLBACK(cb_sq_application_archive_command_terminated), app);
-	if(lsq_archive_extract(lp_archive, dest_path, NULL))
+	GtkWidget *message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
+	gtk_widget_show(message_dialog);
+	if(!lsq_archive_extract(lp_archive, dest_path, NULL))
 	{
 		GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, 
 		                                                   GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -254,7 +257,7 @@
 		}
 	}
 	g_signal_connect(G_OBJECT(lp_archive), "command-terminated", G_CALLBACK(cb_sq_application_archive_command_terminated), app);
-	if(lsq_archive_add(lp_archive, files))
+	if(!lsq_archive_add(lp_archive, files))
 	{
 		/* FIXME: show warning dialog */
 		GtkWidget *warning_dialog = gtk_message_dialog_new(NULL, 

Modified: squeeze/trunk/src/main_window.c
===================================================================
--- squeeze/trunk/src/main_window.c	2007-04-02 05:36:31 UTC (rev 25358)
+++ squeeze/trunk/src/main_window.c	2007-04-02 10:04:22 UTC (rev 25359)
@@ -730,7 +730,7 @@
 			g_slist_free(filenames);
 			filenames = NULL;
 		}
-		if(lsq_archive_extract(lp_archive, extract_archive_path, filenames))
+		if(!lsq_archive_extract(lp_archive, extract_archive_path, filenames))
 		{
 			GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 			                                                   GTK_DIALOG_DESTROY_WITH_PARENT, 
@@ -944,10 +944,15 @@
 		_("Contributors:"),
 		"Peter de Ridder <peter at xfce.org>",
 		"",
-		_("Artwork:"),
-		_("The add and extract icons are based on the extract icon created by Andreas Nilsson"),
+		_("Inspired by Xarchiver, written by Giuseppe Torelli"), NULL};
+	const gchar *artists[] = {
+		_("Application Icon:"),
+		"Stephan Arts <stephan at xfce.org",
 		"",
-		_("Inspired by Xarchiver, written by Giuseppe Torelli"), NULL};
+		_("Add / Extract icons:"),
+		_("Based on the original extract icon created by Andreas Nilsson"),
+		NULL
+	};
 	GtkWidget *about_dialog = gtk_about_dialog_new();
 
 	gtk_about_dialog_set_name((GtkAboutDialog *)about_dialog, PACKAGE_NAME);
@@ -963,6 +968,10 @@
 
 	gtk_about_dialog_set_license((GtkAboutDialog *)about_dialog, xfce_get_license_text(XFCE_LICENSE_TEXT_GPL));
 
+	gtk_about_dialog_set_artists((GtkAboutDialog *)about_dialog, artists);
+
+	gtk_about_dialog_set_copyright((GtkAboutDialog *)about_dialog, "Copyright \302\251 2006-2007 Stephan Arts");
+
 	gtk_dialog_run(GTK_DIALOG(about_dialog));
 
 	gtk_widget_destroy(about_dialog);

Added: squeeze/trunk/src/message_dialog.c
===================================================================
--- squeeze/trunk/src/message_dialog.c	                        (rev 0)
+++ squeeze/trunk/src/message_dialog.c	2007-04-02 10:04:22 UTC (rev 25359)
@@ -0,0 +1,172 @@
+/*
+ *  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 Library 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 Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <thunar-vfs/thunar-vfs.h>
+#include <libsqueeze/libsqueeze.h>
+
+#include "message_dialog.h"
+#include "widget_factory.h"
+
+static void
+sq_message_dialog_class_init(SQMessageDialogClass *archive_class);
+
+static void
+sq_message_dialog_init(SQMessageDialog *archive);
+
+static void
+sq_message_dialog_dispose(GObject *dialog);
+
+static gboolean
+sq_message_dialog_progressbar_pulse(SQMessageDialog *dialog);
+static void
+cb_sq_message_dialog_close(GtkButton *button, SQMessageDialog *dialog);
+
+static GObjectClass *parent_class = NULL;
+
+GType
+sq_message_dialog_get_type ()
+{
+	static GType sq_message_dialog_type = 0;
+
+ 	if (!sq_message_dialog_type)
+	{
+ 		static const GTypeInfo sq_message_dialog_info = 
+		{
+			sizeof (SQMessageDialogClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) sq_message_dialog_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,
+			sizeof (SQMessageDialog),
+			0,
+			(GInstanceInitFunc) sq_message_dialog_init,
+			NULL
+		};
+
+		sq_message_dialog_type = g_type_register_static (GTK_TYPE_WINDOW, "SQMessageDialog", &sq_message_dialog_info, 0);
+	}
+	return sq_message_dialog_type;
+}
+
+static void
+sq_message_dialog_class_init(SQMessageDialogClass *dialog_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (dialog_class);
+	GParamSpec *pspec = NULL;
+
+	parent_class = gtk_type_class (GTK_TYPE_WINDOW);
+
+	object_class->dispose = sq_message_dialog_dispose;
+}
+
+static void
+sq_message_dialog_init(SQMessageDialog *dialog)
+{
+	GtkWidget *vbox = gtk_vbox_new(FALSE, 3);
+	dialog->message_label = gtk_label_new("being silly here");
+	dialog->progress_bar = gtk_progress_bar_new();
+
+	gtk_label_set_ellipsize(GTK_LABEL(dialog->message_label), PANGO_ELLIPSIZE_MIDDLE);
+
+	GtkWidget *separator = gtk_hseparator_new();
+	GtkWidget *button_box= gtk_hbutton_box_new();
+
+	gtk_box_pack_end(GTK_BOX(vbox), button_box, FALSE, FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(vbox), separator, FALSE, FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(vbox), dialog->message_label, FALSE, FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(vbox), dialog->progress_bar, TRUE, FALSE, 5);
+
+
+	gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
+
+	GtkWidget *cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+
+	g_signal_connect(cancel_button, "clicked", G_CALLBACK(cb_sq_message_dialog_close), dialog);
+
+	gtk_container_add(GTK_CONTAINER(button_box), cancel_button);
+
+	gtk_widget_show_all(vbox);
+
+	gtk_container_add(GTK_CONTAINER(dialog), vbox);
+}
+
+static void
+sq_message_dialog_dispose(GObject *dialog)
+{
+	if(SQ_MESSAGE_DIALOG(dialog)->archive)
+	{
+		GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog), 
+									   GTK_DIALOG_MODAL,
+									   GTK_MESSAGE_WARNING,
+									   GTK_BUTTONS_YES_NO,
+									   "Are you sure you want to cancel this operation?");
+		if(gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES)
+		{
+			lsq_archive_stop(SQ_MESSAGE_DIALOG(dialog)->archive);
+			SQ_MESSAGE_DIALOG(dialog)->archive = NULL;
+
+		}
+		gtk_widget_destroy(warning_dialog);
+	}
+	else
+		parent_class->dispose(dialog);
+}
+
+static gboolean
+sq_message_dialog_progressbar_pulse(SQMessageDialog *dialog)
+{
+	if(dialog->archive)
+	{
+		gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress_bar));
+		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dialog->progress_bar), lsq_archive_get_status(dialog->archive));
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static void
+cb_sq_message_dialog_close(GtkButton *button, SQMessageDialog *dialog)
+{
+	gtk_widget_destroy(GTK_WIDGET(dialog));
+}
+
+GtkWidget *
+sq_message_dialog_new(GtkWindowType type, LSQArchive *archive)
+{
+	SQMessageDialog *dialog;
+
+	dialog = g_object_new(sq_message_dialog_get_type(),
+			"title", _("Archive Manager"),
+			"type", type,
+			"resizable", FALSE,
+			"deletable", FALSE,
+			"modal", TRUE,
+			NULL);
+
+	gtk_widget_set_size_request(GTK_WIDGET(dialog), 300,100);
+
+	SQ_MESSAGE_DIALOG(dialog)->archive = archive;
+
+	g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
+
+	gtk_label_set_text(GTK_LABEL(dialog->message_label), lsq_archive_get_path(archive));
+
+	return (GtkWidget*)dialog;
+}

Added: squeeze/trunk/src/message_dialog.h
===================================================================
--- squeeze/trunk/src/message_dialog.h	                        (rev 0)
+++ squeeze/trunk/src/message_dialog.h	2007-04-02 10:04:22 UTC (rev 25359)
@@ -0,0 +1,60 @@
+/*
+ *  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 Library 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 Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SQRCHIVER_MESSAGE_DIALOG_H__
+#define __SQRCHIVER_MESSAGE_DIALOG_H__
+G_BEGIN_DECLS
+
+#define SQ_MESSAGE_DIALOG(obj)         ( \
+		G_TYPE_CHECK_INSTANCE_CAST ((obj),    \
+			sq_message_dialog_get_type(),      \
+			SQMessageDialog))
+
+#define SQ_IS_MESSAGE_DIALOG(obj)      ( \
+		G_TYPE_CHECK_INSTANCE_TYPE ((obj),    \
+			sq_message_dialog_get_type()))
+
+#define SQ_MESSAGE_DIALOG_CLASS(class) ( \
+		G_TYPE_CHECK_CLASS_CAST ((class),     \
+			sq_message_dialog_get_type(),      \
+			SQMessageDialogClass))
+
+#define SQ_IS_MESSAGE_DIALOG_CLASS(class) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((class),        \
+			sq_message_dialog_get_type()))
+
+typedef struct _SQMessageDialog SQMessageDialog;
+
+struct _SQMessageDialog
+{
+	GtkWindow parent;
+	LSQArchive *archive;
+	GtkWidget *message_label;
+	GtkWidget *progress_bar;
+};
+
+typedef struct _SQMessageDialogClass SQMessageDialogClass;
+
+struct _SQMessageDialogClass
+{
+	GtkWindowClass parent;
+};
+
+GType      sq_message_dialog_get_type();
+GtkWidget *sq_message_dialog_new();
+
+G_END_DECLS
+#endif /* __SQRCHIVER_MESSAGE_DIALOG_H__ */



More information about the Xfce4-commits mailing list