[Xfce4-commits] <squeeze:peter/libsqueeze> Use the api in the application
Peter de Ridder
noreply at xfce.org
Sun Feb 3 21:46:06 CET 2013
Updating branch refs/heads/peter/libsqueeze
to 40a75344fa2918b78db21818bdb6bab987bee012 (commit)
from d62f93326d0b937d53cbb2b80b0c8e2862421cc6 (commit)
commit 40a75344fa2918b78db21818bdb6bab987bee012
Author: Peter de Ridder <peter at xfce.org>
Date: Sun Jun 17 17:49:12 2012 +0200
Use the api in the application
src/application.c | 32 ++++++++++++++-------
src/archive_store.c | 2 +-
src/extract_dialog.c | 1 +
src/main_window.c | 75 ++++++++++++++++++++++++++++++++++----------------
src/new_dialog.c | 8 +++--
src/notebook.c | 4 +-
src/tool_bar.c | 2 +-
7 files changed, 82 insertions(+), 42 deletions(-)
diff --git a/src/application.c b/src/application.c
index 2e2688b..8bb2a85 100644
--- a/src/application.c
+++ b/src/application.c
@@ -149,9 +149,12 @@ gint
sq_application_extract_archive(SQApplication *app, GFile *file, gchar *dest_path)
{
GtkWidget *dialog = NULL;
- LSQArchive *lp_archive = NULL;
+ LSQArchive *archive;
GtkWidget *message_dialog;
- if(lsq_open_archive(file, &lp_archive))
+ LSQExecuteContext *operation;
+
+ archive = lsq_open_archive( file, NULL );
+ if ( NULL == archive )
{
/*
* Could not open archive (mime type not supported or file did not exist)
@@ -165,7 +168,7 @@ sq_application_extract_archive(SQApplication *app, GFile *file, gchar *dest_path
}
if(!dest_path)
{
- GtkWidget *extr_dialog = sq_extract_archive_dialog_new(lp_archive, 0);
+ GtkWidget *extr_dialog = sq_extract_archive_dialog_new( archive, 0 );
gint result = gtk_dialog_run (GTK_DIALOG (extr_dialog) );
if(result == GTK_RESPONSE_OK)
{
@@ -176,12 +179,13 @@ sq_application_extract_archive(SQApplication *app, GFile *file, gchar *dest_path
}
if(!dest_path)
{
- lsq_close_archive(lp_archive);
+ lsq_close_archive( archive );
return 1;
}
- message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
+ message_dialog = sq_message_dialog_new( GTK_WINDOW_TOPLEVEL, archive );
gtk_widget_show(message_dialog);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path))
+ operation = lsq_archive_operate( archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -195,6 +199,7 @@ sq_application_extract_archive(SQApplication *app, GFile *file, gchar *dest_path
}
}
+ g_object_unref( operation );
g_object_ref(app);
return 0;
}
@@ -204,8 +209,9 @@ sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
{
GtkWidget *dialog = NULL;
gint result = 0;
- LSQArchive *lp_archive = NULL;
+ LSQArchive *archive;
GtkWidget *message_dialog;
+ LSQExecuteContext *operation;
if(!file)
{
@@ -226,7 +232,8 @@ sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
file = sq_new_archive_dialog_get_file(SQ_NEW_ARCHIVE_DIALOG(dialog));
gtk_widget_destroy (GTK_WIDGET (dialog) );
}
- if(lsq_new_archive(file, TRUE, &lp_archive))
+ archive = lsq_new_archive( file, NULL, TRUE, NULL );
+ if ( NULL == archive )
{
/*
* Could not create archive (mime type unsupported)
@@ -242,7 +249,8 @@ sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
}
else
{
- if(lsq_open_archive(file, &lp_archive))
+ archive = lsq_open_archive( file, NULL );
+ if ( NULL == archive )
{
/*
* Could not open archive (mime type not supported or file did not exist)
@@ -255,10 +263,11 @@ sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
return 1;
}
}
- message_dialog = sq_message_dialog_new(GTK_WINDOW_TOPLEVEL, lp_archive);
+ message_dialog = sq_message_dialog_new( GTK_WINDOW_TOPLEVEL, archive );
gtk_widget_show(message_dialog);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL))
+ operation = lsq_archive_operate( archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL, NULL, NULL );
+ if ( NULL == operation )
{
/* FIXME: show warning dialog */
GtkWidget *warning_dialog = gtk_message_dialog_new(
@@ -270,6 +279,7 @@ sq_application_new_archive(SQApplication *app, GFile *file, GSList *files)
gtk_dialog_run (GTK_DIALOG (warning_dialog) );
gtk_widget_destroy(warning_dialog);
}
+ g_object_unref( operation );
g_object_ref(app);
return 0;
}
diff --git a/src/archive_store.c b/src/archive_store.c
index 968c992..63614de 100644
--- a/src/archive_store.c
+++ b/src/archive_store.c
@@ -1014,7 +1014,7 @@ sq_archive_insertionsort(SQArchiveStore *store, gint left, gint right)
static GIcon *
sq_archive_store_get_icon_name_for_iter(SQArchiveStore *store, LSQArchiveIter *iter)
{
- return g_content_type_get_icon(lsq_archive_iter_get_contenttype(iter));
+ return g_content_type_get_icon( lsq_archive_iter_get_content_type( iter ) );
}
GtkTreeModel *
diff --git a/src/extract_dialog.c b/src/extract_dialog.c
index 630af18..7bf26a1 100644
--- a/src/extract_dialog.c
+++ b/src/extract_dialog.c
@@ -22,6 +22,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <libxfce4util/libxfce4util.h>
#include <libsqueeze/libsqueeze.h>
#include "extract_dialog.h"
diff --git a/src/main_window.c b/src/main_window.c
index f50029c..f283857 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -660,28 +660,32 @@ cb_sq_main_new_archive(GtkWidget *widget, gpointer userdata)
GtkWidget *dialog = sq_new_archive_dialog_new();
GFile *file = NULL;
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
- LSQArchive *archive = NULL;
- LSQSupportType support_mask = 0;
+ LSQArchive *archive;
+ //LSQSupportType support_mask = 0;
gint result = 0;
result = gtk_dialog_run (GTK_DIALOG (dialog) );
- if(result == GTK_RESPONSE_CANCEL || result == GTK_RESPONSE_DELETE_EVENT)
+ switch ( result )
{
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
gtk_widget_destroy (GTK_WIDGET (dialog) );
return;
- }
- if(result == GTK_RESPONSE_OK)
- {
+
+ case GTK_RESPONSE_OK:
file = sq_new_archive_dialog_get_file(SQ_NEW_ARCHIVE_DIALOG(dialog));
- if(!lsq_new_archive(file, TRUE, &archive))
+ archive = lsq_new_archive( file, NULL, TRUE, NULL );
+ if ( NULL != archive )
{
- support_mask = lsq_archive_get_support_mask(archive);
+ //support_mask = lsq_archive_get_support_mask(archive);
sq_notebook_add_archive(SQ_NOTEBOOK(window->notebook), archive, TRUE);
+ /*
if(support_mask & LSQ_SUPPORT_FILES)
gtk_widget_set_sensitive(window->menubar.menu_item_add_files, TRUE);
if(support_mask & LSQ_SUPPORT_FOLDERS)
gtk_widget_set_sensitive(window->menubar.menu_item_add_folders, TRUE);
+ */
gtk_widget_set_sensitive(window->menubar.menu_item_extract, TRUE);
gtk_widget_set_sensitive(window->menubar.menu_item_remove, TRUE);
@@ -689,10 +693,12 @@ cb_sq_main_new_archive(GtkWidget *widget, gpointer userdata)
if(window->tool_bar)
{
+ /*
if(support_mask & LSQ_SUPPORT_FILES)
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add_files), TRUE);
if(support_mask & LSQ_SUPPORT_FOLDERS)
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add_folders), TRUE);
+ */
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_extract), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_remove), TRUE);
@@ -802,6 +808,7 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
gchar *extract_archive_path = NULL;
gint result = 0;
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
+ LSQExecuteContext *operation;
LSQArchive *lp_archive = NULL;
@@ -822,8 +829,9 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
lsq_iter_slist_free(filenames);
filenames = NULL;
}
- strv = lsq_iter_list_to_strv(filenames);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path))
+ strv = lsq_iter_slist_to_strv( filenames );
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog;
g_strfreev(strv);
@@ -840,9 +848,10 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
}
else
g_strfreev(strv);
- g_free(extract_archive_path);
- extract_archive_path = NULL;
+ g_object_unref( operation );
}
+ g_free(extract_archive_path);
+ extract_archive_path = NULL;
gtk_widget_destroy (dialog);
lsq_iter_slist_free(filenames);
@@ -852,6 +861,7 @@ static void
cb_sq_main_add_files_to_archive(GtkWidget *widget, gpointer userdata)
{
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
+ LSQExecuteContext *operation;
LSQArchive *lp_archive = NULL;
GtkWidget *dialog = NULL;
@@ -875,8 +885,9 @@ cb_sq_main_add_files_to_archive(GtkWidget *widget, gpointer userdata)
filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
if(filenames)
{
- gchar **strv = lsq_iter_list_to_strv(filenames);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL))
+ gchar **strv = lsq_iter_slist_to_strv( filenames );
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog;
g_strfreev(strv);
@@ -890,6 +901,7 @@ cb_sq_main_add_files_to_archive(GtkWidget *widget, gpointer userdata)
}
else
g_strfreev(strv);
+ g_object_unref( operation );
}
}
gtk_widget_destroy (dialog);
@@ -899,6 +911,7 @@ static void
cb_sq_main_add_folders_to_archive(GtkWidget *widget, gpointer userdata)
{
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
+ LSQExecuteContext *operation;
LSQArchive *lp_archive = NULL;
GtkWidget *dialog = NULL;
@@ -922,8 +935,9 @@ cb_sq_main_add_folders_to_archive(GtkWidget *widget, gpointer userdata)
filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
if(filenames)
{
- gchar **strv = lsq_iter_list_to_strv(filenames);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL))
+ gchar **strv = lsq_iter_slist_to_strv( filenames );
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog;
g_strfreev(strv);
@@ -938,6 +952,7 @@ cb_sq_main_add_folders_to_archive(GtkWidget *widget, gpointer userdata)
}
else
g_strfreev(strv);
+ g_object_unref( operation );
}
}
gtk_widget_destroy (dialog);
@@ -952,6 +967,7 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
gint result = 0;
gchar **strv;
GSList *filenames = sq_notebook_get_selected_items(SQ_NOTEBOOK(window->notebook));
+ LSQExecuteContext *operation;
if(filenames)
{
@@ -962,8 +978,9 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
gtk_widget_hide(dialog);
sq_notebook_get_active_archive(SQ_NOTEBOOK(window->notebook), &lp_archive);
/* gtk_tree_view_set_model(sq_notebook_get_active_tree_view(SQ_NOTEBOOK(window->notebook)), NULL); */
- strv = lsq_iter_list_to_strv(filenames);
- if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE, strv, NULL))
+ strv = lsq_iter_slist_to_strv( filenames );
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_REMOVE, strv, NULL, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog;
g_strfreev(strv);
@@ -977,6 +994,7 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
}
else
g_strfreev(strv);
+ g_object_unref( operation );
}
gtk_widget_destroy (dialog);
@@ -1004,7 +1022,7 @@ cb_sq_main_refresh_archive(GtkWidget *widget, gpointer userdata)
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
SQArchiveStore *store = sq_notebook_get_active_store(SQ_NOTEBOOK(window->notebook));
LSQArchive *archive = sq_archive_store_get_archive(store);
- lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
+ g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL ) );
}
static void
@@ -1252,6 +1270,7 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
GtkWidget *extr_dialog = NULL;
gint result;
gchar **strv;
+ LSQExecuteContext *operation = NULL;
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 20);
gtk_widget_show(label);
result = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -1265,7 +1284,8 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
{
case GTK_RESPONSE_OK: /* VIEW */
sq_notebook_get_active_archive(SQ_NOTEBOOK(notebook), &lp_archive);
- if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_OPEN, strv, NULL))
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_OPEN, strv, NULL, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog = gtk_message_dialog_new(window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("Squeeze cannot view this file.\nthe application to support this is missing."));
if(warning_dialog)
@@ -1288,7 +1308,8 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
g_strfreev(strv);
strv = NULL;
}
- if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path))
+ operation = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path, NULL, NULL );
+ if ( NULL == operation )
{
GtkWidget *warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1309,15 +1330,17 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
break;
}
g_strfreev(strv);
+ g_object_unref( operation );
gtk_widget_destroy(dialog);
}
gint
sq_main_window_open_archive(SQMainWindow *window, GFile *file, gint replace)
{
- LSQArchive *archive = NULL;
+ LSQArchive *archive;
- if(!lsq_open_archive(file, &archive))
+ archive = lsq_open_archive( file, NULL );
+ if ( NULL != archive )
{
if(replace < 0)
sq_notebook_add_archive(SQ_NOTEBOOK(window->notebook), archive, FALSE);
@@ -1386,7 +1409,7 @@ static void
cb_sq_main_window_notebook_state_changed(SQNotebook *notebook, LSQArchive *archive, gpointer userdata)
{
SQMainWindow *window = SQ_MAIN_WINDOW(userdata);
- LSQSupportType support_mask = lsq_archive_get_support_mask(archive);
+ //LSQSupportType support_mask = lsq_archive_get_support_mask(archive);
guint context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(window->statusbar), "Window Statusbar");
const gchar *message = lsq_archive_get_state_msg(archive);
@@ -1396,10 +1419,12 @@ cb_sq_main_window_notebook_state_changed(SQNotebook *notebook, LSQArchive *archi
message = _("Done");
if(window->menu_bar)
{
+ /*
if(support_mask & LSQ_SUPPORT_FILES)
gtk_widget_set_sensitive(window->menubar.menu_item_add_files, TRUE);
if(support_mask & LSQ_SUPPORT_FOLDERS)
gtk_widget_set_sensitive(window->menubar.menu_item_add_folders, TRUE);
+ */
gtk_widget_set_sensitive(window->menubar.menu_item_extract, TRUE);
gtk_widget_set_sensitive(window->menubar.menu_item_remove, TRUE);
gtk_widget_set_sensitive(window->menubar.menu_item_refresh, TRUE);
@@ -1407,10 +1432,12 @@ cb_sq_main_window_notebook_state_changed(SQNotebook *notebook, LSQArchive *archi
if(window->tool_bar)
{
+ /*
if(support_mask & LSQ_SUPPORT_FILES)
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add_files), TRUE);
if(support_mask & LSQ_SUPPORT_FOLDERS)
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add_folders), TRUE);
+ */
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_extract), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_remove), TRUE);
diff --git a/src/new_dialog.c b/src/new_dialog.c
index d1e1205..d76aae4 100644
--- a/src/new_dialog.c
+++ b/src/new_dialog.c
@@ -67,7 +67,7 @@ static void
sq_new_archive_dialog_init(SQNewArchiveDialog *dialog)
{
GtkWidget *hbox = gtk_hbox_new(FALSE, 10);
- GSList *_supported_mime_types;
+ //GSList *_supported_mime_types;
gtk_box_pack_start (GTK_BOX (hbox),gtk_label_new (_("Archive type:")),FALSE, FALSE, 0);
dialog->archive_types_combo = gtk_combo_box_new_text();
@@ -75,14 +75,16 @@ sq_new_archive_dialog_init(SQNewArchiveDialog *dialog)
gtk_widget_show_all(hbox);
+ /*
dialog->supported_mime_types = lsq_get_supported_mime_types(LSQ_COMMAND_TYPE_ADD);
_supported_mime_types = dialog->supported_mime_types;
+ */
dialog->file_filter = gtk_file_filter_new();
gtk_file_filter_set_name(dialog->file_filter, _("Archives"));
+ /*
while(_supported_mime_types)
{
- /*
gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->archive_types_combo),
lsq_mime_support_get_comment((LSQMimeSupport *)(_supported_mime_types->data)));
@@ -90,8 +92,8 @@ sq_new_archive_dialog_init(SQNewArchiveDialog *dialog)
lsq_mime_support_get_name((LSQMimeSupport *)(_supported_mime_types->data)));
_supported_mime_types = g_slist_next(_supported_mime_types);
- */
}
+ */
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, TRUE, 0);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
diff --git a/src/notebook.c b/src/notebook.c
index 2de6571..15e31a4 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -590,7 +590,7 @@ sq_notebook_add_archive(SQNotebook *notebook, LSQArchive *archive, gboolean new_
if(new_archive == FALSE)
{
- lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
+ g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL) );
}
g_free(filename);
g_free(filepath);
@@ -842,7 +842,7 @@ sq_notebook_page_set_archive(SQNotebook *notebook, LSQArchive *archive, gint n)
g_signal_connect(G_OBJECT(archive), "refreshed", G_CALLBACK(cb_notebook_archive_refreshed), treeview);
- lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
+ g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL ) );
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), store);
diff --git a/src/tool_bar.c b/src/tool_bar.c
index 68ad636..c0f1355 100644
--- a/src/tool_bar.c
+++ b/src/tool_bar.c
@@ -366,7 +366,7 @@ static void
cb_sq_tool_bar_refresh(GtkWidget *refresh_button, SQToolBar *tool_bar)
{
LSQArchive *archive = sq_archive_store_get_archive(SQ_NAVIGATION_BAR(tool_bar)->store);
- lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
+ g_object_unref( lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL ) );
}
static void
More information about the Xfce4-commits
mailing list