[Goodies-commits] r6674 - in xfce4-clipman-plugin/branches/xfce-4-6: . panel-plugin po
Mike Massonnet
mmassonnet at xfce.org
Wed Feb 11 17:34:02 CET 2009
Author: mmassonnet
Date: 2009-02-11 16:34:01 +0000 (Wed, 11 Feb 2009)
New Revision: 6674
Added:
xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/xfce4-clipman-actions.xml.in
Removed:
xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/xfce4-clipman-actions.xml
Modified:
xfce4-clipman-plugin/branches/xfce-4-6/ChangeLog
xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/Makefile.am
xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/actions.c
xfce4-clipman-plugin/branches/xfce-4-6/po/POTFILES.in
Log:
Add i18n support for the default XML actions file.
Modified: xfce4-clipman-plugin/branches/xfce-4-6/ChangeLog
===================================================================
--- xfce4-clipman-plugin/branches/xfce-4-6/ChangeLog 2009-02-10 17:03:48 UTC (rev 6673)
+++ xfce4-clipman-plugin/branches/xfce-4-6/ChangeLog 2009-02-11 16:34:01 UTC (rev 6674)
@@ -1,3 +1,16 @@
+2009-02-11 Mike Massonnet
+Add i18n support for the default XML actions file.
+
+ - panel-plugin/actions.c, panel-plugin/xfce4-clipman-actions.xml.in,
+ panel-plugin/Makefile.am:
+ Make it possible to have the action and command names
+ translated inside the settings dialog just like it is done
+ with the Thunar User Custom Actions.
+ - panel-plugin/xfce4-clipman-actions.xml:
+ This file is now auto-generated, delete it.
+ - po/POTFILES.in:
+ Add the new .xml.in file to the list of files to translate.
+
2009-01-30 Mike Massonnet
Drop the idea of an icon for an action.
Modified: xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/Makefile.am
===================================================================
--- xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/Makefile.am 2009-02-10 17:03:48 UTC (rev 6673)
+++ xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/Makefile.am 2009-02-11 16:34:01 UTC (rev 6674)
@@ -48,7 +48,9 @@
endif
actionsdir = $(sysconfdir)/xdg/xfce4/panel
-actions_DATA = xfce4-clipman-actions.xml
+actions_in_files = xfce4-clipman-actions.xml.in
+actions_DATA = $(actions_in_files:.xml.in=.xml)
+ at INTLTOOL_XML_RULE@
desktopdir = $(datadir)/xfce4/panel-plugins
desktop_in_in_files = xfce4-clipman-plugin.desktop.in.in
Modified: xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/actions.c
===================================================================
--- xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/actions.c 2009-02-10 17:03:48 UTC (rev 6673)
+++ xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/actions.c 2009-02-11 16:34:01 UTC (rev 6674)
@@ -4,6 +4,9 @@
* XML parsing based on Xfce4 Panel:
* Copyright (c) 2005 Jasper Huijsmans <jasper at xfce.org>
*
+ * Internationalization of the XML file based on Thunar User Custom Actions:
+ * Copyright (c) 2005-2006 Benedikt Meurer <benny at 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
@@ -23,6 +26,10 @@
#include <config.h>
#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
#include <exo/exo.h>
#include <gtk/gtk.h>
#include <libxfce4util/libxfce4util.h>
@@ -122,6 +129,11 @@
{
ClipmanActions *actions;
ParserState state;
+
+ gchar *locale;
+ gboolean name_use;
+ gint name_match;
+
gchar *action_name;
gchar *regex;
gchar *command_name;
@@ -143,6 +155,8 @@
GError **error)
{
EntryParser *parser = user_data;
+ gint n;
+ gint match;
switch (parser->state)
{
@@ -152,27 +166,53 @@
break;
case ACTIONS:
+ parser->name_use = FALSE;
+ parser->name_match = XFCE_LOCALE_NO_MATCH;
+
if (!g_ascii_strcasecmp (element_name, "action"))
parser->state = ACTION;
break;
- case ACTION:
- if (!g_ascii_strcasecmp (element_name, "name"))
- parser->state = ACTION_NAME;
- else if (!g_ascii_strcasecmp (element_name, "regex"))
- parser->state = REGEX;
- else if (!g_ascii_strcasecmp (element_name, "commands"))
- parser->state = COMMANDS;
- break;
+ case COMMANDS:
+ parser->name_use = FALSE;
+ parser->name_match = XFCE_LOCALE_NO_MATCH;
- case COMMANDS:
if (!g_ascii_strcasecmp (element_name, "command"))
parser->state = COMMAND;
break;
+ case ACTION:
case COMMAND:
if (!g_ascii_strcasecmp (element_name, "name"))
- parser->state = COMMAND_NAME;
+ {
+ for (n = 0; attribute_names[n] != NULL; n++)
+ {
+ if (!g_ascii_strcasecmp (attribute_names[n], "xml:lang"))
+ break;
+ }
+
+ if (attribute_names[n] == NULL)
+ {
+ parser->name_use = (parser->name_match <= XFCE_LOCALE_NO_MATCH);
+ }
+ else
+ {
+ match = xfce_locale_match (parser->locale, attribute_values[n]);
+ if (parser->name_match < match)
+ {
+ parser->name_match = match;
+ parser->name_use = TRUE;
+ }
+ else
+ parser->name_use = FALSE;
+ }
+
+ parser->state = (parser->state == ACTION) ? ACTION_NAME : COMMAND_NAME;
+ }
+ else if (!g_ascii_strcasecmp (element_name, "regex"))
+ parser->state = REGEX;
+ else if (!g_ascii_strcasecmp (element_name, "commands"))
+ parser->state = COMMANDS;
else if (!g_ascii_strcasecmp (element_name, "exec"))
parser->state = EXEC;
break;
@@ -216,6 +256,8 @@
g_free (parser->command_name);
g_free (parser->command);
+ parser->command_name = NULL;
+ parser->command = NULL;
parser->state = COMMANDS;
break;
@@ -242,7 +284,11 @@
switch (parser->state)
{
case ACTION_NAME:
- parser->action_name = g_strdup (text);
+ if (parser->name_use)
+ {
+ g_free (parser->action_name);
+ parser->action_name = g_strdup (text);
+ }
break;
case REGEX:
@@ -250,7 +296,11 @@
break;
case COMMAND_NAME:
- parser->command_name = g_strdup (text);
+ if (parser->name_use)
+ {
+ g_free (parser->command_name);
+ parser->command_name = g_strdup (text);
+ }
break;
case EXEC:
@@ -666,6 +716,7 @@
{
parser = g_slice_new0 (EntryParser);
parser->actions = actions;
+ parser->locale = setlocale (LC_MESSAGES, NULL);
context = g_markup_parse_context_new (&markup_parser, 0, parser, NULL);
g_markup_parse_context_parse (context, data, (gssize)size, NULL);
if (!g_markup_parse_context_end_parse (context, NULL))
Added: xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/xfce4-clipman-actions.xml.in
===================================================================
--- xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/xfce4-clipman-actions.xml.in (rev 0)
+++ xfce4-clipman-plugin/branches/xfce-4-6/panel-plugin/xfce4-clipman-actions.xml.in 2009-02-11 16:34:01 UTC (rev 6674)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE actions [
+ <!ELEMENT actions (action+)>
+ <!ELEMENT action (name,regex,commands)>
+ <!ELEMENT commands (command+)>
+ <!ELEMENT command (name,exec)>
+
+ <!ELEMENT name (#PCDATA)>
+ <!ATTLIST name xml:lang CDATA #IMPLIED>
+ <!ELEMENT regex (#PCDATA)>
+ <!ELEMENT exec (#PCDATA)>
+]>
+<!--
+ Copyright (c) 2009 Mike Massonnet <mmassonnet at xfce.org>
+
+ Default Clipman actions configuration file, which gets installed system-wide.
+ This should act more like an example, and is therefore kept simple.
+-->
+<actions>
+ <action>
+ <_name>Image</_name>
+ <regex>(/|http|ftp).+\.(jpg|png|gif)</regex>
+ <commands>
+ <command>
+ <_name>View with Ristretto</_name>
+ <exec>ristretto "\0"</exec>
+ </command>
+ <command>
+ <_name>Edit with Gimp</_name>
+ <exec>gimp "\0"</exec>
+ </command>
+ </commands>
+ </action>
+ <action>
+ <_name>Bugz</_name>
+ <regex>.*bug #?([0-9]+).*</regex>
+ <commands>
+ <command>
+ <_name>Xfce Bug</_name>
+ <exec>exo-open http://bugzilla.xfce.org/show_bug.cgi?id=\1</exec>
+ </command>
+ <command>
+ <_name>GNOME Bug</_name>
+ <exec>exo-open http://bugzilla.gnome.org/show_bug.cgi?id=\1</exec>
+ </command>
+ </commands>
+ </action>
+</actions>
Modified: xfce4-clipman-plugin/branches/xfce-4-6/po/POTFILES.in
===================================================================
--- xfce4-clipman-plugin/branches/xfce-4-6/po/POTFILES.in 2009-02-10 17:03:48 UTC (rev 6673)
+++ xfce4-clipman-plugin/branches/xfce-4-6/po/POTFILES.in 2009-02-11 16:34:01 UTC (rev 6674)
@@ -1,3 +1,4 @@
+panel-plugin/xfce4-clipman-actions.xml.in
panel-plugin/xfce4-clipman-plugin.desktop.in.in
panel-plugin/panel-plugin.c
panel-plugin/collector.c
More information about the Goodies-commits
mailing list