file-roller r2230 - in trunk: . src
- From: paobac svn gnome org
- To: svn-commits-list gnome org
- Subject: file-roller r2230 - in trunk: . src
- Date: Fri, 11 Apr 2008 18:38:17 +0100 (BST)
Author: paobac
Date: Fri Apr 11 18:38:17 2008
New Revision: 2230
URL: http://svn.gnome.org/viewvc/file-roller?rev=2230&view=rev
Log:
2008-04-11 Paolo Bacchilega <paobac svn gnome org>
* src/fr-window.c:
show an alert dialog when the 'save as' operation is completed, and
allow the user the open the new archive. Fixed a bug in the conversion
procedure as well.
* src/gtk-utils.h:
* src/gtk-utils.c:
* src/dlg-open-with.c:
load the application icon using the new API.
* src/actions.c:
Use gtk_file_chooser_set_do_overwrite_confirmation instead of the
custom dialog.
Do not use g_file_query_info to get the basename, just use
g_uri_unescape_string because the file could not exists.
Modified:
trunk/ChangeLog
trunk/src/actions.c
trunk/src/dlg-open-with.c
trunk/src/fr-window.c
trunk/src/gtk-utils.c
trunk/src/gtk-utils.h
Modified: trunk/src/actions.c
==============================================================================
--- trunk/src/actions.c (original)
+++ trunk/src/actions.c Fri Apr 11 18:38:17 2008
@@ -211,7 +211,6 @@
if (uri_exists (path)) {
GtkWidget *dialog;
- int r;
if (! is_supported_extension (file_sel, path)) {
dialog = _gtk_error_dialog_new (GTK_WINDOW (file_sel),
@@ -226,25 +225,6 @@
return NULL;
}
- dialog = _gtk_message_dialog_new (GTK_WINDOW (file_sel),
- GTK_DIALOG_MODAL,
- GTK_STOCK_DIALOG_QUESTION,
- _("The archive already exists. Do you want to overwrite it?"),
- NULL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("Overwrite"), GTK_RESPONSE_YES,
- NULL);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
- r = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- if (r != GTK_RESPONSE_YES) {
- g_free (path);
- g_object_unref (file);
- return NULL;
- }
-
g_file_delete (file, NULL, &err);
if (err != NULL) {
GtkWidget *dialog;
@@ -305,14 +285,12 @@
GtkWidget *file_sel)
{
int idx;
- const char *filename;
- const char *ext, *newext;
- char *new_filename, *filename_noext;
- const char *uri;
- GFile *file;
- GFileInfo *info;
- GError *err = NULL;
-
+ const char *uri, *basename;
+ const char *ext, *new_ext;
+ char *basename_noext;
+ char *new_basename;
+ char *new_basename_uft8;
+
idx = gtk_combo_box_get_active (combo_box) - 1;
if (idx < 0)
return;
@@ -321,28 +299,21 @@
if (uri == NULL)
return;
- file = g_file_new_for_uri (uri);
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 0, NULL, &err);
- if (err != NULL) {
- g_warning ("Failed to get display name for uri %s: %s", uri, err->message);
- g_clear_error (&err);
- g_object_unref (file);
- return;
- }
-
- filename = g_file_info_get_display_name (info);
- ext = fr_archive_utils__get_file_name_ext (filename);
+ ext = fr_archive_utils__get_file_name_ext (uri);
if (ext == NULL)
ext = "";
- filename_noext = g_strndup (filename, strlen (filename) - strlen (ext));
-
- newext = file_type_desc[save_type[idx]].ext;
- new_filename = g_strconcat (filename_noext, newext, NULL);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_sel), new_filename);
+ basename = file_name_from_path (uri);
+ basename_noext = g_strndup (basename, strlen (basename) - strlen (ext));
- g_free (new_filename);
- g_free (filename_noext);
+ new_ext = file_type_desc[save_type[idx]].ext;
+ new_basename = g_strconcat (basename_noext, new_ext, NULL);
+ new_basename_uft8 = g_uri_unescape_string (new_basename, NULL);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_sel), new_basename_uft8);
+
+ g_free (new_basename_uft8);
+ g_free (new_basename);
+ g_free (basename_noext);
}
@@ -590,6 +561,7 @@
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (file_sel), TRUE);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), fr_window_get_open_default_dir (window));
if (fr_window_get_archive_uri (window)) {
Modified: trunk/src/dlg-open-with.c
==============================================================================
--- trunk/src/dlg-open-with.c (original)
+++ trunk/src/dlg-open-with.c Fri Apr 11 18:38:17 2008
@@ -387,7 +387,8 @@
for (scan = data->app_list; scan; scan = scan->next) {
gboolean found;
char *utf8_name;
- GdkPixbuf *icon;
+ GIcon *icon;
+ GdkPixbuf *icon_image;
app = scan->data;
@@ -405,13 +406,18 @@
app_names = g_list_prepend (app_names, (char*) g_app_info_get_executable (app));
utf8_name = g_locale_to_utf8 (g_app_info_get_name (app), -1, NULL, NULL, NULL);
- /*icon = create_pixbuf (theme, gnome_vfs_mime_application_get_icon (app), icon_size);*/
-
+
+ icon = g_app_info_get_icon (app);
+ if (icon != NULL) {
+ icon_image = get_icon_pixbuf (theme, G_THEMED_ICON (icon), icon_size);
+ g_object_unref (icon);
+ }
+
gtk_list_store_append (GTK_LIST_STORE (data->app_model),
&iter);
gtk_list_store_set (GTK_LIST_STORE (data->app_model),
&iter,
- /*ICON_COLUMN, icon,*/
+ ICON_COLUMN, icon_image,
TEXT_COLUMN, utf8_name,
DATA_COLUMN, app,
-1);
Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c (original)
+++ trunk/src/fr-window.c Fri Apr 11 18:38:17 2008
@@ -2733,6 +2733,42 @@
handle_errors (window, archive, action, error);
+ if (error->type == FR_PROC_ERROR_NONE) {
+ GtkWidget *d;
+ char *filename;
+ char *basename;
+ char *msg;
+ int result;
+
+ filename = g_file_get_basename (window->priv->convert_data.new_archive->file);
+ basename = g_filename_display_basename (filename);
+ msg = g_strdup_printf (_("The archive \"%s\" has been created successfully"), basename);
+ g_free (filename);
+
+ d = _gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_DIALOG_INFO,
+ msg,
+ "",
+ _("_Open the Archive"), 1,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_CLOSE);
+ result = gtk_dialog_run (GTK_DIALOG (d));
+ gtk_widget_destroy (GTK_WIDGET (d));
+
+ if (result == 1) {
+ GtkWidget *new_window;
+ char *uri;
+
+ uri = g_file_get_uri (window->priv->convert_data.new_archive->file);
+ new_window = fr_window_new ();
+ gtk_widget_show (new_window);
+ fr_window_archive_open (FR_WINDOW (new_window), uri, GTK_WINDOW (new_window));
+ g_free (uri);
+ }
+ }
+
remove_local_directory (window->priv->convert_data.temp_dir);
fr_window_convert_data_free (window);
@@ -2883,17 +2919,21 @@
}
if (window->priv->convert_data.converting) {
+ char *source_dir;
+
+ source_dir = g_filename_to_uri (window->priv->convert_data.temp_dir, NULL, NULL);
fr_archive_add_with_wildcard (
window->priv->convert_data.new_archive,
"*",
NULL,
- window->priv->convert_data.temp_dir,
+ source_dir,
NULL,
FALSE,
TRUE,
FALSE,
window->priv->password,
window->priv->compression);
+ g_free (source_dir);
}
else if (window->priv->view_folder_after_extraction) {
if (window->priv->batch_mode) {
@@ -5599,14 +5639,14 @@
window->priv->convert_data.temp_dir = get_temp_work_dir ();
fr_process_clear (window->archive->process);
- fr_archive_extract (window->archive,
- NULL,
- window->priv->convert_data.temp_dir,
- NULL,
- TRUE,
- FALSE,
- FALSE,
- window->priv->password);
+ fr_archive_extract_to_local (window->archive,
+ NULL,
+ window->priv->convert_data.temp_dir,
+ NULL,
+ TRUE,
+ FALSE,
+ FALSE,
+ window->priv->password);
fr_process_start (window->archive->process);
}
@@ -7416,7 +7456,7 @@
GAppInfo *app)
{
GList *uris = NULL, *scan;
- GError *error;
+ GError *error = NULL;
for (scan = file_list; scan; scan = scan->next) {
char *filename = g_filename_to_uri (scan->data, NULL, NULL);
Modified: trunk/src/gtk-utils.c
==============================================================================
--- trunk/src/gtk-utils.c (original)
+++ trunk/src/gtk-utils.c Fri Apr 11 18:38:17 2008
@@ -22,10 +22,11 @@
#include <config.h>
#include <string.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
+#include "gtk-utils.h"
#include <libgnome/gnome-help.h>
+#define LOAD_BUFFER_SIZE 65536
+
static void
count_selected (GtkTreeModel *model,
@@ -66,7 +67,9 @@
va_list args;
const gchar *text;
int response_id;
- char *escaped_message, *markup_text;
+ char *markup_text;
+
+ g_return_val_if_fail ((message != NULL) || (secondary_message != NULL), NULL);
if (stock_id == NULL)
stock_id = GTK_STOCK_DIALOG_INFO;
@@ -85,19 +88,27 @@
label = gtk_label_new ("");
- escaped_message = g_markup_escape_text (message, -1);
- if (secondary_message != NULL) {
- char *escaped_secondary_message = g_markup_escape_text (secondary_message, -1);
- markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- escaped_message,
- escaped_secondary_message);
- g_free (escaped_secondary_message);
- } else
- markup_text = g_strdup (escaped_message);
+ if (message != NULL) {
+ char *escaped_message;
+
+ escaped_message = g_markup_escape_text (message, -1);
+ if (secondary_message != NULL) {
+ char *escaped_secondary_message = g_markup_escape_text (secondary_message, -1);
+ markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
+ escaped_message,
+ escaped_secondary_message);
+ g_free (escaped_secondary_message);
+ }
+ else
+ markup_text = g_strdup (escaped_message);
+ g_free (escaped_message);
+ }
+ else
+ markup_text = g_markup_escape_text (secondary_message, -1);
+
gtk_label_set_markup (GTK_LABEL (label), markup_text);
g_free (markup_text);
- g_free (escaped_message);
-
+
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
@@ -782,6 +793,32 @@
}
+GdkPixbuf *
+get_icon_pixbuf (GtkIconTheme *icon_theme,
+ GThemedIcon *icon,
+ int size)
+{
+ char **icon_names;
+ GtkIconInfo *icon_info;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ g_object_get (icon, "names", &icon_names, NULL);
+
+ icon_info = gtk_icon_theme_choose_icon (icon_theme, (const char **)icon_names, size, 0);
+ pixbuf = gtk_icon_info_load_icon (icon_info, &error);
+ if (pixbuf == NULL) {
+ g_warning ("could not load icon pixbuf: %s\n", error->message);
+ g_clear_error (&error);
+ }
+
+ gtk_icon_info_free (icon_info);
+ g_strfreev (icon_names);
+
+ return pixbuf;
+}
+
+
int
get_folder_pixbuf_size_for_list (GtkWidget *widget)
{
Modified: trunk/src/gtk-utils.h
==============================================================================
--- trunk/src/gtk-utils.h (original)
+++ trunk/src/gtk-utils.h Fri Apr 11 18:38:17 2008
@@ -24,6 +24,7 @@
#define GTK_UTILS_H
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
int _gtk_count_selected (GtkTreeSelection *selection);
@@ -69,10 +70,13 @@
void _gtk_label_set_filename_text (GtkLabel *label,
const char *text);
char * _gtk_label_get_filename_text (GtkLabel *label);
-GdkPixbuf * create_pixbuf (GtkIconTheme *icon_theme,
- const char *icon_name,
- int icon_size);
-int get_folder_pixbuf_size_for_list (GtkWidget *widget);
+GdkPixbuf * create_pixbuf (GtkIconTheme *icon_theme,
+ const char *icon_name,
+ int icon_size);
+GdkPixbuf * get_icon_pixbuf (GtkIconTheme *icon_theme,
+ GThemedIcon *icon,
+ int size);
+int get_folder_pixbuf_size_for_list (GtkWidget *widget);
void show_help_dialog (GtkWindow *parent,
const char *section);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]