Commit 1d7d408f authored by Benedikt Meurer's avatar Benedikt Meurer

2006-03-21 Benedikt Meurer <benny@xfce.org>

	* plugins/thunar-uca/README: Fix typos.
	* thunarx/thunarx-private.{c,h}: Import new helper function
	  thunarx_param_spec_get_option_name().
	* thunarx/Makefile.am, thunarx/thunarx.h, thunarx/thunarx-renamer.{c,h},
	  thunarx/thunarx-renamer-provider.{c,h}, thunarx/thunarx.symbols:
	  Merge the ThunarxRenamer extension point, which can be used to hook
	  additional bulk renamers into Thunar. Bug #1416.
	* thunar/thunar-renamer-dialog.{c,h}, thunar/thunar-renamer-model.{c,h},
	  thunar/thunar-renamer-pair.{c,h},thunar/thunar-renamer-progress.{c,h},
	  thunar/Makefile.am, thunar/thunar-standard-view.c: Merge the bulk
	  rename framework for Thunar, which uses the ThunarxRenamers to
	  rename multiple files at once. Bug #1416.
	* acinclude.m4, configure.in.in, plugins/thunar-sbr/, 
	  plugins/Makefile.am: Merge stable version of the thunar-sbr exten-
	  sion ("Simple Builtin Renamers"), which provides "Search & Replace",
	  which optionally uses PCRE to support regular expressions, and
	  "Convert upper/lowercase". Additional renamers will be merged once
	  ready. Bug #1416.
	* po/POTFILES.in: Add new files.
	* po/Thunar.pot, po/*.po: Merge new strings.
	* po/de.po: Update german translations.




(Old svn revision: 20517)
parent f2827ae8
2006-03-21 Benedikt Meurer <benny@xfce.org>
* plugins/thunar-uca/README: Fix typos.
* thunarx/thunarx-private.{c,h}: Import new helper function
thunarx_param_spec_get_option_name().
* thunarx/Makefile.am, thunarx/thunarx.h, thunarx/thunarx-renamer.{c,h},
thunarx/thunarx-renamer-provider.{c,h}, thunarx/thunarx.symbols:
Merge the ThunarxRenamer extension point, which can be used to hook
additional bulk renamers into Thunar. Bug #1416.
* thunar/thunar-renamer-dialog.{c,h}, thunar/thunar-renamer-model.{c,h},
thunar/thunar-renamer-pair.{c,h},thunar/thunar-renamer-progress.{c,h},
thunar/Makefile.am, thunar/thunar-standard-view.c: Merge the bulk
rename framework for Thunar, which uses the ThunarxRenamers to
rename multiple files at once. Bug #1416.
* acinclude.m4, configure.in.in, plugins/thunar-sbr/,
plugins/Makefile.am: Merge stable version of the thunar-sbr exten-
sion ("Simple Builtin Renamers"), which provides "Search & Replace",
which optionally uses PCRE to support regular expressions, and
"Convert upper/lowercase". Additional renamers will be merged once
ready. Bug #1416.
* po/POTFILES.in: Add new files.
* po/Thunar.pot, po/*.po: Merge new strings.
* po/de.po: Update german translations.
2006-03-21 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-gobject-extensions.c
......
......@@ -8,6 +8,25 @@ dnl
dnl # BM_THUNAR_PLUGIN_SBR()
dnl #
dnl # Check whether the "Simple Builtin Renamers" plugin
dnl # should be built and installed.
dnl #
AC_DEFUN([BM_THUNAR_PLUGIN_SBR],
[
AC_ARG_ENABLE([sbr-plugin], AC_HELP_STRING([--disable-sbr-plugin], [Don't build the thunar-sbr plugin, see plugins/thunar-sbr/README]),
[ac_bm_thunar_plugin_sbr=$enable_val], [ac_bm_thunar_plugin_sbr=yes])
AC_MSG_CHECKING([whether to build the thunar-sbr plugin])
AM_CONDITIONAL([THUNAR_PLUGIN_SBR], [test x"$ac_bm_thunar_plugin_sbr" = x"yes"])
AC_MSG_RESULT([$ac_bm_thunar_plugin_sbr])
dnl Check for PCRE (for the "Search & Replace" renamer)
XDT_CHECK_OPTIONAL_PACKAGE([PCRE], [libpcre], [6.0], [pcre], [Regular expression support])
])
dnl # BM_THUNAR_PLUGIN_UCA()
dnl #
dnl # Check whether the "User Customizable Actions" plugin
......
......@@ -341,6 +341,7 @@ AC_SUBST([PLATFORM_LDFLAGS])
dnl ************************************
dnl *** Check for additional plugins ***
dnl ************************************
BM_THUNAR_PLUGIN_SBR()
BM_THUNAR_PLUGIN_UCA()
AC_OUTPUT([
......@@ -369,6 +370,7 @@ icons/48x48/Makefile
icons/scalable/Makefile
pixmaps/Makefile
plugins/Makefile
plugins/thunar-sbr/Makefile
plugins/thunar-uca/Makefile
po/Makefile.in
po-doc/Makefile
......@@ -411,5 +413,6 @@ echo "* Volume Manager: $ac_bm_thunar_vfs_volume_impl"
echo
echo "Additional Plugins:"
echo
echo "* Simple Builting Renamers: $ac_bm_thunar_plugin_sbr"
echo "* User Customizable Actions: $ac_bm_thunar_plugin_uca"
echo
# $Id$
if THUNAR_PLUGIN_SBR
THUNAR_SBR_SUBDIRS = thunar-sbr
endif
if THUNAR_PLUGIN_UCA
THUNAR_UCA_SUBDIRS = thunar-uca
endif
SUBDIRS = \
$(THUNAR_SBR_SUBDIRS) \
$(THUNAR_UCA_SUBDIRS)
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
# $Id$
INCLUDES = \
-I$(top_builddir) \
-I$(top_builddir)/plugins \
-I$(top_srcdir) \
-I$(top_srcdir)/plugins \
-DEXO_API_SUBJECT_TO_CHANGE \
-DG_LOG_DOMAIN=\"thunar-sbr\" \
$(PLATFORM_CPPFLAGS)
extensionsdir = $(libdir)/thunarx-$(THUNAR_VERSION_API)
extensions_LTLIBRARIES = \
thunar-sbr.la
thunar_sbr_la_SOURCES = \
thunar-sbr-case-renamer.c \
thunar-sbr-case-renamer.h \
thunar-sbr-enum-types.c \
thunar-sbr-enum-types.h \
thunar-sbr-plugin.c \
thunar-sbr-provider.c \
thunar-sbr-provider.h \
thunar-sbr-replace-renamer.c \
thunar-sbr-replace-renamer.h
thunar_sbr_la_CFLAGS = \
$(EXO_CFLAGS) \
$(PCRE_CFLAGS) \
$(PLATFORM_CFLAGS)
thunar_sbr_la_LDFLAGS = \
-avoid-version \
-export-dynamic \
-module \
$(PLATFORM_LDFLAGS)
thunar_sbr_la_LIBADD = \
$(PCRE_LIBS)
EXTRA_DIST = \
README
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
Thunar Simple Builtin Renamers (thunar-sbr)
===========================================
Thunar-sbr is an extension to Thunar, which includes a bunch of simple renamers
for the bulk rename dialog:
* Convert upper/lowercase
* Search & Replace
By default the thunar-sbr extension will be installed, but as with every
extension, it will slightly increase the resource usage of Thunar (this
shouldn't be a real problem unless you're targeting an embedded system), and so
you can pass `--disable-sbr-plugin' to configure and the plugin won't be built
and installed. Since it is an extension, you can also easily uninstall it
afterwards by removing the thunar-sbr.so file from the lib/thunarx-1/ directory
of your installation (be sure to quit Thunar before removing files though).
Regular Expressions
-------------------
The "Search & Replace" renamer can be built with support for regular ex-
pressions using the Perl-compatible regular expression (PCRE) library
version 6.0 or above. The reasons to use PCRE instead of the POSIX regular
expressions, that are part of the system C library, are:
* PCRE supports UTF-8, which Thunar uses internally for all user visible
texts (be sure to enable this when installing PCRE using the --enable-utf8
configure switch).
* PCRE uses a more consistent syntax, which is easier to understand for
most people.
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <exo/exo.h>
#include <thunar-sbr/thunar-sbr-case-renamer.h>
/* Property identifiers */
enum
{
PROP_0,
PROP_MODE,
};
static void thunar_sbr_case_renamer_class_init (ThunarSbrCaseRenamerClass *klass);
static void thunar_sbr_case_renamer_init (ThunarSbrCaseRenamer *case_renamer);
static void thunar_sbr_case_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void thunar_sbr_case_renamer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static gchar *thunar_sbr_case_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
guint index);
struct _ThunarSbrCaseRenamerClass
{
ThunarxRenamerClass __parent__;
};
struct _ThunarSbrCaseRenamer
{
ThunarxRenamer __parent__;
ThunarSbrCaseRenamerMode mode;
};
THUNARX_DEFINE_TYPE (ThunarSbrCaseRenamer, thunar_sbr_case_renamer, THUNARX_TYPE_RENAMER);
static void
thunar_sbr_case_renamer_class_init (ThunarSbrCaseRenamerClass *klass)
{
ThunarxRenamerClass *thunarxrenamer_class;
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = thunar_sbr_case_renamer_get_property;
gobject_class->set_property = thunar_sbr_case_renamer_set_property;
thunarxrenamer_class = THUNARX_RENAMER_CLASS (klass);
thunarxrenamer_class->process = thunar_sbr_case_renamer_process;
/**
* ThunarSbrCaseRenamer:mode:
*
* The #ThunarSbrCaseRenamerMode for this
* #ThunarSbrCaseRenamer instance.
**/
g_object_class_install_property (gobject_class,
PROP_MODE,
g_param_spec_enum ("mode", "mode", "mode",
THUNAR_SBR_TYPE_CASE_RENAMER_MODE,
THUNAR_SBR_CASE_RENAMER_MODE_LOWER,
G_PARAM_READWRITE));
}
static void
thunar_sbr_case_renamer_init (ThunarSbrCaseRenamer *case_renamer)
{
AtkRelationSet *relations;
AtkRelation *relation;
GEnumClass *klass;
AtkObject *object;
GtkWidget *combo;
GtkWidget *label;
GtkWidget *hbox;
gint n;
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (case_renamer), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("Con_vert to:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
combo = gtk_combo_box_new_text ();
klass = g_type_class_ref (THUNAR_SBR_TYPE_CASE_RENAMER_MODE);
for (n = 0; n < klass->n_values; ++n)
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick));
exo_mutual_binding_new (G_OBJECT (case_renamer), "mode", G_OBJECT (combo), "active");
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
g_type_class_unref (klass);
gtk_widget_show (combo);
/* set Atk label relation for the combo */
object = gtk_widget_get_accessible (combo);
relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
atk_relation_set_add (relations, relation);
g_object_unref (G_OBJECT (relation));
}
static void
thunar_sbr_case_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ThunarSbrCaseRenamer *case_renamer = THUNAR_SBR_CASE_RENAMER (object);
switch (prop_id)
{
case PROP_MODE:
g_value_set_enum (value, thunar_sbr_case_renamer_get_mode (case_renamer));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
thunar_sbr_case_renamer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ThunarSbrCaseRenamer *case_renamer = THUNAR_SBR_CASE_RENAMER (object);
switch (prop_id)
{
case PROP_MODE:
thunar_sbr_case_renamer_set_mode (case_renamer, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gchar*
tscr_utf8_strcamel (const gchar *text)
{
const gchar *t;
gboolean upper = TRUE;
gunichar c;
GString *result;
/* allocate a new string for the result */
result = g_string_sized_new (32);
/* convert the input text */
for (t = text; *t != '\0'; t = g_utf8_next_char (t))
{
/* check the next char */
c = g_utf8_get_char (t);
if (g_unichar_isspace (c))
{
upper = TRUE;
}
else if (upper)
{
c = g_unichar_toupper (c);
upper = FALSE;
}
else
{
c = g_unichar_tolower (c);
}
/* append the char to the result */
g_string_append_unichar (result, c);
}
return g_string_free (result, FALSE);
}
static gchar*
thunar_sbr_case_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
guint index)
{
ThunarSbrCaseRenamer *case_renamer = THUNAR_SBR_CASE_RENAMER (renamer);
switch (case_renamer->mode)
{
case THUNAR_SBR_CASE_RENAMER_MODE_LOWER:
return g_utf8_strdown (text, -1);
case THUNAR_SBR_CASE_RENAMER_MODE_UPPER:
return g_utf8_strup (text, -1);
case THUNAR_SBR_CASE_RENAMER_MODE_CAMEL:
return tscr_utf8_strcamel (text);
default:
g_assert_not_reached ();
return NULL;
}
}
/**
* thunar_sbr_case_renamer_new:
*
* Allocates a new #ThunarSbrCaseRenamer instance.
*
* Return value: the newly allocated #ThunarSbrCaseRenamer.
**/
ThunarSbrCaseRenamer*
thunar_sbr_case_renamer_new (void)
{
return g_object_new (THUNAR_SBR_TYPE_CASE_RENAMER,
"name", _("Convert upper/lowercase"),
NULL);
}
/**
* thunar_sbr_case_renamer_get_mode:
* @case_renamer : a #ThunarSbrCaseRenamer.
*
* Returns the current #ThunarSbrCaseRenamerMode
* for the @case_renamer.
*
* Return value: the current mode of @case_renamer.
**/
ThunarSbrCaseRenamerMode
thunar_sbr_case_renamer_get_mode (ThunarSbrCaseRenamer *case_renamer)
{
g_return_val_if_fail (THUNAR_SBR_IS_CASE_RENAMER (case_renamer), THUNAR_SBR_CASE_RENAMER_MODE_LOWER);
return case_renamer->mode;
}
/**
* thunar_sbr_case_renamer_set_mode:
* @case_renamer : a #ThunarSbrCaseRenamer.
* @mode : the new #ThunarSbrCaseRenamerMode.
*
* Sets the #ThunarSbrCaseRenamerMode of the @case_renamer
* to the specified @mode.
**/
void
thunar_sbr_case_renamer_set_mode (ThunarSbrCaseRenamer *case_renamer,
ThunarSbrCaseRenamerMode mode)
{
g_return_if_fail (THUNAR_SBR_IS_CASE_RENAMER (case_renamer));
/* check if we already use that mode */
if (G_UNLIKELY (case_renamer->mode == mode))
return;
/* apply the new mode */
case_renamer->mode = mode;
/* notify listeners */
g_object_notify (G_OBJECT (case_renamer), "mode");
/* emit the "changed" signal */
thunarx_renamer_changed (THUNARX_RENAMER (case_renamer));
}
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __THUNAR_SBR_CASE_RENAMER_H__
#define __THUNAR_SBR_CASE_RENAMER_H__
#include <thunar-sbr/thunar-sbr-enum-types.h>
G_BEGIN_DECLS;
typedef struct _ThunarSbrCaseRenamerClass ThunarSbrCaseRenamerClass;
typedef struct _ThunarSbrCaseRenamer ThunarSbrCaseRenamer;
#define THUNAR_SBR_TYPE_CASE_RENAMER (thunar_sbr_case_renamer_get_type ())
#define THUNAR_SBR_CASE_RENAMER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_SBR_TYPE_CASE_RENAMER, ThunarSbrCaseRenamer))
#define THUNAR_SBR_CASE_RENAMER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_SBR_TYPE_CASE_RENAMER, ThunarSbrCaseRenamerClass))
#define THUNAR_SBR_IS_CASE_RENAMER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_SBR_TYPE_CASE_RENAMER))
#define THUNAR_SBR_IS_CASE_RENAMER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_SBR_TYPE_CASE_RENAMER))
#define THUNAR_SBR_CASE_RENAMER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_SBR_TYPE_CASE_RENAMER, ThunarSbrCaseRenamerClass))
GType thunar_sbr_case_renamer_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
void thunar_sbr_case_renamer_register_type (ThunarxProviderPlugin *plugin) G_GNUC_INTERNAL;
ThunarSbrCaseRenamer *thunar_sbr_case_renamer_new (void) G_GNUC_CONST G_GNUC_INTERNAL G_GNUC_MALLOC;
ThunarSbrCaseRenamerMode thunar_sbr_case_renamer_get_mode (ThunarSbrCaseRenamer *case_renamer) G_GNUC_INTERNAL;
void thunar_sbr_case_renamer_set_mode (ThunarSbrCaseRenamer *case_renamer,
ThunarSbrCaseRenamerMode mode) G_GNUC_INTERNAL;
G_END_DECLS;
#endif /* !__THUNAR_SBR_CASE_RENAMER_H__ */
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n-lib.h>
#include <thunar-sbr/thunar-sbr-enum-types.h>
static GType case_renamer_mode_type;
GType
thunar_sbr_case_renamer_mode_get_type (void)
{
return case_renamer_mode_type;
}
void
thunar_sbr_register_enum_types (ThunarxProviderPlugin *plugin)
{
static const GEnumValue case_renamer_mode_values[] =
{
{ THUNAR_SBR_CASE_RENAMER_MODE_LOWER, "THUNAR_SBR_CASE_RENAMER_MODE_LOWER", N_ ("lowercase"), },
{ THUNAR_SBR_CASE_RENAMER_MODE_UPPER, "THUNAR_SBR_CASE_RENAMER_MODE_UPPER", N_ ("UPPERCASE"), },
{ THUNAR_SBR_CASE_RENAMER_MODE_CAMEL, "THUNAR_SBR_CASE_RENAMER_MODE_CAMEL", N_ ("Camelcase"), },
{ 0, NULL, NULL, },
};
case_renamer_mode_type = thunarx_provider_plugin_register_enum (plugin, "ThunarSbrCaseRenamerMode", case_renamer_mode_values);
}
/* $Id$ */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.