[Xfce4-commits] <squeeze:master> Reintroduced get_filename get_path convenience functions
Peter de Ridder
noreply at xfce.org
Tue Aug 23 22:04:01 CEST 2011
Updating branch refs/heads/master
to 7aaea0c7c6efd1ed84eb2d6d7c21e7cda6c9b817 (commit)
from c3dd62e9ca7e4de3d79fce5b4b63d7e34d2d9e16 (commit)
commit 7aaea0c7c6efd1ed84eb2d6d7c21e7cda6c9b817
Author: Peter de Ridder <peter at xfce.org>
Date: Tue Aug 23 22:01:19 2011 +0200
Reintroduced get_filename get_path convenience functions
libsqueeze/archive.c | 20 +++++++++++++++++++-
libsqueeze/archive.h | 4 +++-
libsqueeze/command-queue.c | 7 ++-----
src/extract_dialog.c | 5 ++++-
src/main_window.c | 4 +---
src/message_dialog.c | 5 ++++-
src/notebook.c | 7 ++++---
src/properties_dialog.c | 5 ++++-
8 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/libsqueeze/archive.c b/libsqueeze/archive.c
index e2c55f0..4aae474 100644
--- a/libsqueeze/archive.c
+++ b/libsqueeze/archive.c
@@ -294,8 +294,26 @@ lsq_archive_entry_properties_size(const LSQArchive *archive)
*
* Return value: filename string
*/
+gchar *
+lsq_archive_get_filename (const LSQArchive *archive)
+{
+ return g_file_get_basename(archive->priv->file);
+}
+
+/*
+ * lsq_archive_get_path:
+ * @archive: LSQArchive object
+ *
+ * Return value: filename string
+ */
+gchar *
+lsq_archive_get_path (const LSQArchive *archive)
+{
+ return g_file_get_path(archive->priv->file);
+}
+
GFile *
-lsq_archive_get_file (LSQArchive *archive)
+lsq_archive_get_file (const LSQArchive *archive)
{
return archive->priv->file;
}
diff --git a/libsqueeze/archive.h b/libsqueeze/archive.h
index b2ba3a5..e129227 100644
--- a/libsqueeze/archive.h
+++ b/libsqueeze/archive.h
@@ -93,6 +93,8 @@ struct _LSQArchiveClass
GType lsq_archive_get_type(void);
+gchar *lsq_archive_get_filename(const LSQArchive *archive);
+gchar *lsq_archive_get_path(const LSQArchive *archive);
const gchar *lsq_archive_get_mimetype(const LSQArchive *archive);
gboolean lsq_archive_exists(const LSQArchive *archive);
LSQSupportType lsq_archive_get_support_mask(const LSQArchive *archive);
@@ -103,7 +105,7 @@ void lsq_archive_state_changed(const LSQArchive *archive) G_GNUC_INTERNAL;
void lsq_archive_add_children(GSList *files);
gboolean lsq_archive_remove_file(LSQArchive *, const gchar *);
-GFile *lsq_archive_get_file(LSQArchive *);
+GFile *lsq_archive_get_file(const LSQArchive *);
gboolean lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **, const gchar *);
diff --git a/libsqueeze/command-queue.c b/libsqueeze/command-queue.c
index ee674f4..9bb4525 100644
--- a/libsqueeze/command-queue.c
+++ b/libsqueeze/command-queue.c
@@ -111,13 +111,12 @@ static const gchar *lsq_execute_context_get_temp_file(LSQExecuteContext *ctx)
static gchar *format_get_filename(const gchar *format, LSQExecuteContext *ctx)
{
- GFile *file = lsq_archive_get_file (ctx->archive);
if((format[0] == '%') && (format[2] == '\0'))
{
switch(format[1])
{
case 'a':
- return g_file_get_basename (file);
+ return lsq_archive_get_path (ctx->archive);
case 't':
return g_strdup(lsq_execute_context_get_temp_file(ctx));
}
@@ -131,7 +130,6 @@ static gchar **lsq_command_entry_to_argv(LSQCommandEntry *entry, LSQExecuteConte
guint size;
GSList *iter;
gchar **filei;
- GFile *file;
size = 2;
@@ -155,7 +153,6 @@ static gchar **lsq_command_entry_to_argv(LSQCommandEntry *entry, LSQExecuteConte
for(iter = entry->args; iter; iter = iter->next)
{
const gchar *arg = (const gchar*)iter->data;
- file = lsq_archive_get_file(ctx->archive);
if((arg[0] == '%') && (arg[2] == '\0'))
{
switch(arg[1])
@@ -170,7 +167,7 @@ static gchar **lsq_command_entry_to_argv(LSQCommandEntry *entry, LSQExecuteConte
}
break;
case 'a':
- *argi++ = g_file_get_path(file);
+ *argi++ = lsq_archive_get_path(ctx->archive);
break;
case 't':
*argi++ = g_strdup(lsq_execute_context_get_temp_file(ctx));
diff --git a/src/extract_dialog.c b/src/extract_dialog.c
index 0e34477..630af18 100644
--- a/src/extract_dialog.c
+++ b/src/extract_dialog.c
@@ -108,6 +108,7 @@ sq_extract_archive_dialog_new(LSQArchive *archive, gboolean sel_option)
{
SQExtractArchiveDialog *dialog;
GtkWidget *r_vbox;
+ gchar *filename;
gchar **filename_components;
dialog = g_object_new(sq_extract_archive_dialog_get_type(), "title", _("Extract archive"), "action", GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "do-overwrite-confirmation", TRUE, NULL);
@@ -130,7 +131,9 @@ sq_extract_archive_dialog_new(LSQArchive *archive, gboolean sel_option)
}
/* FIXME, does not work correctly when there are more dots in a filename then the one identifying the extention */
- filename_components = g_strsplit(g_file_get_basename(lsq_archive_get_file(archive)), ".", 2);
+ filename = lsq_archive_get_filename(archive);
+ filename_components = g_strsplit(filename, ".", 2);
+ g_free(filename);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename_components[0]);
g_strfreev(filename_components);
diff --git a/src/main_window.c b/src/main_window.c
index 04f8d22..1b95e0d 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -1156,12 +1156,10 @@ cb_sq_main_window_notebook_page_switched(SQNotebook *notebook, GtkNotebookPage *
SQMainWindow *window = SQ_MAIN_WINDOW(data);
guint context_id;
const gchar *message;
- GFile *file;
gchar *filename;
sq_notebook_page_get_archive(notebook, &lp_archive, page_nr);
- file = lsq_archive_get_file(lp_archive);
- filename = g_file_get_basename (file);
+ filename = lsq_archive_get_filename(lp_archive);
gtk_window_set_title(GTK_WINDOW(window), g_strconcat(PACKAGE_NAME, " - ", filename , NULL));
g_free (filename);
diff --git a/src/message_dialog.c b/src/message_dialog.c
index 55e8819..04599f4 100644
--- a/src/message_dialog.c
+++ b/src/message_dialog.c
@@ -157,6 +157,7 @@ GtkWidget *
sq_message_dialog_new(GtkWindowType type, LSQArchive *archive)
{
SQMessageDialog *dialog;
+ gchar *filename;
dialog = g_object_new(sq_message_dialog_get_type(),
"title", _("Archive manager"),
@@ -172,7 +173,9 @@ sq_message_dialog_new(GtkWindowType type, LSQArchive *archive)
g_timeout_add(200, (GSourceFunc)sq_message_dialog_progressbar_pulse, dialog);
- gtk_label_set_text(GTK_LABEL(dialog->message_label), g_file_get_path(lsq_archive_get_file(archive)));
+ filename = lsq_archive_get_filename(archive);
+ gtk_label_set_text(GTK_LABEL(dialog->message_label), filename);
+ g_free(filename);
return (GtkWidget*)dialog;
}
diff --git a/src/notebook.c b/src/notebook.c
index 85b2ec7..de09a7c 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -502,8 +502,8 @@ void
sq_notebook_add_archive(SQNotebook *notebook, LSQArchive *archive, gboolean new_archive)
{
GtkWidget *lbl_hbox = gtk_hbox_new(FALSE, 0);
- GFile *file = lsq_archive_get_file(archive);
- gchar *filename = g_file_get_basename(file);
+ gchar *filename = lsq_archive_get_filename(archive);
+ gchar *filepath = lsq_archive_get_path(archive);
GtkWidget *label = gtk_label_new(filename);
GtkWidget *archive_image = gtk_image_new_from_icon_name("unknown", GTK_ICON_SIZE_MENU);
GtkWidget *throbber = sq_throbber_new();
@@ -535,7 +535,7 @@ sq_notebook_add_archive(SQNotebook *notebook, LSQArchive *archive, gboolean new_
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_max_width_chars(GTK_LABEL(label), 20);
- gtk_tooltips_set_tip(notebook->tool_tips, label, g_file_get_basename(lsq_archive_get_file(archive)), NULL);
+ gtk_tooltips_set_tip(notebook->tool_tips, label, filepath, NULL);
tree_view = gtk_tree_view_new();
g_signal_connect(G_OBJECT(tree_view), "notify", G_CALLBACK(cb_sq_notebook_notify_proxy), notebook);
@@ -593,6 +593,7 @@ sq_notebook_add_archive(SQNotebook *notebook, LSQArchive *archive, gboolean new_
lsq_archive_operate(archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL);
}
g_free(filename);
+ g_free(filepath);
}
diff --git a/src/properties_dialog.c b/src/properties_dialog.c
index 7cd3de3..53a48a5 100644
--- a/src/properties_dialog.c
+++ b/src/properties_dialog.c
@@ -114,6 +114,7 @@ GtkWidget *
sq_properties_dialog_new(LSQArchive *archive, GtkIconTheme *icon_theme)
{
GtkWidget *dialog;
+ gchar *filename;
dialog = g_object_new(sq_properties_dialog_get_type(),
"title", _("Properties"),
@@ -125,7 +126,9 @@ sq_properties_dialog_new(LSQArchive *archive, GtkIconTheme *icon_theme)
GdkPixbuf *icon = gtk_icon_theme_load_icon(icon_theme, thunar_vfs_mime_info_lookup_icon_name(archive->mime_info, icon_theme), 48, 0, NULL);
gtk_image_set_from_pixbuf(GTK_IMAGE(((SQPropertiesDialog *)dialog)->icon_image), icon);
- gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->filename_label), lsq_archive_get_filename(archive));
+ filename = lsq_archive_get_filename(archive);
+ gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->filename_label), filename);
+ g_free(filename);
gtk_label_set_text(GTK_LABEL(((SQPropertiesDialog *)dialog)->mimetype_label), lsq_archive_get_mimetype(archive));
return dialog;
More information about the Xfce4-commits
mailing list