gnome-utils r7892 - in trunk/baobab: . src
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-utils r7892 - in trunk/baobab: . src
- Date: Wed, 30 Apr 2008 21:57:31 +0100 (BST)
Author: pborelli
Date: Wed Apr 30 20:57:31 2008
New Revision: 7892
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=7892&view=rev
Log:
2008-04-29 Paolo Borelli <pborelli katamail com>
* src/baobab-remote-connect-dialog.c:
* src/baobab-remote-connect-dialog.h:
Add a getter for the selected uri instead of abusing of
'last_scan_command'
* src/baobab-utils.c:
use baobab_rescan_current_dir instead of open coding it
* src/baobab.c:
* src/baobab.h:
Remove last_scan_command and use a private GFile location to remember
the current scan. Factor out functions to scan home and root.
* src/callbacks.c
Adapt to the above changes
Modified:
trunk/baobab/ChangeLog
trunk/baobab/src/baobab-remote-connect-dialog.c
trunk/baobab/src/baobab-remote-connect-dialog.h
trunk/baobab/src/baobab-utils.c
trunk/baobab/src/baobab.c
trunk/baobab/src/baobab.h
trunk/baobab/src/callbacks.c
Modified: trunk/baobab/src/baobab-remote-connect-dialog.c
==============================================================================
--- trunk/baobab/src/baobab-remote-connect-dialog.c (original)
+++ trunk/baobab/src/baobab-remote-connect-dialog.c Wed Apr 30 20:57:31 2008
@@ -40,6 +40,8 @@
struct _BaobabRemoteConnectDialogDetails {
+ char *uri;
+
GtkWidget *required_table;
GtkWidget *optional_table;
@@ -86,6 +88,8 @@
dialog = BAOBAB_REMOTE_CONNECT_DIALOG(object);
+ g_free (dialog->details->uri);
+
g_object_unref (dialog->details->uri_entry);
g_object_unref (dialog->details->server_entry);
g_object_unref (dialog->details->share_entry);
@@ -100,7 +104,6 @@
G_OBJECT_CLASS (baobab_remote_connect_dialog_parent_class)->finalize (object);
}
-
static gboolean
remote_connect (BaobabRemoteConnectDialog *dialog)
{
@@ -110,7 +113,10 @@
char *error_message;
char *name;
int type;
-
+
+ g_free (dialog->details->uri);
+ dialog->details->uri = NULL;
+
type = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->details->type_combo));
if (type == TYPE_URI) {
@@ -308,9 +314,8 @@
gnome_vfs_uri_unref (vfs_uri);
}
- g_string_assign(baobab.last_scan_command,uri);
-
- g_free (uri);
+ dialog->details->uri = uri;
+
g_free (name);
return TRUE;
@@ -341,11 +346,8 @@
{
GObjectClass *gobject_class;
-
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = baobab_remote_connect_dialog_finalize;
-
-
}
static void
@@ -634,7 +636,6 @@
}
}
-
static void
baobab_remote_connect_dialog_init (BaobabRemoteConnectDialog *dialog)
{
@@ -700,7 +701,6 @@
G_CALLBACK (combo_changed_callback),
dialog);
-
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (vbox),
hbox, FALSE, TRUE, 0);
@@ -754,8 +754,6 @@
g_signal_connect (dialog, "response",
G_CALLBACK (response_callback),
dialog);
-
-
}
GtkWidget *
@@ -791,3 +789,10 @@
return dialog;
}
+
+char *
+baobab_remote_connect_dialog_get_uri (BaobabRemoteConnectDialog *dlg)
+{
+ return g_strdup (dlg->details->uri);
+}
+
Modified: trunk/baobab/src/baobab-remote-connect-dialog.h
==============================================================================
--- trunk/baobab/src/baobab-remote-connect-dialog.h (original)
+++ trunk/baobab/src/baobab-remote-connect-dialog.h Wed Apr 30 20:57:31 2008
@@ -55,6 +55,8 @@
GtkWidget* baobab_remote_connect_dialog_new (GtkWindow *window,
const gchar *uri);
+char *baobab_remote_connect_dialog_get_uri (BaobabRemoteConnectDialog *dlg);
+
/* Private internal calls */
Modified: trunk/baobab/src/baobab-utils.c
==============================================================================
--- trunk/baobab/src/baobab-utils.c (original)
+++ trunk/baobab/src/baobab-utils.c Wed Apr 30 20:57:31 2008
@@ -451,7 +451,6 @@
gtk_label_set_markup (GTK_LABEL (label),
baobab.label_scan);
-
}
void
@@ -500,24 +499,24 @@
g_free (uri);
}
-
g_free (uri_scheme);
- if (application) g_object_unref(application);
+
+ if (application)
+ g_object_unref (application);
+
g_object_unref (info);
}
-
gboolean
trash_file (const gchar *filename)
{
GError *error = NULL;
GFile *file;
gchar *str = NULL;
-
- file = g_file_new_for_path(filename);
- if (!g_file_trash(file, NULL, &error))
- {
+ file = g_file_new_for_path (filename);
+
+ if (!g_file_trash(file, NULL, &error)) {
gchar *mess;
str = g_strdup_printf (_("Could not move \"%s\" to the Trash"), g_path_get_basename (filename));
@@ -529,19 +528,16 @@
g_object_unref (file);
return FALSE;
- }
-
- g_object_unref(file);
+ }
+
+ g_object_unref (file);
return TRUE;
-
}
-
void
contents_changed (void)
{
-
baobab_get_filesystem (&g_fs);
set_label_scan (&g_fs);
show_label ();
@@ -549,10 +545,7 @@
if (messageyesno (_("Rescan your home folder?"),
_("The content of your home folder has changed. Select rescan to update the disk usage details."),
GTK_MESSAGE_QUESTION, _("_Rescan"), baobab.window) == GTK_RESPONSE_OK) {
- GFile * file;
- file= g_file_new_for_uri(baobab.last_scan_command->str);
- start_proc_on_location (file);
- g_object_unref (file);
+ baobab_rescan_current_dir ();
}
}
Modified: trunk/baobab/src/baobab.c
==============================================================================
--- trunk/baobab/src/baobab.c (original)
+++ trunk/baobab/src/baobab.c Wed Apr 30 20:57:31 2008
@@ -58,6 +58,8 @@
static GtkTreeIter firstiter;
static GQueue *iterstack = NULL;
+static GFile *current_location = NULL;
+
#define BUSY_IMAGE_PATH BAOBAB_PIX_DIR "busy.gif"
#define DONE_IMAGE_PATH BAOBAB_PIX_DIR "done.png"
@@ -99,21 +101,22 @@
* start scanning on a specific directory
*/
void
-start_proc_on_location (GFile *file)
+start_proc_on_location (GFile *file)
{
GdkCursor *cursor = NULL;
GtkWidget *ck_allocated;
- gchar *dir = NULL;
+ gchar *dir = NULL;
if (!baobab_check_dir (file))
return;
-
+
if (iterstack !=NULL)
return;
-
- dir = g_file_get_uri(file);
+
+ current_location = g_object_ref (file);
+
+ dir = g_file_get_uri (file);
g_noactivescans = FALSE;
- g_string_assign (baobab.last_scan_command, dir);
baobab.STOP_SCANNING = FALSE;
set_busy (TRUE);
check_menu_sens (TRUE);
@@ -167,17 +170,35 @@
}
void
-rescan_current_dir (void)
+baobab_scan_home (void)
+{
+ GFile *file;
+
+ file = g_file_new_for_path (g_get_home_dir ());
+ start_proc_on_location (file);
+ g_object_unref (file);
+}
+
+void
+baobab_scan_root (void)
{
- GFile * file;
- g_return_if_fail (baobab.last_scan_command != NULL);
+ GFile *file;
+
+ file = g_file_new_for_uri ("file:///");
+ start_proc_on_location (file);
+ g_object_unref (file);
+}
+
+void
+baobab_rescan_current_dir (void)
+{
+ g_return_if_fail (current_location != NULL);
+
baobab_get_filesystem (&g_fs);
set_label_scan (&g_fs);
show_label ();
- file = g_file_new_for_uri(baobab.last_scan_command->str);
- start_proc_on_location (file);
- g_object_unref (file);
+ start_proc_on_location (current_location);
}
/*
@@ -597,7 +618,6 @@
/* Misc */
baobab.label_scan = NULL;
- baobab.last_scan_command = g_string_new ("file:///");
baobab.CONTENTS_CHANGED_DELAYED = FALSE;
baobab.STOP_SCANNING = TRUE;
baobab.show_allocated = TRUE;
@@ -615,7 +635,7 @@
GCONF_VALUE_STRING, NULL);
/* Verify if gconf wrongly contains root dir exclusion, and remove it from gconf. */
- if (is_excluded_dir("/")) {
+ if (is_excluded_dir ("/")) {
baobab.bbExcludedDirs = g_slist_delete_link (baobab.bbExcludedDirs,
g_slist_find_custom(baobab.bbExcludedDirs,
"/", list_find));
@@ -653,7 +673,10 @@
g_error_free (error);
}
else {
- g_signal_connect (monitor_home, "changed", G_CALLBACK (contents_changed_cb), NULL);
+ g_signal_connect (monitor_home,
+ "changed",
+ G_CALLBACK (contents_changed_cb),
+ NULL);
}
}
@@ -661,7 +684,9 @@
baobab_shutdown (void)
{
g_free (baobab.label_scan);
- g_string_free (baobab.last_scan_command, TRUE);
+
+ if (current_location)
+ g_object_unref (current_location);
if (monitor_vol)
g_object_unref (monitor_vol);
@@ -715,13 +740,9 @@
}
static gboolean
-start_proc_on_command_line (const char *uri)
+start_proc_on_command_line (GFile *file)
{
- GFile *file;
-
- file = g_file_new_for_uri (uri);
start_proc_on_location (file);
- g_object_unref (file);
return FALSE;
}
@@ -750,9 +771,9 @@
gtk_window_set_default_icon_name ("baobab");
baobab_init ();
-
+
g_noactivescans = TRUE;
- check_menu_sens(FALSE);
+ check_menu_sens (FALSE);
baobab_get_filesystem (&g_fs);
if (g_fs.total == 0) {
GtkWidget *dialog = gtk_message_dialog_new (NULL,
@@ -777,7 +798,7 @@
baobab.tree_view = create_directory_treeview ();
- set_glade_widget_sens("menurescan",FALSE);
+ set_glade_widget_sens ("menurescan",FALSE);
/* set allocated space checkbox */
gtk_check_menu_item_set_active ((GtkCheckMenuItem *)
@@ -786,7 +807,7 @@
"ck_allocated"),
baobab.show_allocated);
- set_glade_widget_sens("menu_treemap",FALSE);
+ set_glade_widget_sens ("menu_treemap",FALSE);
gtk_widget_show (baobab.window);
first_row ();
@@ -797,16 +818,16 @@
/* commandline */
if (argc > 1) {
- gchar *uri_shell;
+ GFile *file;
- uri_shell = gnome_vfs_make_uri_from_shell_arg (argv[1]);
+ file = g_file_new_for_commandline_arg (argv[1]);
- /* start processing the uri specified on the
+ /* start processing the dir specified on the
* command line as soon as we enter the main loop */
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc) start_proc_on_command_line,
- uri_shell,
- (GDestroyNotify) g_free);
+ file,
+ (GDestroyNotify) g_object_unref);
}
gtk_main ();
Modified: trunk/baobab/src/baobab.h
==============================================================================
--- trunk/baobab/src/baobab.h (original)
+++ trunk/baobab/src/baobab.h Wed Apr 30 20:57:31 2008
@@ -61,7 +61,6 @@
GSList *bbExcludedDirs;
gboolean bbEnableHomeMonitor;
gchar *label_scan;
- GString *last_scan_command;
gboolean show_allocated;
gboolean is_local;
@@ -92,7 +91,9 @@
void set_busy (gboolean busy);
void start_proc_on_location (GFile *);
-void rescan_current_dir (void);
+void baobab_scan_home (void);
+void baobab_scan_root (void);
+void baobab_rescan_current_dir (void);
void fill_model (struct chan_data *);
void first_row (void);
gint list_find (gconstpointer a, gconstpointer b);
Modified: trunk/baobab/src/callbacks.c
==============================================================================
--- trunk/baobab/src/callbacks.c (original)
+++ trunk/baobab/src/callbacks.c Wed Apr 30 20:57:31 2008
@@ -41,21 +41,13 @@
void
on_menuscanhome_activate (GtkMenuItem *menuitem, gpointer user_data)
{
- GFile *file;
-
- file = g_file_new_for_path (g_get_home_dir ());
- start_proc_on_location (file);
- g_object_unref (file);
+ baobab_scan_home ();
}
void
on_menuallfs_activate (GtkMenuItem *menuitem, gpointer user_data)
{
- GFile *file;
-
- file = g_file_new_for_uri ("file:///");
- start_proc_on_location (file);
- g_object_unref (file);
+ baobab_scan_root ();
}
void
@@ -138,7 +130,7 @@
void
on_menu_rescan_activate (GtkMenuItem *menuitem, gpointer user_data)
{
- rescan_current_dir ();
+ baobab_rescan_current_dir ();
}
void
@@ -150,21 +142,13 @@
void
on_tbscanhome_clicked (GtkToolButton *toolbutton, gpointer user_data)
{
- GFile *file;
-
- file = g_file_new_for_path (g_get_home_dir ());
- start_proc_on_location (file);
- g_object_unref (file);
+ baobab_scan_home ();
}
void
on_tbscanall_clicked (GtkToolButton *toolbutton, gpointer user_data)
{
- GFile *file;
-
- file = g_file_new_for_uri ("file:///");
- start_proc_on_location (file);
- g_object_unref (file);
+ baobab_scan_root ();
}
void
@@ -172,23 +156,25 @@
{
gint response;
GtkWidget *dlg;
+ char *uri = NULL;
- dlg =
- baobab_remote_connect_dialog_new (GTK_WINDOW (baobab.window),
- NULL);
+ dlg = baobab_remote_connect_dialog_new (GTK_WINDOW (baobab.window),
+ NULL);
response = gtk_dialog_run (GTK_DIALOG (dlg));
- gtk_widget_destroy (dlg);
+ if (response == GTK_RESPONSE_OK) {
+ uri = baobab_remote_connect_dialog_get_uri (BAOBAB_REMOTE_CONNECT_DIALOG (dlg));
+ }
- while (gtk_events_pending ())
- gtk_main_iteration ();
+ gtk_widget_destroy (dlg);
- if (response == GTK_RESPONSE_OK) {
- GFile *file;
- file = g_file_new_for_uri (baobab.last_scan_command->str);
+ if (uri) {
+ GFile *file;
+ file = g_file_new_for_uri (uri);
start_proc_on_location (file);
g_object_unref (file);
- }
+ g_free (uri);
+ }
}
void
@@ -207,7 +193,7 @@
void
on_tbrescan_clicked (GtkToolButton *toolbutton, gpointer user_data)
{
- rescan_current_dir ();
+ baobab_rescan_current_dir ();
}
gboolean
@@ -221,19 +207,18 @@
void
open_file_cb (GtkMenuItem *pmenu, gpointer dummy)
{
- GFile *file;
+ GFile *file;
g_assert (!dummy);
g_assert (baobab.selected_path);
if (baobab.is_local) {
- file = g_file_new_for_path(baobab.selected_path);
- }
+ file = g_file_new_for_path (baobab.selected_path);
+ }
else {
- file = g_file_new_for_uri(baobab.selected_path);
+ file = g_file_new_for_uri (baobab.selected_path);
}
-
-
+
if (!g_file_query_exists (file, NULL)) {
message (_("The document does not exist."), "",
GTK_MESSAGE_INFO, baobab.window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]