[Xfce4-commits] r24248 - in squeeze/trunk: libsqueeze src
Stephan Arts
stephan at xfce.org
Wed Jan 3 00:03:40 CET 2007
Author: stephan
Date: 2007-01-02 23:03:39 +0000 (Tue, 02 Jan 2007)
New Revision: 24248
Modified:
squeeze/trunk/libsqueeze/archive.c
squeeze/trunk/libsqueeze/internals.c
squeeze/trunk/libsqueeze/internals.h
squeeze/trunk/libsqueeze/libsqueeze.c
squeeze/trunk/libsqueeze/libsqueeze.h
squeeze/trunk/src/main.c
squeeze/trunk/src/main_window.c
squeeze/trunk/src/notebook.c
Log:
Files can't be opened more then once in the lib.
GUI can display them more then once though
-- Fixes bug #2636
Fixed reference counting of ThunarVfsPath.
Fixed reference counting of LSQArchive.
Fixed close_active_archive code
Modified: squeeze/trunk/libsqueeze/archive.c
===================================================================
--- squeeze/trunk/libsqueeze/archive.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/libsqueeze/archive.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -223,12 +223,14 @@
kill ( archive->child_pid , SIGHUP);
break;
}
+ lsq_opened_archive_list = g_slist_remove(lsq_opened_archive_list, object);
}
LSQArchive *
lsq_archive_new(gchar *path, const gchar *mime)
{
LSQArchive *archive;
+ gchar *base = NULL;
archive = g_object_new(lsq_archive_get_type(), NULL);
@@ -249,7 +251,14 @@
}
else
{
- archive->mime_info = thunar_vfs_mime_database_get_info(lsq_mime_database, mime);
+ if(mime)
+ archive->mime_info = thunar_vfs_mime_database_get_info(lsq_mime_database, mime);
+ else
+ {
+ base = g_path_get_basename(path);
+ archive->mime_info = thunar_vfs_mime_database_get_info_for_file(lsq_mime_database, path, base);
+ g_free(base);
+ }
}
if(!lsq_get_support_for_mime(archive->mime_info))
Modified: squeeze/trunk/libsqueeze/internals.c
===================================================================
--- squeeze/trunk/libsqueeze/internals.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/libsqueeze/internals.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -36,6 +36,10 @@
#include <sys/types.h>
#include <sys/wait.h>
+static gint
+lsq_opened_archives_lookup_archive(gconstpointer open_archive, gconstpointer path);
+
+
void
lsq_default_child_watch_func(GPid pid, gint status, gpointer data)
{
@@ -54,6 +58,19 @@
}
else
{
+ if(archive->status == LSQ_ARCHIVESTATUS_ADD)
+ {
+ if(!archive->file_info)
+ {
+ archive->file_info = thunar_vfs_info_new_for_path(archive->path_info, NULL);
+ if(archive->file_info)
+ {
+ thunar_vfs_mime_info_unref(archive->mime_info);
+ archive->mime_info = archive->file_info->mime_info;
+ thunar_vfs_mime_info_ref(archive->mime_info);
+ }
+ }
+ }
if(archive->status != LSQ_ARCHIVESTATUS_REFRESH)
lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
}
@@ -136,3 +153,32 @@
}
return concat_str;
}
+
+LSQArchive *
+lsq_opened_archive_get_archive(gchar *path)
+{
+ GSList *result = g_slist_find_custom(lsq_opened_archive_list, path, lsq_opened_archives_lookup_archive);
+ if(result)
+ {
+ g_object_ref(result->data);
+ return result->data;
+ }
+ return NULL;
+}
+
+
+static gint
+lsq_opened_archives_lookup_archive(gconstpointer open_archive, gconstpointer path)
+{
+ ThunarVfsPath *path_info = thunar_vfs_path_new(path, NULL);
+ if(thunar_vfs_path_equal(((LSQArchive *)open_archive)->path_info, path_info))
+ {
+ thunar_vfs_path_unref(path_info);
+ return 0;
+ }
+ else
+ {
+ thunar_vfs_path_unref(path_info);
+ return 1;
+ }
+}
Modified: squeeze/trunk/libsqueeze/internals.h
===================================================================
--- squeeze/trunk/libsqueeze/internals.h 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/libsqueeze/internals.h 2007-01-02 23:03:39 UTC (rev 24248)
@@ -18,6 +18,7 @@
const gchar *lsq_tmp_dir;
GSList *lsq_archive_support_list;
+GSList *lsq_opened_archive_list;
/*
* gint
@@ -37,4 +38,7 @@
gchar *
lsq_concat_filenames(GSList *filenames) G_GNUC_INTERNAL;
+LSQArchive *
+lsq_opened_archive_get_archive(gchar *path) G_GNUC_INTERNAL;
+
ThunarVfsMimeDatabase *lsq_mime_database;
Modified: squeeze/trunk/libsqueeze/libsqueeze.c
===================================================================
--- squeeze/trunk/libsqueeze/libsqueeze.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/libsqueeze/libsqueeze.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -46,9 +46,10 @@
}
void
-lsq_destroy()
+lsq_shutdown()
{
g_slist_foreach(lsq_archive_support_list, (GFunc)g_object_unref, NULL);
+ g_slist_foreach(lsq_opened_archive_list, (GFunc)g_object_unref, NULL);
g_object_unref(lsq_mime_database);
}
@@ -90,7 +91,12 @@
return 1;
}
- LSQArchive *archive = lsq_archive_new(path, NULL);
+ LSQArchive *archive = lsq_opened_archive_get_archive(path);
+ if(!archive)
+ {
+ archive = lsq_archive_new(path, NULL);
+ lsq_opened_archive_list = g_slist_prepend(lsq_opened_archive_list, archive);
+ }
(*lp_archive) = archive;
if(!archive)
return 1;
Modified: squeeze/trunk/libsqueeze/libsqueeze.h
===================================================================
--- squeeze/trunk/libsqueeze/libsqueeze.h 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/libsqueeze/libsqueeze.h 2007-01-02 23:03:39 UTC (rev 24248)
@@ -32,9 +32,9 @@
/*
* void
- * lsq_destroy()
+ * lsq_shutdown()
*/
-void lsq_destroy();
+void lsq_shutdown();
/*
* gint
Modified: squeeze/trunk/src/main.c
===================================================================
--- squeeze/trunk/src/main.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/src/main.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -177,7 +177,7 @@
g_object_unref(sq_app);
gtk_main();
- lsq_destroy();
+ lsq_shutdown();
thunar_vfs_shutdown();
return 0;
Modified: squeeze/trunk/src/main_window.c
===================================================================
--- squeeze/trunk/src/main_window.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/src/main_window.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -700,7 +700,8 @@
{
gtk_widget_hide(dialog);
filenames = sq_add_dialog_get_filenames(SQ_ADD_DIALOG(dialog));
- lsq_archive_support_add(lp_support, lp_archive, filenames);
+ if(filenames)
+ lsq_archive_support_add(lp_support, lp_archive, filenames);
}
gtk_widget_destroy (dialog);
}
Modified: squeeze/trunk/src/notebook.c
===================================================================
--- squeeze/trunk/src/notebook.c 2007-01-02 19:52:16 UTC (rev 24247)
+++ squeeze/trunk/src/notebook.c 2007-01-02 23:03:39 UTC (rev 24248)
@@ -176,6 +176,7 @@
static void
sq_notebook_finalize(GObject *object)
{
+ /* TODO: unref archive_stores */
}
GtkWidget *
@@ -395,6 +396,22 @@
{
GtkNotebook *_notebook = GTK_NOTEBOOK(notebook);
gint n = gtk_notebook_get_current_page(_notebook);
+
+ GtkWidget *child = gtk_notebook_get_nth_page(_notebook, n);
+
+ GtkWidget *treeview = gtk_bin_get_child(GTK_BIN(child));
+ GtkTreeModel *archive_store = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
+
+ LSQArchive *archive = sq_archive_store_get_archive(SQ_ARCHIVE_STORE(archive_store));
+
+ if(archive)
+ g_signal_handlers_disconnect_by_func(archive, cb_notebook_archive_refreshed, treeview);
+ if(SQ_NOTEBOOK(notebook)->navigation_bar)
+ sq_navigation_bar_set_store(((SQNotebook *)notebook)->navigation_bar, NULL);
+ g_object_unref(archive_store);
+
+ lsq_close_archive(archive);
+
gtk_notebook_remove_page(_notebook, n);
g_signal_emit(G_OBJECT(notebook), sq_notebook_signals[SQ_NOTEBOOK_SIGNAL_ARCHIVE_REMOVED], 0, NULL);
}
@@ -491,7 +508,10 @@
cb_sq_notebook_page_removed(SQNotebook *notebook, gpointer data)
{
if(!gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)))
- sq_navigation_bar_set_store(notebook->navigation_bar, NULL);
+ {
+ if(notebook->navigation_bar)
+ sq_navigation_bar_set_store(notebook->navigation_bar, NULL);
+ }
}
static void
More information about the Xfce4-commits
mailing list