gwget r619 - in trunk: . src
- From: davidsf svn gnome org
- To: svn-commits-list gnome org
- Subject: gwget r619 - in trunk: . src
- Date: Thu, 12 Feb 2009 18:56:02 +0000 (UTC)
Author: davidsf
Date: Thu Feb 12 18:56:02 2009
New Revision: 619
URL: http://svn.gnome.org/viewvc/gwget?rev=619&view=rev
Log:
2009-02-12 David SedeÃo <david alderia com>
* src/gwget_data.c, src/main_window.c, src/main_window_cb.c,
src/main.c: Port to gio for local operations.
Modified:
trunk/ChangeLog
trunk/src/gwget_data.c
trunk/src/main.c
trunk/src/main_window.c
trunk/src/main_window_cb.c
Modified: trunk/src/gwget_data.c
==============================================================================
--- trunk/src/gwget_data.c (original)
+++ trunk/src/gwget_data.c Thu Feb 12 18:56:02 2009
@@ -16,9 +16,12 @@
#define _FILE_OFFSET_BITS 64
#include <config.h>
-#include <gnome.h>
+#include <gio/gio.h>
+#include <glib.h>
#include <glib/gstdio.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
@@ -443,8 +446,8 @@
user_password=g_strdup_printf("%s:%s@",gwget_pref.proxy_user,gwget_pref.proxy_password);
}
- setenv("http_proxy", g_strconcat("http://",g_strdup_printf(user_password),g_strdup_printf("%s",gwget_pref.http_proxy),":",g_strdup_printf("%d",gwget_pref.http_proxy_port),NULL), 1);
- setenv("ftp_proxy", g_strconcat("http://",g_strdup_printf(user_password),g_strdup_printf("%s",gwget_pref.http_proxy),":",g_strdup_printf("%d",gwget_pref.http_proxy_port),NULL), 1);
+ setenv("http_proxy", g_strconcat("http://", g_strdup_printf("%s", user_password),g_strdup_printf("%s",gwget_pref.http_proxy),":",g_strdup_printf("%d",gwget_pref.http_proxy_port),NULL), 1);
+ setenv("ftp_proxy", g_strconcat("http://", g_strdup_printf("%s", user_password),g_strdup_printf("%s",gwget_pref.http_proxy),":",g_strdup_printf("%d",gwget_pref.http_proxy_port),NULL), 1);
argv[arg]="-Yon";
arg++;
}
@@ -456,8 +459,8 @@
user_password=g_strdup_printf("%s:%s@",gwget_pref.gnome_proxy_user,gwget_pref.gnome_proxy_password);
}
- setenv("http_proxy",g_strconcat("http://",g_strdup_printf(user_password),g_strdup_printf("%s",gwget_pref.gnome_http_proxy),":",g_strdup_printf("%d",gwget_pref.gnome_http_proxy_port),NULL),1);
- setenv("ftp_proxy",g_strconcat("http://",g_strdup_printf(user_password),g_strdup_printf("%s",gwget_pref.gnome_http_proxy),":",g_strdup_printf("%d",gwget_pref.gnome_http_proxy_port),NULL),1);
+ setenv("http_proxy",g_strconcat("http://", g_strdup_printf("%s", user_password), g_strdup_printf("%s", gwget_pref.gnome_http_proxy),":", g_strdup_printf("%d", gwget_pref.gnome_http_proxy_port),NULL),1);
+ setenv("ftp_proxy",g_strconcat("http://", g_strdup_printf("%s", user_password), g_strdup_printf("%s", gwget_pref.gnome_http_proxy),":", g_strdup_printf("%d", gwget_pref.gnome_http_proxy_port),NULL),1);
argv[arg]="-Yon";
arg++;
}
@@ -518,8 +521,10 @@
gwget_data_create(gchar *url, gchar *dir)
{
GwgetData *gwgetdata;
- GnomeVFSURI *localfile_uri;
+ GFile *file;
+ GFileInfo *info;
gint length;
+ GError *err = NULL;
g_return_val_if_fail(url != NULL, NULL);
g_return_val_if_fail(dir != NULL, NULL);
@@ -547,23 +552,22 @@
gwget_data_set_filename(gwgetdata,gwgetdata->filename);
- localfile_uri = gnome_vfs_uri_new (gwgetdata->local_filename);
- if (gnome_vfs_uri_exists (localfile_uri) ) {
- GnomeVFSFileInfo *info;
- info = gnome_vfs_file_info_new();
- gnome_vfs_get_file_info (gwgetdata->local_filename,
- info,
- GNOME_VFS_FILE_INFO_DEFAULT);
- gwgetdata->cur_size = (guint64)info->size;
+ file = g_file_new_for_path (gwgetdata->local_filename);
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &err);
+
+ if (err==NULL) {
+ gwgetdata->cur_size = g_file_info_get_size (info);
} else {
gwgetdata->cur_size = 0;
+ g_warning ("Failed to get file size for %s: %s", gwgetdata->local_filename, err->message);
+ g_error_free (err);
}
+
gwgetdata->line = NULL;
gwgetdata->session_start_time = 0;
gwgetdata->session_start_size = 0;
gwgetdata->session_elapsed = 0;
- /* gwgetdata->cur_size = 0; */
gwgetdata->state = DL_NOT_STARTED;
gwgetdata->total_size = 0;
gwgetdata->total_time = 0;
@@ -730,12 +734,15 @@
void
gwget_data_exec (GwgetData *gwgetdata)
{
- gchar *uri;
+ gchar *url;
+ GFile *file;
GError *err = NULL;
- uri = gnome_vfs_make_uri_from_input_with_dirs (gwgetdata->local_filename,
- GNOME_VFS_MAKE_URI_DIR_CURRENT);
- if (!gnome_url_show (uri, &err)) {
+ file = g_file_new_for_commandline_arg (gwgetdata->local_filename);
+ url = g_file_get_uri (file);
+ g_object_unref (file);
+
+ if (!gtk_show_uri (NULL, url, GDK_CURRENT_TIME, &err)) {
run_dialog_error(_("Error opening file"), _("Couldn't open the file"));
}
}
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Thu Feb 12 18:56:02 2009
@@ -22,7 +22,7 @@
#include <gconf/gconf-client.h>
#include <locale.h>
#include <libgnomeui/libgnomeui.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
#include "main_window_cb.h"
#include "main_window.h"
@@ -164,9 +164,11 @@
for (i = 0; files[i]; i++) {
char *uri;
char *dest_dir;
-
- uri = gnome_vfs_make_uri_from_shell_arg (files[i]);
+ GFile *file;
+ file = g_file_new_for_commandline_arg (files[i]);
+ uri = g_file_get_uri (file);
+
if (destination_dir) {
dest_dir = destination_dir;
}
@@ -210,6 +212,7 @@
}
#endif
g_free (uri);
+ g_object_unref (file);
result = TRUE;
}
@@ -233,13 +236,18 @@
}
for ( i = 0; urls[i]; i++) {
- url = gnome_vfs_make_uri_from_shell_arg (urls[i]);
+ GFile *file;
+
+ file = g_file_new_for_commandline_arg (urls[i]);
+
+ url = g_file_get_uri (file);
gwgetdata = gwget_data_new ((gchar *)url);
if (destination_dir) {
gwgetdata->dir = destination_dir;
}
gwget_data_add_download(gwgetdata);
gwget_data_start_download(gwgetdata);
+ g_object_unref (file);
}
}
Modified: trunk/src/main_window.c
==============================================================================
--- trunk/src/main_window.c (original)
+++ trunk/src/main_window.c Thu Feb 12 18:56:02 2009
@@ -405,6 +405,8 @@
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ PangoContext *context;
+ PangoLayout *layout;
/* File Name Column */
@@ -429,8 +431,12 @@
gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN(column),_("File Name"));
+ context = gtk_widget_get_pango_context(GTK_WIDGET(treeview));
+ layout = pango_layout_new (PANGO_CONTEXT(context));
+ pango_layout_set_ellipsize (PANGO_LAYOUT(layout), PANGO_ELLIPSIZE_END);
+
gtk_tree_view_column_set_sort_column_id (column, FILENAME_COLUMN);
- gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (treeview, column);
/* State Column */
@@ -522,7 +528,9 @@
guint time, gpointer data)
{
gchar *file;
- GList *files;
+ gchar *uri;
+ gchar **uris;
+ GList *files = NULL;
GwgetData *gwgetdata;
gboolean drop_ok;
@@ -532,10 +540,12 @@
drop_ok = FALSE;
if (dnd_type==TARGET_URI_LIST) {
- GnomeVFSURI *vfs_uri;
- files = gnome_vfs_uri_list_parse (seldata->data);
- vfs_uri = files->data;
- file = gnome_vfs_uri_to_string(vfs_uri,GNOME_VFS_URI_HIDE_NONE);
+ uris = g_uri_list_extract_uris (seldata->data);
+ for (uri=uris[0]; uri != NULL; uri++) {
+ files = g_list_prepend (files, uri);
+ }
+ g_strfreev (uris);
+ file = files->data;
drop_ok = TRUE;
} else if (dnd_type==TARGET_NETSCAPE_URL) {
file=((gchar *) (seldata->data));
Modified: trunk/src/main_window_cb.c
==============================================================================
--- trunk/src/main_window_cb.c (original)
+++ trunk/src/main_window_cb.c Thu Feb 12 18:56:02 2009
@@ -61,7 +61,8 @@
GtkTreeModel *model;
GwgetData *gwgetdata;
gchar *uri;
- GError *err = NULL;
+ GError *err = NULL;
+ GFile *location;
treev=glade_xml_get_widget(xml,"treeview1");
select=gtk_tree_view_get_selection(GTK_TREE_VIEW(treev));
@@ -105,12 +106,15 @@
run_dialog_error(_("Error in download"),gwgetdata->error_msg);
} else {
if (gwgetdata->recursive) {
- uri = gnome_vfs_make_uri_from_input(gwgetdata->dir);
+ location = g_file_parse_name (gwgetdata->dir);
+ uri = g_file_get_uri (location);
+ g_object_unref (location);
} else {
- uri = gnome_vfs_make_uri_from_input_with_dirs (gwgetdata->local_filename,
- GNOME_VFS_MAKE_URI_DIR_CURRENT);
+ location = g_file_new_for_commandline_arg (gwgetdata->local_filename);
+ uri = g_file_get_uri (location);
+ g_object_unref (location);
}
- if (!gnome_url_show (uri, &err)) {
+ if (!gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &err)) {
run_dialog_error(_("Error opening file"),_("Couldn't open the file"));
return FALSE;
}
@@ -217,7 +221,8 @@
GtkIconTheme *theme;
GtkIconInfo *icon_info;
GdkPixbuf *pixbuf;
- char *mime, *size;
+ gchar *content_type = NULL;
+ gchar *size;
int width = 16, height = 16;
gdouble perc;
@@ -245,9 +250,9 @@
theme = gtk_icon_theme_get_default ();
if (!gwgetdata->recursive) {
- mime = (gchar *)gnome_vfs_get_mime_type_for_name (gwgetdata->local_filename);
+ content_type = g_content_type_guess (gwgetdata->local_filename, NULL, 0, NULL);
gwgetdata->icon_name = gnome_icon_lookup (theme, NULL, NULL, NULL, NULL,
- mime, GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);
+ content_type, GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);
} else {
gwgetdata->icon_name = g_strdup("gtk-refresh");
}
@@ -267,7 +272,8 @@
if (pixbuf)
g_object_unref (pixbuf);
-
+
+ g_free (content_type);
}
@@ -896,7 +902,7 @@
GTK_DIALOG_DESTROY_WITH_PARENT,
msg_type,
GTK_BUTTONS_CLOSE,
- msg->str);
+ "%s", msg->str);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(GTK_WIDGET(dialog));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]