Re: Trash LocationWidgetProvider
- From: "Lakin Wecker" <lakin wecker gmail com>
- To: nautilus-list gnome org
- Subject: Re: Trash LocationWidgetProvider
- Date: Wed, 26 Apr 2006 08:32:18 -0600
This morning, is not my morning, I should go back to bed. Patch is
attached for real this time.
Lakin
On 4/26/06, Lakin Wecker <lakin wecker gmail com> wrote:
> Ugh, I replied only to alex the first time. Sorry.
>
> On 4/26/06, Alexander Larsson <alexl redhat com> wrote:
> > I'm not sure exactly what you mean, because you didn't attach the patch,
>
> I was using my http://pages.cpsc.ucalgary.ca/~weckerl/nautilus_patch.html
> page to host the patch, but I suppose the general standard around
> here, is to attach the patch to messages. And in either case, I
> forgot to mention the link.
>
> I've attached the patch this time.
>
> > however, the extra widgets added in with add_extra_location_widget gets
> > cleaned up in the call to remove_extra_location_widgets() in
> > update_for_new_location().
>
> Thanks for the clarification.
>
> Lakin
>
diff -Nur nautilus-2.14.0.orig/src/Makefile.am nautilus-2.14.0/src/Makefile.am
--- nautilus-2.14.0.orig/src/Makefile.am 2005-12-12 09:29:52.000000000 -0700
+++ nautilus-2.14.0/src/Makefile.am 2006-03-23 10:37:41.000000000 -0700
@@ -103,6 +103,8 @@
nautilus-query-editor.h \
nautilus-search-bar.c \
nautilus-search-bar.h \
+ nautilus-trash-directory-bar.c \
+ nautilus-trash-directory-bar.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-shell.c \
diff -Nur nautilus-2.14.0.orig/src/nautilus-trash-directory-bar.c nautilus-2.14.0/src/nautilus-trash-directory-bar.c
--- nautilus-2.14.0.orig/src/nautilus-trash-directory-bar.c 1969-12-31 17:00:00.000000000 -0700
+++ nautilus-2.14.0/src/nautilus-trash-directory-bar.c 2006-03-23 10:38:02.000000000 -0700
@@ -0,0 +1,158 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Lakin Wecker <lakin wecker gmail com>
+ *
+ * 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.
+ *
+ * Authors: Lakin Wecker <lakin wecker gmail com>
+ * Based heavily off of code written by William Jon McCann <mccann jhu edu>
+ * in nautilus-cd-burner-2.13.90/nautilus-burn-bar.c
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#include "nautilus-trash-directory-bar.h"
+#include "nautilus-trash-monitor.h"
+
+static void nautilus_trash_directory_bar_class_init (NautilusTrashDirectoryBarClass *klass);
+static void nautilus_trash_directory_bar_init (NautilusTrashDirectoryBar *bar);
+static void nautilus_trash_directory_bar_finalize (GObject *object);
+
+#define NAUTILUS_TRASH_DIRECTORY_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR, NautilusTrashDirectoryBarPrivate))
+
+struct NautilusTrashDirectoryBarPrivate
+{
+ GtkTooltips *tooltips;
+ GtkWidget *button;
+};
+
+enum {
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+static GObjectClass *parent_class = NULL;
+static guint signals [LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (NautilusTrashDirectoryBar, nautilus_trash_directory_bar, GTK_TYPE_HBOX)
+
+static void
+nautilus_trash_directory_bar_class_init (NautilusTrashDirectoryBarClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = nautilus_trash_directory_bar_finalize;
+ g_type_class_add_private (klass, sizeof (NautilusTrashDirectoryBarPrivate));
+
+ signals [ACTIVATE] = g_signal_new ("activate",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusTrashDirectoryBarClass, activate),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+}
+
+static void
+button_clicked_cb (GtkWidget *button,
+ NautilusTrashDirectoryBar *bar)
+{
+ g_signal_emit (bar, signals [ACTIVATE], 0);
+}
+
+void
+trash_state_changed_cb (NautilusTrashMonitor *emitting_signal,
+ gboolean trash_empty,
+ NautilusTrashDirectoryBar *bar)
+{
+ gtk_widget_set_sensitive (bar->priv->button, !trash_empty);
+}
+
+
+static void
+nautilus_trash_directory_bar_init (NautilusTrashDirectoryBar *bar)
+{
+ GtkWidget *label;
+ GtkWidget *hbox;
+
+ bar->priv = NAUTILUS_TRASH_DIRECTORY_BAR_GET_PRIVATE (bar);
+
+ bar->priv->tooltips = gtk_tooltips_new ();
+ g_object_ref (bar->priv->tooltips);
+ gtk_object_sink (GTK_OBJECT (bar->priv->tooltips));
+
+ hbox = GTK_WIDGET (bar);
+
+ label = gtk_label_new (_("Trash Folder"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ bar->priv->button = gtk_button_new_with_label (_("Empty Trash"));
+ gtk_widget_show (bar->priv->button);
+ gtk_box_pack_end (GTK_BOX (hbox), bar->priv->button, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive (bar->priv->button, !nautilus_trash_monitor_is_empty());
+
+ g_signal_connect (bar->priv->button, "clicked",
+ G_CALLBACK (button_clicked_cb),
+ bar);
+
+ g_signal_connect_object (nautilus_trash_monitor_get(),
+ "trash_state_changed",
+ G_CALLBACK (trash_state_changed_cb),
+ bar,
+ 0);
+ gtk_tooltips_set_tip (GTK_TOOLTIPS (bar->priv->tooltips),
+ bar->priv->button,
+ _("Empty the contents of the trash."),
+ NULL);
+}
+
+static void
+nautilus_trash_directory_bar_finalize (GObject *object)
+{
+ NautilusTrashDirectoryBar *bar;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (NAUTILUS_IS_TRASH_DIRECTORY_BAR (object));
+
+ bar = NAUTILUS_TRASH_DIRECTORY_BAR (object);
+
+ g_return_if_fail (bar->priv != NULL);
+
+ if (bar->priv->tooltips != NULL) {
+ g_object_unref (bar->priv->tooltips);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+GtkWidget *
+nautilus_trash_directory_bar_new (void)
+{
+ GObject *result;
+
+ result = g_object_new (NAUTILUS_TYPE_TRASH_DIRECTORY_BAR,
+ NULL);
+
+ return GTK_WIDGET (result);
+
+}
diff -Nur nautilus-2.14.0.orig/src/nautilus-trash-directory-bar.h nautilus-2.14.0/src/nautilus-trash-directory-bar.h
--- nautilus-2.14.0.orig/src/nautilus-trash-directory-bar.h 1969-12-31 17:00:00.000000000 -0700
+++ nautilus-2.14.0/src/nautilus-trash-directory-bar.h 2006-03-23 10:37:59.000000000 -0700
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Lakin Wecker <lakin wecker gmail com>
+ *
+ * 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.
+ *
+ * Authors: Lakin Wecker <lakin wecker gmail com>
+ * Based heavily off of code written by William Jon McCann <mccann jhu edu>
+ * in nautilus-cd-burner-2.13.90/nautilus-burn-bar.h
+ *
+ *
+ */
+
+#ifndef __NAUTILUS_TRASH_DIRECTORY_BAR_H
+#define __NAUTILUS_TRASH_DIRECTORY_BAR_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_TRASH_DIRECTORY_BAR (nautilus_trash_directory_bar_get_type ())
+#define NAUTILUS_TRASH_DIRECTORY_BAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR, NautilusTrashDirectoryBar))
+#define NAUTILUS_TRASH_DIRECTORY_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR, NautilusTrashDirectoryBarClass))
+#define NAUTILUS_IS_TRASH_DIRECTORY_BAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR))
+#define NAUTILUS_IS_TRASH_DIRECTORY_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR))
+#define NAUTILUS_TRASH_DIRECTORY_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_TRASH_DIRECTORY_BAR, NautilusTrashDirectoryBarClass))
+
+typedef struct NautilusTrashDirectoryBarPrivate NautilusTrashDirectoryBarPrivate;
+
+typedef struct
+{
+ GtkHBox box;
+
+ NautilusTrashDirectoryBarPrivate *priv;
+} NautilusTrashDirectoryBar;
+
+typedef struct
+{
+ GtkHBoxClass parent_class;
+
+ void (* activate) (NautilusTrashDirectoryBar *bar);
+
+} NautilusTrashDirectoryBarClass;
+
+GType nautilus_trash_directory_bar_get_type (void);
+GtkWidget *nautilus_trash_directory_bar_new (void);
+
+G_END_DECLS
+
+#endif /* __GS_TRASH_DIRECTORY_BAR_H */
diff -Nur nautilus-2.14.0.orig/src/nautilus-window-manage-views.c nautilus-2.14.0/src/nautilus-window-manage-views.c
--- nautilus-2.14.0.orig/src/nautilus-window-manage-views.c 2006-03-03 06:42:51.000000000 -0700
+++ nautilus-2.14.0/src/nautilus-window-manage-views.c 2006-03-23 10:38:42.000000000 -0700
@@ -32,6 +32,7 @@
#include "nautilus-application.h"
#include "nautilus-location-bar.h"
#include "nautilus-search-bar.h"
+#include "nautilus-trash-directory-bar.h"
#include "nautilus-pathbar.h"
#include "nautilus-main.h"
#include "nautilus-window-private.h"
@@ -55,6 +56,7 @@
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-extension/nautilus-location-widget-provider.h>
#include <libnautilus-private/nautilus-file-attributes.h>
+#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-global-preferences.h>
@@ -63,6 +65,7 @@
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-monitor.h>
#include <libnautilus-private/nautilus-search-directory.h>
+#include <libnautilus-private/nautilus-trash-directory.h>
#include <libnautilus-private/nautilus-view-factory.h>
#include <libnautilus-private/nautilus-window-info.h>
@@ -1229,6 +1232,14 @@
} else {
nautilus_window_set_search_mode (window, FALSE, NULL);
}
+ if (NAUTILUS_IS_TRASH_DIRECTORY (directory)) {
+ GtkWidget *bar;
+ bar = nautilus_trash_directory_bar_new ();
+ g_signal_connect (bar, "activate", G_CALLBACK (nautilus_file_operations_empty_trash), window);
+ gtk_widget_show (bar);
+
+ nautilus_window_add_extra_location_widget (window, bar);
+ }
nautilus_directory_unref (directory);
add_extension_extra_widgets (window, window->details->location);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]