gnome-applets r10650 - in trunk: po trashapplet trashapplet/src



Author: ryanl
Date: Wed Feb 13 07:27:11 2008
New Revision: 10650
URL: http://svn.gnome.org/viewvc/gnome-applets?rev=10650&view=rev

Log:
2008-02-13  Ryan Lortie  <desrt desrt ca>

        * POTFILES.in: trash applet updates (glade -> gtkbuilder,
        empty-trash.c).


2008-02-12  Ryan Lortie  <desrt desrt ca>

        Fix the regression introduced in the last commit.  Add progress dialog
        support for emptying the trash via GIO.

        * src/trash-monitor.c:
        * src/trash-monitor.h: remove trash emptying functions.  they no
        longer logically belong here.
        * src/trash-empty.h:
        * src/trash-empty.c: new files.  handle emptying the trash.
        * src/trashapplet.h: remove mention of glade
        * src/trashapplet.c: remove trash emptying UI code (it's now in
        trash-empty.c)
        * src/Makefile.am: remove glade, add trash-empty.[ch]
        * trashapplet-empty-progress.ui: replaces trashapplet.glade (moved to
        GtkBuilder).
        * Makefile.am: install the .ui instead of the .glade



Added:
   trunk/trashapplet/src/trash-empty.c
   trunk/trashapplet/src/trash-empty.h
   trunk/trashapplet/trashapplet-empty-progress.ui
Removed:
   trunk/trashapplet/trashapplet.glade
Modified:
   trunk/po/ChangeLog
   trunk/po/POTFILES.in
   trunk/trashapplet/ChangeLog
   trunk/trashapplet/Makefile.am
   trunk/trashapplet/src/Makefile.am
   trunk/trashapplet/src/trash-monitor.c
   trunk/trashapplet/src/trash-monitor.h
   trunk/trashapplet/src/trashapplet.c
   trunk/trashapplet/src/trashapplet.h

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Wed Feb 13 07:27:11 2008
@@ -114,4 +114,5 @@
 trashapplet/GNOME_Panel_TrashApplet.server.in.in
 trashapplet/GNOME_Panel_TrashApplet.xml
 trashapplet/src/trashapplet.c
-trashapplet/trashapplet.glade
+trashapplet/src/trash-empty.c
+[type: gettext/glade]trashapplet/trashapplet-empty-progress.ui

Modified: trunk/trashapplet/Makefile.am
==============================================================================
--- trunk/trashapplet/Makefile.am	(original)
+++ trunk/trashapplet/Makefile.am	Wed Feb 13 07:27:11 2008
@@ -12,7 +12,8 @@
 uidir = $(datadir)/gnome-2.0/ui
 ui_DATA = GNOME_Panel_TrashApplet.xml
 
-glade_DATA = trashapplet.glade
+# here for now until i here of a better place
+glade_DATA = trashapplet-empty-progress.ui
 
 EXTRA_DIST = \
 	$(ui_DATA) \

Modified: trunk/trashapplet/src/Makefile.am
==============================================================================
--- trunk/trashapplet/src/Makefile.am	(original)
+++ trunk/trashapplet/src/Makefile.am	Wed Feb 13 07:27:11 2008
@@ -1,7 +1,6 @@
 INCLUDES = -I$(top_srcdir)		\
 	   $(GNOME_APPLETS_CFLAGS)	\
-	   $(GIO_CFLAGS) 		\
-           $(LIBGLADE_CFLAGS)
+	   $(GIO_CFLAGS)
 
 libexec_PROGRAMS = trashapplet
 
@@ -10,10 +9,11 @@
 	trashapplet.h \
 	trash-monitor.h \
 	trash-monitor.c \
+	trash-empty.h \
+	trash-empty.c \
 	xstuff.c \
 	xstuff.h
 
 trashapplet_LDADD = 		\
 	$(GNOME_APPLETS_LIBS) 	\
-	$(GIO_LIBS) 		\
-	$(LIBGLADE_LIBS)
+	$(GIO_LIBS)

Added: trunk/trashapplet/src/trash-empty.c
==============================================================================
--- (empty file)
+++ trunk/trashapplet/src/trash-empty.c	Wed Feb 13 07:27:11 2008
@@ -0,0 +1,372 @@
+/*
+ * trash-empty.c: a routine to empty the trash
+ *
+ * Copyright  2008 Ryan Lortie
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <gconf/gconf-client.h>
+#include <gio/gio.h>
+#include <gnome.h>
+
+#include "trash-empty.h"
+#include "config.h"
+
+/* only one concurrent trash empty operation can occur */
+static GtkDialog          *trash_empty_confirm_dialog;
+static GtkDialog          *trash_empty_dialog;
+static GtkProgressBar     *trash_empty_progress_bar;
+static GtkLabel           *trash_empty_location;
+static GtkLabel           *trash_empty_file;
+
+/* the rules:
+ * 1) nothing here may be modified while trash_empty_update_pending.
+ * 2) an idle may only be scheduled if trash_empty_update_pending.
+ * 3) only the worker may set trash_empty_update_pending = TRUE.
+ * 4) only the UI updater may set trash_empty_update_pending = FALSE.
+ *
+ * i -think- this is threadsafe...  ((famous last words...))
+ */
+static GFile *     volatile trash_empty_current_file;
+static gsize       volatile trash_empty_deleted_files;
+static gsize       volatile trash_empty_total_files;
+static gboolean    volatile trash_empty_update_pending;
+
+static gboolean
+trash_empty_clear_pending (gpointer user_data)
+{
+  trash_empty_update_pending = FALSE;
+
+  return FALSE;
+}
+
+static gboolean
+trash_empty_update_dialog (gpointer user_data)
+{
+  gsize deleted, total;
+  GFile *file;
+
+  g_assert (trash_empty_update_pending);
+
+  deleted = trash_empty_deleted_files;
+  total = trash_empty_total_files;
+  file = trash_empty_current_file;
+
+  /* maybe the done() got processed first. */
+  if (trash_empty_dialog)
+    {
+      char *text;
+      char *tmp;
+
+      text = g_strdup_printf (_("Removing item %d of %d"),
+                              deleted + 1, total);
+      gtk_progress_bar_set_text (trash_empty_progress_bar, text);
+      g_free (text);
+
+      if (deleted > total)
+        gtk_progress_bar_set_fraction (trash_empty_progress_bar, 1.0);
+      else
+        gtk_progress_bar_set_fraction (trash_empty_progress_bar,
+                                       (gdouble) deleted / (gdouble) total);
+
+      /* no g_file_get_basename? */
+      {
+        GFile *parent;
+       
+        parent = g_file_get_parent (file);
+        text = g_file_get_uri (parent);
+        g_object_unref (parent);
+      }
+      gtk_label_set_text (trash_empty_location, text);
+      g_free (text);
+
+      tmp = g_file_get_basename (file);
+      text = g_markup_printf_escaped ("<i>%s %s</i>", _("Removing:"), tmp);
+      gtk_label_set_markup (trash_empty_file, text);
+      g_free (text);
+      g_free (tmp);
+
+      /* unhide the labels */
+      gtk_widget_show_all (GTK_WIDGET (trash_empty_dialog));
+    }
+
+  trash_empty_current_file = NULL;
+  g_object_unref (file);
+
+  trash_empty_update_pending = FALSE;
+
+  return FALSE;
+}
+
+static gboolean
+trash_empty_done (gpointer user_data)
+{
+  gtk_object_destroy (GTK_OBJECT (trash_empty_dialog));
+
+  g_assert (trash_empty_dialog == NULL);
+
+  return FALSE;
+}
+
+/* =============== worker thread code begins here =============== */
+static void
+trash_empty_maybe_schedule_update (GIOSchedulerJob *job,
+                                   GFile           *file,
+                                   gsize            deleted)
+{
+  if (!trash_empty_update_pending)
+    {
+      g_assert (trash_empty_current_file == NULL);
+
+      trash_empty_current_file = g_object_ref (file);
+      trash_empty_deleted_files = deleted;
+
+      trash_empty_update_pending = TRUE;
+      g_io_scheduler_job_send_to_mainloop_async (job,
+                                                 trash_empty_update_dialog,
+                                                 NULL, NULL);
+    }
+}
+
+static void
+trash_empty_delete_contents (GIOSchedulerJob *job,
+                             GCancellable    *cancellable,
+                             GFile           *file,
+                             gboolean         actually_delete,
+                             gsize           *deleted)
+{
+  GFileEnumerator *enumerator;
+  GFileInfo *info;
+  GFile *child;
+
+  if (g_cancellable_is_cancelled (cancellable))
+    return;
+
+  enumerator = g_file_enumerate_children (file,
+                                          G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                                          G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                          G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                          cancellable, NULL);
+  if (enumerator) 
+    {
+      while ((info = g_file_enumerator_next_file (enumerator,
+                                                  cancellable, NULL)) != NULL)
+        {
+          child = g_file_get_child (file, g_file_info_get_name (info));
+
+          if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
+            trash_empty_delete_contents (job, cancellable, child,
+                                         actually_delete, deleted);
+
+          if (actually_delete)
+            {
+              trash_empty_maybe_schedule_update (job, child, *deleted);
+              g_file_delete (child, cancellable, NULL);
+            }
+
+          (*deleted)++;
+
+          g_object_unref (child);
+          g_object_unref (info);
+
+          if (g_cancellable_is_cancelled (cancellable))
+            break;
+        }
+
+      g_object_unref (enumerator);
+    }
+}
+
+static gboolean
+trash_empty_job (GIOSchedulerJob *job,
+                 GCancellable    *cancellable,
+                 gpointer         user_data)
+{
+  gsize deleted;
+  GFile *trash;
+
+  trash = g_file_new_for_uri ("trash:///");
+
+  /* first do a dry run to count the number of files */
+  deleted = 0;
+  trash_empty_delete_contents (job, cancellable, trash, FALSE, &deleted);
+  trash_empty_total_files = deleted;
+ 
+  /* now do the real thing */ 
+  deleted = 0;
+  trash_empty_delete_contents (job, cancellable, trash, TRUE, &deleted);
+
+  /* done */
+  g_object_unref (trash);
+  g_io_scheduler_job_send_to_mainloop_async (job,
+                                             trash_empty_done,
+                                             NULL, NULL);
+
+  return FALSE;
+}
+/* ================ worker thread code ends here ================ */
+
+static void
+trash_empty_start (GtkWidget *parent)
+{
+  struct { const char *name; gpointer *pointer; } widgets[] =
+    {
+      { "empty_trash",       (gpointer *) &trash_empty_dialog        },
+      { "progressbar",       (gpointer *) &trash_empty_progress_bar  },
+      { "location_label",    (gpointer *) &trash_empty_location      },
+      { "file_label",        (gpointer *) &trash_empty_file          }
+    };
+  GCancellable *cancellable;
+  GtkBuilder *builder;
+  gint i;
+
+  builder = gtk_builder_new ();
+  gtk_builder_add_from_file (builder,
+                             GNOME_GLADEDIR "/trashapplet-empty-progress.ui",
+                             NULL);
+
+  for (i = 0; i < G_N_ELEMENTS (widgets); i++)
+    {
+      GObject *object;
+
+      object = gtk_builder_get_object (builder, widgets[i].name);
+
+      if (object == NULL)
+        {
+          g_critical ("failed to parse trash-empty dialog markup");
+
+          if (trash_empty_dialog)
+            gtk_object_destroy (GTK_OBJECT (trash_empty_dialog));
+
+          g_object_unref (builder);
+          return;
+        }
+
+      *widgets[i].pointer = object;
+      g_object_add_weak_pointer (object, widgets[i].pointer);
+    }
+
+  cancellable = g_cancellable_new ();
+  g_signal_connect_object (trash_empty_dialog, "response",
+                           G_CALLBACK (g_cancellable_cancel),
+                           cancellable, G_CONNECT_SWAPPED);
+  g_io_scheduler_push_job (trash_empty_job, NULL, NULL, 0, cancellable);
+  g_object_unref (cancellable);
+
+  gtk_window_set_screen (GTK_WINDOW (trash_empty_dialog),
+                         gtk_widget_get_screen (parent));
+  gtk_widget_show (GTK_WIDGET (trash_empty_dialog));
+}
+
+static gboolean
+trash_empty_require_confirmation (void)
+{
+  return gconf_client_get_bool (gconf_client_get_default (),
+                                "/apps/nautilus/preferences/confirm_trash",
+                                NULL);
+}
+
+static void
+trash_empty_confirmation_response (GtkDialog *dialog,
+                                   gint       response_id,
+                                   gpointer   user_data)
+{
+  if (response_id == GTK_RESPONSE_YES)
+    trash_empty_start (GTK_WIDGET (dialog));
+
+  gtk_object_destroy (GTK_OBJECT (dialog));
+  g_assert (trash_empty_confirm_dialog == NULL);
+}
+
+/*
+ * The code in trash_empty_show_confirmation_dialog() was taken from
+ * libnautilus-private/nautilus-file-operations.c (confirm_empty_trash)
+ * by Michiel Sikkes <michiel eyesopened nl> and adapted for the applet.
+ */
+static void
+trash_empty_show_confirmation_dialog (GtkWidget *parent)
+{
+  GtkWidget *dialog;
+  GtkWidget *button;
+  GdkScreen *screen;
+  int response;
+
+  if (!trash_empty_require_confirmation ())
+    {
+      trash_empty_start (parent);
+      return;
+    }
+
+  screen = gtk_widget_get_screen (parent);
+
+  dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_NONE,
+                                   _("Empty all of the items from "
+                                     "the trash?"));
+  trash_empty_confirm_dialog = GTK_DIALOG (dialog);
+  g_object_add_weak_pointer (G_OBJECT (dialog),
+                             (gpointer *) &trash_empty_confirm_dialog);
+
+  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                            _("If you choose to empty "
+                                              "the trash, all items in "
+                                              "it will be permanently "
+                                              "lost. Please note that "
+                                              "you can also delete them "
+                                              "separately."));
+
+  gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+  atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
+  gtk_window_set_wmclass (GTK_WINDOW (dialog), "empty_trash", "Nautilus");
+
+  /* Make transient for the window group */
+  gtk_widget_realize (dialog);
+  gdk_window_set_transient_for (dialog->window,
+                                gdk_screen_get_root_window (screen));
+
+  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
+                         GTK_RESPONSE_CANCEL);
+
+  button = gtk_button_new_with_mnemonic (_("_Empty Trash"));
+  gtk_widget_show (button);
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
+                                GTK_RESPONSE_YES);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+                                   GTK_RESPONSE_YES);
+
+  gtk_widget_show (dialog);
+
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (trash_empty_confirmation_response), NULL);
+}
+
+void
+trash_empty (GtkWidget *parent)
+{
+  if (trash_empty_confirm_dialog)
+    gtk_window_present (GTK_WINDOW (trash_empty_confirm_dialog));
+  else if (trash_empty_dialog)
+    gtk_window_present (GTK_WINDOW (trash_empty_dialog));
+
+  /* theoretically possible that an update is pending, but very unlikely. */
+  else if (!trash_empty_update_pending)
+    trash_empty_show_confirmation_dialog (parent);
+}

Added: trunk/trashapplet/src/trash-empty.h
==============================================================================
--- (empty file)
+++ trunk/trashapplet/src/trash-empty.h	Wed Feb 13 07:27:11 2008
@@ -0,0 +1,29 @@
+/*
+ * trash-empty.h: empty the trash
+ *
+ * Copyright  2008 Ryan Lortie
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _trash_empty_h_
+#define _trash_empty_h_
+
+#include <gio/gio.h>
+
+void trash_empty (GtkWidget *parent);
+
+#endif /* _trash_empty_h_ */

Modified: trunk/trashapplet/src/trash-monitor.c
==============================================================================
--- trunk/trashapplet/src/trash-monitor.c	(original)
+++ trunk/trashapplet/src/trash-monitor.c	Wed Feb 13 07:27:11 2008
@@ -321,70 +321,3 @@
 
   return g_object_ref (monitor);
 }
-
-/*
- * if @file is a directory, delete its contents (but not @file itself).
- * if @file is not a directory, do nothing.
- */
-static void
-trash_monitor_delete_contents (GFile        *file,
-                               GCancellable *cancellable)
-{
-  GFileEnumerator *enumerator;
-  GFileInfo *info;
-  GFile *child;
-
-  if (g_cancellable_is_cancelled (cancellable))
-    return;
-
-  enumerator = g_file_enumerate_children (file,
-                                          G_FILE_ATTRIBUTE_STANDARD_NAME,
-                                          G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                          cancellable, NULL);
-  if (enumerator) 
-    {
-      while ((info = g_file_enumerator_next_file (enumerator,
-                                                  cancellable, NULL)) != NULL)
-        {
-          child = g_file_get_child (file, g_file_info_get_name (info));
-
-          /* it's just as fast to assume that all entries are subdirectories
-           * and try to erase their contents as it is to actually do the
-           * extra stat() call up front...
-           */
-          trash_monitor_delete_contents (child, cancellable);
-
-          g_file_delete (child, cancellable, NULL);
-
-          g_object_unref (child);
-          g_object_unref (info);
-
-          if (g_cancellable_is_cancelled (cancellable))
-            break;
-        }
-
-      g_object_unref (enumerator);
-    }
-}
-
-static gboolean
-trash_monitor_empty_job (GIOSchedulerJob *job,
-                         GCancellable    *cancellable,
-                         gpointer         user_data)
-{
-  TrashMonitor *monitor = user_data;
-
-  trash_monitor_delete_contents (monitor->trash, cancellable);
-
-  return FALSE;
-}
-
-void
-trash_monitor_empty_trash (TrashMonitor *monitor,
-			   GCancellable *cancellable,
-			   gpointer      func, 
-			   gpointer      user_data)
-{
-  g_io_scheduler_push_job (trash_monitor_empty_job,
-                           monitor, NULL, 0, cancellable);
-}

Modified: trunk/trashapplet/src/trash-monitor.h
==============================================================================
--- trunk/trashapplet/src/trash-monitor.h	(original)
+++ trunk/trashapplet/src/trash-monitor.h	Wed Feb 13 07:27:11 2008
@@ -34,9 +34,4 @@
 GType           trash_monitor_get_type          (void);
 TrashMonitor   *trash_monitor_new               (void);
 
-void            trash_monitor_empty_trash       (TrashMonitor *monitor,
-				                 GCancellable *cancellable,
-				                 gpointer      func,
-				                 gpointer      user_data);
-
 #endif

Modified: trunk/trashapplet/src/trashapplet.c
==============================================================================
--- trunk/trashapplet/src/trashapplet.c	(original)
+++ trunk/trashapplet/src/trashapplet.c	Wed Feb 13 07:27:11 2008
@@ -32,7 +32,6 @@
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 #include <libgnome/gnome-help.h>
-#include <glade/glade.h>
 #include <gio/gio.h>
 
 #include "trashapplet.h"
@@ -514,110 +513,12 @@
 	g_free (error_string);
 }
 
-/* this function is based on the one with the same name in
-   libnautilus-private/nautilus-file-operations.c */
-#define NAUTILUS_PREFERENCES_CONFIRM_TRASH    "/apps/nautilus/preferences/confirm_trash"
-static gboolean
-confirm_empty_trash (GtkWidget *parent_view)
-{
-	GtkWidget *dialog;
-	GtkWidget *button;
-	GdkScreen *screen;
-	int response;
-
-	/* Just Say Yes if the preference says not to confirm. */
-	/* Note: use directly gconf instead eel as in original nautilus function*/
-	if (!gconf_client_get_bool (client,
-				    NAUTILUS_PREFERENCES_CONFIRM_TRASH,
-				    NULL)) {
-		return TRUE;
-	}
-	
-	screen = gtk_widget_get_screen (parent_view);
-
-	dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_WARNING,
-					 GTK_BUTTONS_NONE,
-					 _("Empty all of the items from "
-					   "the trash?"));
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("If you choose to empty "
-						    "the trash, all items in "
-						    "it will be permanently "
-						    "lost. Please note that "
-						    "you can also delete them "
-						    "separately."));
-
-	gtk_window_set_screen (GTK_WINDOW (dialog), screen);
-	atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
-	gtk_window_set_wmclass (GTK_WINDOW (dialog), "empty_trash",
-				"Nautilus");
-
-	/* Make transient for the window group */
-        gtk_widget_realize (dialog);
-	gdk_window_set_transient_for (GTK_WIDGET (dialog)->window,
-				      gdk_screen_get_root_window (screen));
-
-	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
-			       GTK_RESPONSE_CANCEL);
-
-	button = gtk_button_new_with_mnemonic (_("_Empty Trash"));
-	gtk_widget_show (button);
-	GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-
-	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
-				      GTK_RESPONSE_YES);
-
-	gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-					 GTK_RESPONSE_YES);
-
-	response = gtk_dialog_run (GTK_DIALOG (dialog));
-
-	gtk_object_destroy (GTK_OBJECT (dialog));
-
-	return response == GTK_RESPONSE_YES;
-}
-
-static void
-on_empty_trash_cancel (GtkWidget    *widget,
-                       GCancellable *cancellable)
-{
-  g_cancellable_cancel (cancellable);
-  gtk_widget_hide (widget);
-}
-
 static void
 trash_applet_do_empty (BonoboUIComponent *component,
 		       TrashApplet       *applet,
 		       const gchar       *cname)
 {
-	GtkWidget *dialog;
-
-	GCancellable *cancellable;
-
-	g_return_if_fail (TRASH_IS_APPLET (applet));
-
-	if (applet->is_empty)
-		return;
-
-	if (!confirm_empty_trash (GTK_WIDGET (applet)))
-		return;
-
-	if (!applet->xml)
-	  applet->xml = glade_xml_new (GNOME_GLADEDIR "/trashapplet.glade", NULL, NULL);
-
-        dialog = glade_xml_get_widget (applet->xml, "empty_trash");
-
-	cancellable = g_cancellable_new ();
-	g_signal_connect (dialog, "response", G_CALLBACK (on_empty_trash_cancel), cancellable);
-
-	gtk_widget_show_all (dialog);
-
-	trash_monitor_empty_trash (applet->monitor,
-				   cancellable, NULL, applet);
-
-	gtk_widget_hide (dialog);
-
+  trash_empty (GTK_WIDGET (applet));
 }
 
 
@@ -682,6 +583,7 @@
 		"Emmanuele Bassi <ebassi gmail com>",
 		"Sebastian Bacher <seb128 canonical com>",
 		"James Henstridge <james henstridge canonical com>",
+                "Ryan Lortie <desrt desrt ca>",
 		NULL
 	};
 	static const char *documenters[] = {
@@ -692,7 +594,8 @@
 	gtk_show_about_dialog
 		(NULL,
 		 "version", VERSION,
-		 "copyright", "Copyright \xC2\xA9 2004 Michiel Sikkes",
+		 "copyright", "Copyright \xC2\xA9 2004 Michiel Sikkes,"
+                              "\xC2\xA9 2008 Ryan Lortie",
 		 "comments", _("A GNOME trash bin that lives in your panel. "
 			       "You can use it to view the trash or drag "
 			       "and drop items into the trash."),

Modified: trunk/trashapplet/src/trashapplet.h
==============================================================================
--- trunk/trashapplet/src/trashapplet.h	(original)
+++ trunk/trashapplet/src/trashapplet.h	Wed Feb 13 07:27:11 2008
@@ -24,7 +24,6 @@
 
 #include <panel-applet.h>
 #include <gnome.h>
-#include <glade/glade.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include "trash-monitor.h"
 
@@ -62,8 +61,6 @@
 	gboolean is_empty;
 	gboolean drag_hover;
 
-	GladeXML *xml;
-
 	TrashMonitor *monitor;
 	guint monitor_signal_id;
 

Added: trunk/trashapplet/trashapplet-empty-progress.ui
==============================================================================
--- (empty file)
+++ trunk/trashapplet/trashapplet-empty-progress.ui	Wed Feb 13 07:27:11 2008
@@ -0,0 +1,98 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<interface>
+  <object class='GtkDialog' id='empty_trash'>
+    <property name='border_width'>6</property>
+    <property name='title' translatable="yes">Emptying the Trash</property>
+    <property name='default_width'>400</property>
+    <property name='has_separator'>False</property>
+
+    <child internal-child='vbox'>
+      <object class='GtkVBox' id='dialog-vbox1'>
+
+        <child internal-child='action_area'>
+          <object class='GtkHButtonBox' id='dialog-action_area1'>
+
+            <child>
+              <object class='GtkButton' id='cancel_button'>
+                <property name='visible'>True</property>
+                <property name='label'>gtk-cancel</property>
+                <property name='use_stock'>True</property>
+              </object>
+            </child>
+          </object>
+        </child>
+
+        <child>
+          <object class='GtkVBox' id='vbox1'>
+            <property name='visible'>True</property>
+            <property name='border_width'>6</property>
+            <property name='spacing'>12</property>
+
+            <child>
+              <object class='GtkLabel' id='label1'>
+                <property name='visible'>True</property>
+                <property name='label' translatable="yes">&lt;big&gt;&lt;b&gt;Emptying the Trash&lt;/b&gt;&lt;/big&gt;</property>
+                <property name='use_markup'>True</property>
+                <property name='xalign'>0</property>
+              </object>
+            </child>
+
+            <child>
+              <object class='GtkHBox' id='hbox1'>
+                <property name='visible'>True</property>
+
+                <child>
+                  <object class='GtkLabel' id='label3'>
+                    <property name='label' translatable="yes">&lt;b&gt;From:&lt;/b&gt;</property>
+                    <property name='use_markup'>True</property>
+                  </object>
+                  <packing>
+                    <property name='expand'>False</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class='GtkLabel' id='location_label'>
+                    <property name='visible'>True</property>
+                    <property name='xalign'>0.0</property>
+                    <property name='ellipsize'>PANGO_ELLIPSIZE_MIDDLE</property>
+                  </object>
+                  <packing>
+                    <property name='fill'>True</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+
+            <child>
+              <object class='GtkVBox' id='vbox2'>
+                <property name='visible'>True</property>
+
+                <child>
+                  <object class='GtkProgressBar' id='progressbar'>
+                    <property name='visible'>True</property>
+                    <property name='text'>  </property>
+                  </object>
+                </child>
+
+                <child>
+                  <object class='GtkLabel' id='file_label'>
+                    <property name='visible'>True</property>
+                    <property name='label'>  </property>
+                    <property name='xalign'>0</property>
+                    <property name='ellipsize'>PANGO_ELLIPSIZE_END</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+
+    <action-widgets>
+      <action-widget response='-6'>cancel_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]