tracker r2933 - in trunk: . src/libtracker-common src/tracker-utils



Author: mr
Date: Tue Feb 17 09:29:46 2009
New Revision: 2933
URL: http://svn.gnome.org/viewvc/tracker?rev=2933&view=rev

Log:
	* src/libtracker-common/tracker-albumart.c:
	(tracker_albumart_queue_cb): Fixed warning from missing include.

	* src/tracker-utils/Makefile.am:
	* src/tracker-utils/tracker-files.c: 
	* src/tracker-utils/tracker-info.c: 
	* src/tracker-utils/tracker-meta-folder.c:
	* src/tracker-utils/tracker-query.c: 
	* src/tracker-utils/tracker-search.c:
	* src/tracker-utils/tracker-tag.c: 
	* src/tracker-utils/tracker-unique.c: Include libtracker-common
	and use new function for translations with plural entities using
	imported function g_dngettext() from Glib 2.18.


Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/tracker-albumart.c
   trunk/src/libtracker-common/tracker-utils.c
   trunk/src/libtracker-common/tracker-utils.h
   trunk/src/tracker-utils/Makefile.am
   trunk/src/tracker-utils/tracker-files.c
   trunk/src/tracker-utils/tracker-info.c
   trunk/src/tracker-utils/tracker-meta-folder.c
   trunk/src/tracker-utils/tracker-query.c
   trunk/src/tracker-utils/tracker-search.c
   trunk/src/tracker-utils/tracker-tag.c
   trunk/src/tracker-utils/tracker-unique.c

Modified: trunk/src/libtracker-common/tracker-albumart.c
==============================================================================
--- trunk/src/libtracker-common/tracker-albumart.c	(original)
+++ trunk/src/libtracker-common/tracker-albumart.c	Tue Feb 17 09:29:46 2009
@@ -44,6 +44,7 @@
 
 
 #include "tracker-albumart.h"
+#include "tracker-thumbnailer.h"
 
 #define ALBUMARTER_SERVICE      "com.nokia.albumart"
 #define ALBUMARTER_PATH         "/com/nokia/albumart/Requester"
@@ -530,21 +531,29 @@
 static void
 tracker_albumart_queue_cb (DBusGProxy     *proxy,
 			   DBusGProxyCall *call,
-			   gpointer	    user_data)
+			   gpointer	   user_data)
 {
 	GError      *error = NULL;
 	guint        handle;
-	GetFileInfo *info = user_data;
+	GetFileInfo *info;
+
+	info = user_data;
 
 	dbus_g_proxy_end_call (proxy, call, &error,
 			       G_TYPE_UINT, &handle,
 			       G_TYPE_INVALID);
 
-	if (g_file_test (info->art_path, G_FILE_TEST_EXISTS)) {
+	if (error) {
+		g_warning ("%s", error->message);
+		g_clear_error (&error);
+	}
 
-		gchar * asuri = g_filename_to_uri (info->art_path, NULL, NULL);
-		tracker_thumbnailer_get_file_thumbnail (asuri, "image/jpeg");
-		g_free (asuri);
+	if (g_file_test (info->art_path, G_FILE_TEST_EXISTS)) {
+		gchar *uri;
+		
+		uri = g_filename_to_uri (info->art_path, NULL, NULL);
+		tracker_thumbnailer_get_file_thumbnail (uri, "image/jpeg");
+		g_free (uri);
 
 		tracker_albumart_copy_to_local (info->art_path, info->local_uri);
 	}
@@ -553,11 +562,6 @@
 	g_free (info->local_uri);
 
 	g_slice_free (GetFileInfo, info);
-
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-	}
 }
 
 void

Modified: trunk/src/libtracker-common/tracker-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-utils.c	(original)
+++ trunk/src/libtracker-common/tracker-utils.c	Tue Feb 17 09:29:46 2009
@@ -20,6 +20,7 @@
  */
 
 #include <string.h>
+#include <locale.h>
 
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -242,3 +243,65 @@
 		g_usleep (throttle);
 	}
 }
+
+/* Temporary: Just here until we upgrade to GLib 2.18. */
+static gboolean
+tracker_dgettext_should_translate (void)
+{
+  static gsize translate = 0;
+  enum {
+    SHOULD_TRANSLATE = 1,
+    SHOULD_NOT_TRANSLATE = 2
+  };
+
+  if (G_UNLIKELY (g_once_init_enter (&translate)))
+    {
+      gboolean should_translate = TRUE;
+
+      const char *default_domain     = textdomain (NULL);
+      const char *translator_comment = gettext ("");
+#ifndef G_OS_WIN32
+      const char *translate_locale   = setlocale (LC_MESSAGES, NULL);
+#else
+      const char *translate_locale   = g_win32_getlocale ();
+#endif
+      /* We should NOT translate only if all the following hold:
+       *   - user has called textdomain() and set textdomain to non-default
+       *   - default domain has no translations
+       *   - locale does not start with "en_" and is not "C"
+       *
+       * Rationale:
+       *   - If text domain is still the default domain, maybe user calls
+       *     it later. Continue with old behavior of translating.
+       *   - If locale starts with "en_", we can continue using the
+       *     translations even if the app doesn't have translations for
+       *     this locale.  That is, en_UK and en_CA for example.
+       *   - If locale is "C", maybe user calls setlocale(LC_ALL,"") later.
+       *     Continue with old behavior of translating.
+       */
+      if (0 != strcmp (default_domain, "messages") &&
+          '\0' == *translator_comment &&
+          0 != strncmp (translate_locale, "en_", 3) &&
+          0 != strcmp (translate_locale, "C"))
+        should_translate = FALSE;
+
+      g_once_init_leave (&translate,
+                         should_translate ?
+                         SHOULD_TRANSLATE :
+                         SHOULD_NOT_TRANSLATE);
+    }
+
+  return translate == SHOULD_TRANSLATE;
+}
+
+G_CONST_RETURN gchar *
+tracker_dngettext (const gchar *domain,
+		   const gchar *msgid,
+		   const gchar *msgid_plural,
+		   gulong       n)
+{
+  if (domain && G_UNLIKELY (!tracker_dgettext_should_translate ()))
+    return n == 1 ? msgid : msgid_plural;
+
+  return dngettext (domain, msgid, msgid_plural, n);
+}

Modified: trunk/src/libtracker-common/tracker-utils.h
==============================================================================
--- trunk/src/libtracker-common/tracker-utils.h	(original)
+++ trunk/src/libtracker-common/tracker-utils.h	Tue Feb 17 09:29:46 2009
@@ -45,4 +45,10 @@
 void	 tracker_throttle		    (TrackerConfig *config,
 					     gint	    multiplier);
 
+/* Temporary: Just here until we upgrade to GLib 2.18. */
+G_CONST_RETURN gchar *tracker_dngettext     (const gchar *domain,
+					     const gchar *msgid,
+					     const gchar *msgid_plural,
+					     gulong       n);
+
 #endif /* __LIBTRACKER_COMMON_UTILS_H__ */

Modified: trunk/src/tracker-utils/Makefile.am
==============================================================================
--- trunk/src/tracker-utils/Makefile.am	(original)
+++ trunk/src/tracker-utils/Makefile.am	Tue Feb 17 09:29:46 2009
@@ -1,28 +1,30 @@
 include $(top_srcdir)/Makefile.decl
 
-INCLUDES =							\
-	-DLOCALEDIR=\""$(localedir)"\" 				\
-	-DG_LOG_DOMAIN=\"Tracker\"				\
-	-I$(top_srcdir)/src					\
-	$(DBUS_CFLAGS)						\
-	$(GIO_CFLAGS)						\
+INCLUDES =								\
+	-DLOCALEDIR=\""$(localedir)"\" 					\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
+	-DTRACKER_COMPILATION						\
+	-I$(top_srcdir)/src						\
+	$(DBUS_CFLAGS)							\
+	$(GIO_CFLAGS)							\
 	$(GLIB2_CFLAGS)
 
-libs = 								\
-	$(top_builddir)/src/libtracker/libtrackerclient.la	\
-	$(GIO_LIBS)						\
+libs = 									\
+	$(top_builddir)/src/libtracker/libtrackerclient.la		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
+	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)
 
-bin_PROGRAMS = 							\
-	tracker-search 						\
-	tracker-query 						\
-	tracker-meta-folder					\
-	tracker-stats						\
-	tracker-tag						\
-	tracker-files						\
-	tracker-status						\
-	tracker-unique						\
-	tracker-info						\
+bin_PROGRAMS = 								\
+	tracker-search 							\
+	tracker-query 							\
+	tracker-meta-folder						\
+	tracker-stats							\
+	tracker-tag							\
+	tracker-files							\
+	tracker-status							\
+	tracker-unique							\
+	tracker-info							\
 	tracker-services
 
 tracker_search_SOURCES = tracker-search.c

Modified: trunk/src/tracker-utils/tracker-files.c
==============================================================================
--- trunk/src/tracker-utils/tracker-files.c	(original)
+++ trunk/src/tracker-utils/tracker-files.c	Tue Feb 17 09:29:46 2009
@@ -30,6 +30,7 @@
 #include <glib/gi18n.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 static gchar	   *service;
 static gchar	  **mimes;
@@ -136,10 +137,10 @@
 
 		length = g_strv_length (array);
 
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 		
@@ -194,10 +195,10 @@
 
 		length = g_strv_length (array);
 
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 		

Modified: trunk/src/tracker-utils/tracker-info.c
==============================================================================
--- trunk/src/tracker-utils/tracker-info.c	(original)
+++ trunk/src/tracker-utils/tracker-info.c	Tue Feb 17 09:29:46 2009
@@ -31,6 +31,7 @@
 #include <gio/gio.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 static gchar	     *service;
 static gchar        **uri = NULL;
@@ -150,10 +151,10 @@
 
 		length = results->len;
 
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 		

Modified: trunk/src/tracker-utils/tracker-meta-folder.c
==============================================================================
--- trunk/src/tracker-utils/tracker-meta-folder.c	(original)
+++ trunk/src/tracker-utils/tracker-meta-folder.c	Tue Feb 17 09:29:46 2009
@@ -30,6 +30,7 @@
 #include <gio/gio.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 #define MAX_FILENAME_WIDTH 35
 
@@ -263,10 +264,10 @@
 
 		length = array->len;
 
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 		

Modified: trunk/src/tracker-utils/tracker-query.c
==============================================================================
--- trunk/src/tracker-utils/tracker-query.c	(original)
+++ trunk/src/tracker-utils/tracker-query.c	Tue Feb 17 09:29:46 2009
@@ -31,6 +31,7 @@
 #include <gio/gio.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 #ifdef G_OS_WIN32
 #include <trackerd/mingw-compat.h>
@@ -244,10 +245,10 @@
 
 		length = array->len;
 
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 

Modified: trunk/src/tracker-utils/tracker-search.c
==============================================================================
--- trunk/src/tracker-utils/tracker-search.c	(original)
+++ trunk/src/tracker-utils/tracker-search.c	Tue Feb 17 09:29:46 2009
@@ -30,6 +30,7 @@
 #include <glib/gi18n.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 static gint	      limit = 512;
 static gint	      offset;
@@ -220,10 +221,10 @@
 
 			length = g_strv_length (strv);
 
-			g_print (g_dngettext (NULL,
-					      _("Result: %d"), 
-					      _("Results: %d"),
-					      length),
+			g_print (tracker_dngettext (NULL,
+						    _("Result: %d"), 
+						    _("Results: %d"),
+						    length),
 				 length);
 			g_print ("\n");
 
@@ -259,10 +260,10 @@
 
 			length = g_strv_length (strv);
 			
-			g_print (g_dngettext (NULL,
-					      _("Result: %d"), 
-					      _("Results: %d"),
-					      length),
+			g_print (tracker_dngettext (NULL,
+						    _("Result: %d"), 
+						    _("Results: %d"),
+						    length),
 				 length);
 			g_print ("\n");
 

Modified: trunk/src/tracker-utils/tracker-tag.c
==============================================================================
--- trunk/src/tracker-utils/tracker-tag.c	(original)
+++ trunk/src/tracker-utils/tracker-tag.c	Tue Feb 17 09:29:46 2009
@@ -30,6 +30,7 @@
 #include <gio/gio.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 #ifdef G_OS_WIN32
 #include <trackerd/mingw-compat.h>
@@ -377,10 +378,10 @@
 
 			length = g_strv_length (results);
 			
-			g_print (g_dngettext (NULL,
-					      _("Result: %d"), 
-					      _("Results: %d"),
-					      length),
+			g_print (tracker_dngettext (NULL,
+						    _("Result: %d"), 
+						    _("Results: %d"),
+						    length),
 				 length);
 			g_print ("\n");
 			

Modified: trunk/src/tracker-utils/tracker-unique.c
==============================================================================
--- trunk/src/tracker-utils/tracker-unique.c	(original)
+++ trunk/src/tracker-utils/tracker-unique.c	Tue Feb 17 09:29:46 2009
@@ -29,6 +29,7 @@
 #include <glib/gi18n.h>
 
 #include <libtracker/tracker.h>
+#include <libtracker-common/tracker-common.h>
 
 #ifdef G_OS_WIN32
 #include <trackerd/mingw-compat.h>
@@ -220,10 +221,10 @@
 
 		length = array->len;
 		
-		g_print (g_dngettext (NULL,
-				      _("Result: %d"), 
-				      _("Results: %d"),
-				      length),
+		g_print (tracker_dngettext (NULL,
+					    _("Result: %d"), 
+					    _("Results: %d"),
+					    length),
 			 length);
 		g_print ("\n");
 



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