[Xfce4-commits] r23069 - in xarchiver/branches/xarchiver-psybsd: . libxarchiver po src

Stephan Arts stephan at xfce.org
Sun Sep 3 23:19:49 UTC 2006


Author: stephan
Date: 2006-09-03 23:19:48 +0000 (Sun, 03 Sep 2006)
New Revision: 23069

Modified:
   xarchiver/branches/xarchiver-psybsd/TODO
   xarchiver/branches/xarchiver-psybsd/configure.in.in
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
   xarchiver/branches/xarchiver-psybsd/po/nl.po
   xarchiver/branches/xarchiver-psybsd/po/xarchiver.pot
   xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c
   xarchiver/branches/xarchiver-psybsd/src/main.c
   xarchiver/branches/xarchiver-psybsd/src/main.h
   xarchiver/branches/xarchiver-psybsd/src/main_window.c
   xarchiver/branches/xarchiver-psybsd/src/main_window.h
   xarchiver/branches/xarchiver-psybsd/src/main_window_menu_bar.c
   xarchiver/branches/xarchiver-psybsd/src/main_window_tool_bar.c
Log:
Fixed New buttons in GUI
Fixed Open buttons in GUI
Fixed Quit button in GUI

started on 'view' of archive



Modified: xarchiver/branches/xarchiver-psybsd/TODO
===================================================================
--- xarchiver/branches/xarchiver-psybsd/TODO	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/TODO	2006-09-03 23:19:48 UTC (rev 23069)
@@ -10,10 +10,8 @@
 
 +-+-+-+
 
-	Implement extract options in extract-dialog
-+-+-+-+
-
 	Implement View support (for all support-objects)
+		Use Path-entries for path-components. (Should reduce mem-usage on large archives tremendously)
 +-+-+-+
 
 	Implement UnRar Support object.

Modified: xarchiver/branches/xarchiver-psybsd/configure.in.in
===================================================================
--- xarchiver/branches/xarchiver-psybsd/configure.in.in	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/configure.in.in	2006-09-03 23:19:48 UTC (rev 23069)
@@ -11,7 +11,7 @@
 dnl ***************************
 m4_define([xarchiver_version_branch], [psybsd])
 m4_define([xarchiver_version_major], [0])
-m4_define([xarchiver_version_minor], [3])
+m4_define([xarchiver_version_minor], [4])
 m4_define([xarchiver_version_micro], [9])
 m4_define([xarchiver_version_nano], []) # Leave empty for no nano version
 m4_define([xarchiver_version_build], [r at REVISION@])

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -48,6 +48,8 @@
 lxa_archive_support_gnu_tar_decompress_watch(GPid pid, gint status, gpointer data);
 
 gboolean
+lxa_archive_support_gnu_tar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+gboolean
 lxa_archive_support_gnu_tar_compress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
 gboolean
 lxa_archive_support_gnu_tar_decompress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
@@ -108,6 +110,8 @@
 	archive_support->add = lxa_archive_support_gnu_tar_add;
 	archive_support->extract = lxa_archive_support_gnu_tar_extract;
 	archive_support->remove = lxa_archive_support_gnu_tar_remove;
+	archive_support->refresh = lxa_archive_support_gnu_tar_refresh;
+	archive_support->view = lxa_archive_support_gnu_tar_view;
 }
 
 void
@@ -316,6 +320,32 @@
 	return 0;
 }
 
+gint
+lxa_archive_support_gnu_tar_view(LXAArchive *archive, gchar *path)
+{
+}
+
+gint
+lxa_archive_support_gnu_tar_refresh(LXAArchive *archive)
+{
+	if(!LXA_IS_ARCHIVE_SUPPORT_GNU_TAR(archive->support))
+	{
+		g_critical("Support is not GNU TAR");
+		return -1;
+	}
+
+	if(!lxa_archive_support_mime_supported(archive->support, archive->mime))
+	{
+		return 1;
+	}
+	else
+	{
+		gchar *command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " tfv " , archive->path, NULL);
+		lxa_execute(command, archive, NULL, NULL, lxa_archive_support_gnu_tar_refresh_parse_output, NULL);
+		g_free(command);
+	}
+}
+
 void
 lxa_archive_support_gnu_tar_decompress_watch(GPid pid, gint status, gpointer data)
 {
@@ -341,6 +371,39 @@
 }
 
 gboolean
+lxa_archive_support_gnu_tar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+	GIOStatus status = G_IO_STATUS_NORMAL;
+	FILE *out_file = NULL;
+	LXAArchive *archive = data;
+	gchar *line	= NULL;
+	guint read = 0;
+	GError *error = NULL;
+	gchar *command = NULL;
+
+	if(cond & (G_IO_PRI | G_IO_IN))
+	{
+		while(TRUE)
+		{
+			status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+			if (line == NULL)
+ 				break;
+			g_print(".");
+			g_free(line);
+		}
+	}
+	if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+	{
+#ifdef DEBUG
+		g_debug("shutting down ioc");
+#endif
+		g_io_channel_shutdown ( ioc,TRUE,NULL );
+		g_io_channel_unref (ioc);
+		return FALSE; 
+	}
+	return TRUE;
+}
+gboolean
 lxa_archive_support_gnu_tar_decompress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
 {
 	FILE *out_file = NULL;

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h	2006-09-03 23:19:48 UTC (rev 23069)
@@ -65,7 +65,8 @@
 gint                 lxa_archive_support_gnu_tar_add(LXAArchive *, GSList *);
 gint                 lxa_archive_support_gnu_tar_extract(LXAArchive *, gchar *, GSList *);
 gint                 lxa_archive_support_gnu_tar_remove(LXAArchive *, GSList *);
-
+gint                 lxa_archive_support_gnu_tar_refresh(LXAArchive *);
+gint                 lxa_archive_support_gnu_tar_view(LXAArchive *, gchar *);
 G_END_DECLS
 
 #endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_GNU_TAR_H__ */

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -18,6 +18,7 @@
 
 #define EXO_API_SUBJECT_TO_CHANGE
 
+#include <string.h>
 #include <glib.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>
@@ -217,6 +218,34 @@
 	return -1;
 }
 
+gint
+lxa_archive_support_refresh(LXAArchiveSupport *support, LXAArchive *archive)
+{
+	if(support->refresh)
+	{
+		lxa_archive_set_status(archive, LXA_ARCHIVESTATUS_REFRESH);
+		archive->support = support;
+		return support->refresh(archive);
+	}
+	else
+		g_critical("VIEW NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+	return -1;
+}
+
+gint
+lxa_archive_support_view(LXAArchiveSupport *support, LXAArchive *archive, gchar *path)
+{
+	if(support->view)
+	{
+		lxa_archive_set_status(archive, LXA_ARCHIVESTATUS_VIEW);
+		archive->support = support;
+		return support->view(archive, path);
+	}
+	else
+		g_critical("VIEW NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+	return -1;
+}
+
 GSList *
 lxa_archive_support_list_properties(LXAArchiveSupport *support, gchar *prefix)
 {

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-09-03 23:19:48 UTC (rev 23069)
@@ -60,6 +60,8 @@
 	gint        (*add)(LXAArchive *archive, GSList *files);
 	gint        (*extract)(LXAArchive *archive, gchar *dest_path, GSList *files);
 	gint        (*remove)(LXAArchive *archive, GSList *files);
+	gint        (*refresh)(LXAArchive *archive);
+	gint        (*view)(LXAArchive *archive, gchar *path);
 };
 
 typedef struct _LXAArchiveSupportClass LXAArchiveSupportClass;
@@ -84,6 +86,8 @@
 gint                 lxa_archive_support_add(LXAArchiveSupport *, LXAArchive *, GSList *);
 gint                 lxa_archive_support_extract(LXAArchiveSupport *, LXAArchive *, gchar *, GSList *);
 gint                 lxa_archive_support_remove(LXAArchiveSupport *, LXAArchive *, GSList *);
+gint                 lxa_archive_support_refresh(LXAArchiveSupport *, LXAArchive *);
+gint                 lxa_archive_support_view(LXAArchiveSupport *, LXAArchive *, gchar *);
 
 GSList *             lxa_archive_support_list_properties(LXAArchiveSupport *, gchar *);
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-09-03 23:19:48 UTC (rev 23069)
@@ -26,6 +26,7 @@
 	LXA_ARCHIVESTATUS_ADD,
 	LXA_ARCHIVESTATUS_EXTRACT,
 	LXA_ARCHIVESTATUS_REMOVE,
+	LXA_ARCHIVESTATUS_REFRESH,
 	LXA_ARCHIVESTATUS_VIEW,
 	LXA_ARCHIVESTATUS_ERROR,
 	LXA_ARCHIVESTATUS_USERBREAK
@@ -57,14 +58,15 @@
 struct _LXAArchive
 {
 	GObject parent;
-	gchar                 *path;
-	gchar                 *mime;
-	LXAArchiveStatus       status;
-	LXAArchiveStatus       old_status;
-	GPid                   child_pid;
-	gpointer               support;
-	gchar                 *tmp_file;
-	gchar                 *files;
+	gchar              *path;
+	gchar              *mime;
+	LXAArchiveStatus    status;
+	LXAArchiveStatus    old_status;
+	GPid                child_pid;
+	gpointer            support;
+	gchar              *tmp_file;
+	gchar              *files;
+	gboolean            has_passwd;
 };
 
 typedef struct _LXAArchiveClass LXAArchiveClass;

Modified: xarchiver/branches/xarchiver-psybsd/po/nl.po
===================================================================
--- xarchiver/branches/xarchiver-psybsd/po/nl.po	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/po/nl.po	2006-09-03 23:19:48 UTC (rev 23069)
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: xarchiver 0.3.9psybsd\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-08-29 07:38+0200\n"
+"POT-Creation-Date: 2006-09-04 01:18+0200\n"
 "PO-Revision-Date: 2006-07-20 16:36+0200\n"
 "Last-Translator: Stephan Arts <psybsd at gmail.com>\n"
 "Language-Team: Dutch <vertaling at vrijschrift.org>\n"
@@ -16,18 +16,18 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: ../libxarchiver/archive-support-gnu-tar.c:123
-#: ../libxarchiver/archive-support-zip.c:99
+#: ../libxarchiver/archive-support-gnu-tar.c:127
+#: ../libxarchiver/archive-support-zip.c:104
 msgid "Overwrite existing files"
 msgstr "Bestaande bestanden overschrijven"
 
-#: ../libxarchiver/archive-support-gnu-tar.c:124
-#: ../libxarchiver/archive-support-zip.c:100
+#: ../libxarchiver/archive-support-gnu-tar.c:128
+#: ../libxarchiver/archive-support-zip.c:105
 msgid "Overwrite existing files on extraction"
 msgstr "Bestaande bestanden overschrijven tijdens uitpakken"
 
-#: ../libxarchiver/archive-support-zip.c:107
-#: ../libxarchiver/archive-support-zip.c:108
+#: ../libxarchiver/archive-support-zip.c:97
+#: ../libxarchiver/archive-support-zip.c:98
 msgid "Password"
 msgstr "Wachtwoord"
 
@@ -78,32 +78,36 @@
 "Kan archief niet openen, MIME-type wordt niet ondersteund of bestand bestaat "
 "niet"
 
+#: ../src/main_window.c:170
+msgid "Open archive"
+msgstr "Archief openen"
+
 #: ../src/new_dialog.c:85
 msgid "Create new archive"
 msgstr "Maak nieuw archief"
 
-#: ../src/extract_dialog.c:69
+#: ../src/extract_dialog.c:74
 msgid "<b>Extract files:</b>"
 msgstr "<b> Bestanden uitpakken:</b>"
 
-#: ../src/extract_dialog.c:70
+#: ../src/extract_dialog.c:75
 msgid "<b>Options:</b>"
 msgstr "<b>Opties:</b>"
 
-#: ../src/extract_dialog.c:80
+#: ../src/extract_dialog.c:85
 msgid "All files"
 msgstr "Alle bestanden"
 
-#: ../src/extract_dialog.c:81
+#: ../src/extract_dialog.c:86
 msgid "Selected files"
 msgstr "Geselecteerde bestanden"
 
-#: ../src/extract_dialog.c:93 ../src/main_window_menu_bar.c:117
-#: ../src/main_window_tool_bar.c:87
+#: ../src/extract_dialog.c:98 ../src/main_window_menu_bar.c:122
+#: ../src/main_window_tool_bar.c:91
 msgid "Extract"
 msgstr "Uitpakken"
 
-#: ../src/extract_dialog.c:105
+#: ../src/extract_dialog.c:110
 msgid "Extract archive"
 msgstr "Archief uitpakken"
 
@@ -119,7 +123,7 @@
 msgid "_Help"
 msgstr "_Help"
 
-#: ../src/main_window_menu_bar.c:112 ../src/main_window_tool_bar.c:84
+#: ../src/main_window_menu_bar.c:117 ../src/main_window_tool_bar.c:88
 msgid "Add"
 msgstr "Toevoegen"
 

Modified: xarchiver/branches/xarchiver-psybsd/po/xarchiver.pot
===================================================================
--- xarchiver/branches/xarchiver-psybsd/po/xarchiver.pot	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/po/xarchiver.pot	2006-09-03 23:19:48 UTC (rev 23069)
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-08-29 07:38+0200\n"
+"POT-Creation-Date: 2006-09-04 01:18+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -16,18 +16,18 @@
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../libxarchiver/archive-support-gnu-tar.c:123
-#: ../libxarchiver/archive-support-zip.c:99
+#: ../libxarchiver/archive-support-gnu-tar.c:127
+#: ../libxarchiver/archive-support-zip.c:104
 msgid "Overwrite existing files"
 msgstr ""
 
-#: ../libxarchiver/archive-support-gnu-tar.c:124
-#: ../libxarchiver/archive-support-zip.c:100
+#: ../libxarchiver/archive-support-gnu-tar.c:128
+#: ../libxarchiver/archive-support-zip.c:105
 msgid "Overwrite existing files on extraction"
 msgstr ""
 
-#: ../libxarchiver/archive-support-zip.c:107
-#: ../libxarchiver/archive-support-zip.c:108
+#: ../libxarchiver/archive-support-zip.c:97
+#: ../libxarchiver/archive-support-zip.c:98
 msgid "Password"
 msgstr ""
 
@@ -73,32 +73,36 @@
 msgid "Could not open archive, MIME-type unsupported or file did not exist"
 msgstr ""
 
+#: ../src/main_window.c:170
+msgid "Open archive"
+msgstr ""
+
 #: ../src/new_dialog.c:85
 msgid "Create new archive"
 msgstr ""
 
-#: ../src/extract_dialog.c:69
+#: ../src/extract_dialog.c:74
 msgid "<b>Extract files:</b>"
 msgstr ""
 
-#: ../src/extract_dialog.c:70
+#: ../src/extract_dialog.c:75
 msgid "<b>Options:</b>"
 msgstr ""
 
-#: ../src/extract_dialog.c:80
+#: ../src/extract_dialog.c:85
 msgid "All files"
 msgstr ""
 
-#: ../src/extract_dialog.c:81
+#: ../src/extract_dialog.c:86
 msgid "Selected files"
 msgstr ""
 
-#: ../src/extract_dialog.c:93 ../src/main_window_menu_bar.c:117
-#: ../src/main_window_tool_bar.c:87
+#: ../src/extract_dialog.c:98 ../src/main_window_menu_bar.c:122
+#: ../src/main_window_tool_bar.c:91
 msgid "Extract"
 msgstr ""
 
-#: ../src/extract_dialog.c:105
+#: ../src/extract_dialog.c:110
 msgid "Extract archive"
 msgstr ""
 
@@ -114,6 +118,6 @@
 msgid "_Help"
 msgstr ""
 
-#: ../src/main_window_menu_bar.c:112 ../src/main_window_tool_bar.c:84
+#: ../src/main_window_menu_bar.c:117 ../src/main_window_tool_bar.c:88
 msgid "Add"
 msgstr ""

Modified: xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -33,6 +33,8 @@
 
 void
 xa_extract_dialog_option_toggled (GtkWidget *widget, gpointer data);
+void
+xa_extract_dialog_option_child_notify(GtkWidget *widget, GParamSpec *, gpointer data);
 
 GType
 xa_extract_archive_dialog_get_type ()
@@ -102,7 +104,7 @@
 xa_extract_archive_dialog_new(LXAArchiveSupport *support, LXAArchive *archive, gboolean sel_option)
 {
 	GSList *extract_options;
-	GtkWidget *test;
+	GtkWidget *test, *hbox;
 	XAExtractArchiveDialog *dialog;
 
 	dialog = g_object_new(xa_extract_archive_dialog_get_type(), "title", _("Extract archive"), "action", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "do-overwrite-confirmation", TRUE, NULL);
@@ -127,8 +129,15 @@
 					gtk_box_pack_start(GTK_BOX(r_vbox), test, FALSE, FALSE, 0);
 					break;
 				case (G_TYPE_STRING): /* TODO: Add text-field */
+					hbox = gtk_hbox_new(FALSE, 0);
 					test = gtk_label_new(g_param_spec_get_nick(G_PARAM_SPEC(extract_options->data)));
-					gtk_box_pack_start(GTK_BOX(r_vbox), test, FALSE, FALSE, 0);
+					gtk_box_pack_start(GTK_BOX(hbox), test, FALSE, FALSE, 0);
+
+					test = gtk_entry_new();
+					gtk_box_pack_start(GTK_BOX(hbox), test, FALSE, FALSE, 0);
+
+					g_signal_connect(G_OBJECT(test), "child_notify", G_CALLBACK(xa_extract_dialog_option_child_notify), (void *)g_param_spec_get_name(G_PARAM_SPEC(extract_options->data)));
+					gtk_box_pack_start(GTK_BOX(r_vbox), hbox, FALSE, FALSE, 0);
 					break;
 			}
 			extract_options = extract_options->next;
@@ -152,3 +161,17 @@
 
 	g_free(val);
 }
+
+void
+xa_extract_dialog_option_child_notify (GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+	GValue *val = g_new0(GValue, 1);
+	gboolean active;
+	if(strcmp(g_param_spec_get_name(pspec), "text"))
+	{
+		val = g_value_init(val, G_TYPE_STRING);
+		g_object_get_property(G_OBJECT(widget), "text", val);
+		g_object_set_property(G_OBJECT(XA_EXTRACT_ARCHIVE_DIALOG(gtk_widget_get_ancestor(widget, GTK_TYPE_DIALOG))->support), (gchar *)data, val);
+	}
+	g_free(val);
+}

Modified: xarchiver/branches/xarchiver-psybsd/src/main.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -91,7 +91,7 @@
 	gint result = 0;
 	GtkWidget *dialog = NULL;
 	GtkWidget *main_window = NULL;
-	LXAArchive *lpArchive;
+	LXAArchive *lp_archive;
 	LXAArchiveSupport *lpSupport;
 	GError *cli_error = NULL;
 	gint i = 0;
@@ -133,31 +133,31 @@
 		}
 		for(i = 1; i < argc; i++)
 		{
-			if(!lxa_open_archive(argv[i], &lpArchive))
+			if(!lxa_open_archive(argv[i], &lp_archive))
 			{
-				g_signal_connect(G_OBJECT(lpArchive), "lxa_status_changed", G_CALLBACK(xa_archive_status_changed), NULL);
+				g_signal_connect(G_OBJECT(lp_archive), "lxa_status_changed", G_CALLBACK(xa_archive_status_changed), NULL);
 				opened_archives++;
-				lpSupport = lxa_get_support_for_mime(lpArchive->mime);
+				lpSupport = lxa_get_support_for_mime(lp_archive->mime);
 				if(!extract_archive_path)
   			{
-					dialog = xa_extract_archive_dialog_new(lpSupport, lpArchive, FALSE);
+					dialog = xa_extract_archive_dialog_new(lpSupport, lp_archive, FALSE);
 					result = gtk_dialog_run (GTK_DIALOG (dialog) );
 					if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
 					{
 						gtk_widget_destroy (GTK_WIDGET (dialog) );
-						lxa_close_archive(lpArchive);
+						lxa_close_archive(lp_archive);
 						opened_archives--;
 					}
 					if(result == GTK_RESPONSE_OK)
 					{
 						extract_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-						lxa_archive_support_extract(lpSupport, lpArchive, extract_archive_path, NULL);
+						lxa_archive_support_extract(lpSupport, lp_archive, extract_archive_path, NULL);
 						g_free(extract_archive_path);
 						extract_archive_path = NULL;
 					}
 				}
 				else
-					lxa_archive_support_extract(lpSupport, lpArchive, extract_archive_path, NULL);
+					lxa_archive_support_extract(lpSupport, lp_archive, extract_archive_path, NULL);
 			}
 		}
 	}
@@ -177,7 +177,7 @@
 				add_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
 				gtk_widget_destroy (GTK_WIDGET (dialog) );
 			}
-			if(lxa_new_archive(add_archive_path, TRUE, NULL, &lpArchive))
+			if(lxa_new_archive(add_archive_path, TRUE, NULL, &lp_archive))
 			{
 				/* 
 				 * Could not create archive (mime type unsupported) 
@@ -193,7 +193,7 @@
 		}
 		else
 		{
-			if(lxa_open_archive(add_archive_path, &lpArchive))
+			if(lxa_open_archive(add_archive_path, &lp_archive))
 			{
 				/*
 				 * Could not open archive (mime type not supported or file did not exist)
@@ -208,18 +208,21 @@
 			else
 				opened_archives++;
 		}
-		g_signal_connect(G_OBJECT(lpArchive), "lxa_status_changed", G_CALLBACK(xa_archive_status_changed), NULL);
+		g_signal_connect(G_OBJECT(lp_archive), "lxa_status_changed", G_CALLBACK(xa_archive_status_changed), NULL);
 		GSList *files = NULL;
 		for(i = 1; i < argc; i++)
 		{
 			files = g_slist_prepend(files, argv[i]);
 		}
-		lpSupport = lxa_get_support_for_mime(lpArchive->mime);
-		lxa_archive_support_add(lpSupport, lpArchive, files);
+		lpSupport = lxa_get_support_for_mime(lp_archive->mime);
+		lxa_archive_support_add(lpSupport, lp_archive, files);
 	}
 
 	if(!new_archive && !add_archive_path && !extract_archive && !extract_archive_path)
 	{
+		if(argc > 1)
+			lxa_open_archive(argv[1], &lp_xa_archive);
+		
 		/* Show main window */
 		main_window = xa_main_window_new();
 		gtk_widget_set_size_request(main_window, 400, 300);

Modified: xarchiver/branches/xarchiver-psybsd/src/main.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.h	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main.h	2006-09-03 23:19:48 UTC (rev 23069)
@@ -0,0 +1,2 @@
+static LXAArchive *lp_xa_archive = NULL;
+

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -24,7 +24,10 @@
 #include "main_window_tool_bar.h"
 #include "main_window_status_bar.h"
 #include "main_window.h"
+#include "new_dialog.h"
 
+#include "main.h"
+
 static void
 xa_main_window_class_init(XAMainWindowClass *);
 
@@ -99,11 +102,11 @@
 xa_main_window_find_image(gchar *filename, GtkIconSize size)
 {
 	GError *error = NULL;
-    GtkWidget *file_image;
+	GtkWidget *file_image;
 	gchar *path;
 	path = g_strconcat(DATADIR, "/xarchiver/pixmaps/", filename, NULL);
 	GdkPixbuf *file_pixbuf = gdk_pixbuf_new_from_file(path, &error);
-	if(!file_pixbuf)
+	if(error)
 	{
 		/*
 		* perhaps xarchiver has not been installed and is being executed from source dir
@@ -112,17 +115,82 @@
 		error = NULL;
 		path = g_strconcat("./pixmaps/", filename, NULL);
 		file_pixbuf = gdk_pixbuf_new_from_file(path, &error);
-    }
-    if(file_pixbuf)
-    {
+	}
+	if(file_pixbuf)
+	{
 		file_image = gtk_image_new_from_pixbuf(file_pixbuf);
 		g_object_unref(file_pixbuf);
-    }
-    else
+	}
+	else
 	{
 		g_free(error);
 		file_image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, size);
-    }
-    g_free(path);
-    return file_image;
+	}
+	g_free(path);
+	return file_image;
 }
+
+void
+cb_xa_main_new_archive(GtkWidget *widget, gpointer userdata)
+{
+	GtkWidget *dialog = NULL;
+	gchar *new_archive_path = NULL;
+	gint result = 0;
+	
+	dialog = xa_new_archive_dialog_new();
+	result = gtk_dialog_run (GTK_DIALOG (dialog) );
+	if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
+	{
+		gtk_widget_destroy (GTK_WIDGET (dialog) );
+		return;
+	}
+	if(result == GTK_RESPONSE_OK)
+	{
+		new_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+		if(lp_xa_archive)
+		{
+			g_object_unref(lp_xa_archive);
+			lp_xa_archive = NULL;
+		}
+		if(!lxa_new_archive(new_archive_path, TRUE, NULL, &lp_xa_archive))
+		{
+			g_debug("Archive opened");
+		}
+		gtk_widget_destroy (GTK_WIDGET (dialog) );
+	}
+}
+
+void
+cb_xa_main_open_archive(GtkWidget *widget, gpointer userdata)
+{
+	GtkWidget *dialog = NULL;
+	gchar *open_archive_path = NULL;
+	gint result = 0;
+	
+	dialog = gtk_file_chooser_dialog_new(_("Open archive"), 
+	                                     GTK_WINDOW(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)),
+																			 GTK_FILE_CHOOSER_ACTION_OPEN,
+																			 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+																			 GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+	result = gtk_dialog_run (GTK_DIALOG (dialog) );
+	if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
+	{
+		gtk_widget_destroy (GTK_WIDGET (dialog) );
+		return;
+	}
+	if(result == GTK_RESPONSE_OK)
+	{
+		open_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+		if(lp_xa_archive)
+		{
+			g_object_unref(lp_xa_archive);
+			lp_xa_archive = NULL;
+		}
+		if(!lxa_open_archive(open_archive_path, &lp_xa_archive))
+		{
+			g_debug("Archive opened");
+		}
+		gtk_widget_destroy (GTK_WIDGET (dialog) );
+	}
+
+}

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h	2006-09-03 23:19:48 UTC (rev 23069)
@@ -47,6 +47,7 @@
 	GtkWidget *menubar;
 	GtkWidget *toolbar;
 	GtkWidget *statusbar;
+	LXAArchive *archive;
 };
 
 typedef struct _XAMainWindowClass XAMainWindowClass;
@@ -59,5 +60,8 @@
 GtkWidget *xa_main_window_new();
 GtkWidget *xa_main_window_find_image(gchar *, GtkIconSize);
 
+void cb_xa_main_new_archive(GtkWidget *widget, gpointer userdata);
+void cb_xa_main_open_archive(GtkWidget *widget, gpointer userdata);
+
 G_END_DECLS
 #endif /* __XARCHIVER_MAIN_WINDOW_H__ */

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window_menu_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window_menu_bar.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window_menu_bar.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -107,6 +107,11 @@
 	menubar->menu_item_quit = gtk_image_menu_item_new_from_stock("gtk-quit", accel_group);
 	gtk_container_add(GTK_CONTAINER(menubar->menu_archive), menubar->menu_item_quit);
 
+	g_signal_connect(G_OBJECT(menubar->menu_item_new), "activate", G_CALLBACK(cb_xa_main_new_archive), NULL);
+	g_signal_connect(G_OBJECT(menubar->menu_item_open), "activate", G_CALLBACK(cb_xa_main_open_archive), NULL);
+	/* g_signal_connect(G_OBJECT(menubar->menu_item_properties), "activate", NULL, NULL);*/
+	g_signal_connect(G_OBJECT(menubar->menu_item_quit), "activate", G_CALLBACK(gtk_main_quit), NULL);
+
 /* Action menu */
 	tmp_image = xa_main_window_find_image("add_button.png", GTK_ICON_SIZE_MENU);
 	menubar->menu_item_add = gtk_image_menu_item_new_with_mnemonic(_("Add"));

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window_tool_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window_tool_bar.c	2006-09-03 22:22:00 UTC (rev 23068)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window_tool_bar.c	2006-09-03 23:19:48 UTC (rev 23069)
@@ -20,8 +20,8 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <libxarchiver/libxarchiver.h>
+#include "main_window.h"
 #include "main_window_tool_bar.h"
-#include "main_window.h"
 
 #include "add_dialog.h"
 #include "new_dialog.h"
@@ -77,6 +77,10 @@
 
 	gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(toolbar->tool_item_new));
 	gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(toolbar->tool_item_open));
+
+	g_signal_connect(G_OBJECT(toolbar->tool_item_new), "clicked", G_CALLBACK(cb_xa_main_new_archive), NULL);
+	g_signal_connect(G_OBJECT(toolbar->tool_item_open), "clicked", G_CALLBACK(cb_xa_main_open_archive), NULL);
+
 	gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(separator));
 
 	/* contents of 'action' pane */
@@ -99,9 +103,10 @@
 GtkWidget *
 xa_main_window_tool_bar_new()
 {
-	GtkWidget *toolbar;
+	XAMainWindowToolBar *toolbar;
 
 	toolbar = g_object_new(xa_main_window_tool_bar_get_type(), NULL);
 
-	return toolbar;
+
+	return GTK_WIDGET(toolbar);
 }



More information about the Xfce4-commits mailing list