Git Repositories

2006-03-24 Benedikt Meurer <benny@xfce.org>
authorBenedikt Meurer <benny@xfce.org>
Fri, 24 Mar 2006 13:10:04 +0000 (13:10 +0000)
committerBenedikt Meurer <benny@xfce.org>
Fri, 24 Mar 2006 13:10:04 +0000 (13:10 +0000)
* thunar/thunar-renamer-progress.{c,h}: Add new helper method
  thunar_renamer_progress_running(), which tells whether the rename
  operation is currently in progress.
* thunar/thunar-renamer-dialog.c(thunar_renamer_dialog_response): Fix
  the Cancel/Close button handling.
* examples/nautilus-bulk-rename.py, examples/Makefile.am: Add an ex-
  ample how to use Thunar Bulk Rename as Nautilus extension. Bug #1597.

(Old svn revision: 20528)

ChangeLog
examples/Makefile.am
examples/nautilus-bulk-rename.py [new file with mode: 0644]
thunar/thunar-renamer-dialog.c
thunar/thunar-renamer-progress.c
thunar/thunar-renamer-progress.h

index b47365f..bca6883 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2006-03-24     Benedikt Meurer <benny@xfce.org>
 
+       * thunar/thunar-renamer-progress.{c,h}: Add new helper method
+         thunar_renamer_progress_running(), which tells whether the rename
+         operation is currently in progress.
+       * thunar/thunar-renamer-dialog.c(thunar_renamer_dialog_response): Fix
+         the Cancel/Close button handling.
+       * examples/nautilus-bulk-rename.py, examples/Makefile.am: Add an ex-
+         ample how to use Thunar Bulk Rename as Nautilus extension. Bug #1597.
+
+2006-03-24     Benedikt Meurer <benny@xfce.org>
+
        * thunar/thunar-file.{c,h}: Add wrapper method thunar_file_get_for_uri()
          which is a rather common operation.
        * thunar/thunar-dbus-service.c
index 8ced9db..3c5d1a4 100644 (file)
@@ -4,6 +4,7 @@ SUBDIRS =                                                               \
        tex-open-terminal
 
 EXTRA_DIST =                                                           \
+       nautilus-bulk-rename.py                                         \
        thunar-file-manager.py                                          \
        xfce-file-manager.py
 
diff --git a/examples/nautilus-bulk-rename.py b/examples/nautilus-bulk-rename.py
new file mode 100644 (file)
index 0000000..c058927
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# $Id$
+#
+# Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
+#
+# 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
+#
+
+# --------------------------------------------------------------- #
+# This example demonstrates how to integrate Thunar's Bulk Rename #
+# functionality into Nautilus. You'll need the nautilus-python    #
+# bindings to actually try this example.                          #
+#                                                                 #
+# Just copy this file to                                          #
+#                                                                 #
+#   ~/.nautilus/python-extensions/                                #
+#                                                                 #
+# creating the directory if it does not already exist, and re-    #
+# start Nautilus. Afterwards you'll see an action labeled "Bulk   #
+# Rename" in the file context menu, which can be used to rename   #
+# the selected files.                                             #
+#                                                                 #
+# Thunar must be compiled with D-BUS support for this to work.    #
+# --------------------------------------------------------------- #
+
+
+import gtk
+import nautilus
+
+import dbus
+import dbus.service
+if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
+  import dbus.glib
+
+class NautilusBulkRename(nautilus.MenuProvider):
+  def __init__(self):
+    bus = dbus.SessionBus()
+    thunar_object = bus.get_object('org.xfce.Thunar', '/org/xfce/FileManager')
+    self.thunar = dbus.Interface(thunar_object, 'org.xfce.Thunar')
+
+  def menu_activate_cb(self, item, files):
+    uris = []
+    for file in files:
+      uris.append(file.get_uri())
+    self.thunar.BulkRename(files[0].get_parent_uri(), uris, False, item.get_data('display'))
+
+  def get_file_items(self, window, files):
+    if len(files) == 0:
+      return
+
+    item = nautilus.MenuItem('NautilusBulkRename::bulk-rename', 'Bulk Rename', 'Rename all selected files at once')
+    item.set_data('display', window.get_screen().make_display_name())
+    item.connect('activate', self.menu_activate_cb, files)
+    return item,
index 3eab3e1..de9c218 100644 (file)
@@ -751,12 +751,12 @@ thunar_renamer_dialog_response (GtkDialog *dialog,
           gtk_widget_destroy (GTK_WIDGET (dialog));
         }
     }
-  else if (!thunar_renamer_dialog_get_standalone (renamer_dialog) || response == GTK_RESPONSE_CANCEL)
+  else if (thunar_renamer_progress_running (THUNAR_RENAMER_PROGRESS (renamer_dialog->progress)))
     {
       /* cancel the rename operation */
       thunar_renamer_progress_cancel (THUNAR_RENAMER_PROGRESS (renamer_dialog->progress));
     }
-  else if (thunar_renamer_dialog_get_standalone (renamer_dialog))
+  else
     {
       /* hide and destroy the dialog window */
       gtk_widget_hide (GTK_WIDGET (dialog));
index e4cb5cd..7c2e3ef 100644 (file)
@@ -336,6 +336,23 @@ thunar_renamer_progress_cancel (ThunarRenamerProgress *renamer_progress)
 
 
 /**
+ * thunar_renamer_progress_running:
+ * @renamer_progress : a #ThunarRenamerProgress.
+ *
+ * Returns %TRUE if @renamer_progress is running.
+ *
+ * Return value: %TRUE if @renamer_progress is running.
+ **/
+gboolean
+thunar_renamer_progress_running (ThunarRenamerProgress *renamer_progress)
+{
+  g_return_val_if_fail (THUNAR_IS_RENAMER_PROGRESS (renamer_progress), FALSE);
+  return (renamer_progress->next_idle_loop != NULL);
+}
+
+
+
+/**
  * thunar_renamer_progress_run:
  * @renamer_progress : a #ThunarRenamerProgress.
  * @pair_list        : a #GList of #ThunarRenamePair<!---->s.
index a6ed2ec..0419092 100644 (file)
@@ -40,6 +40,8 @@ GtkWidget *thunar_renamer_progress_new      (void) G_GNUC_MALLOC;
 
 void       thunar_renamer_progress_cancel   (ThunarRenamerProgress *renamer_progress);
 
+gboolean   thunar_renamer_progress_running  (ThunarRenamerProgress *renamer_progress);
+
 void       thunar_renamer_progress_run      (ThunarRenamerProgress *renamer_progress,
                                              GList                 *pair_list);