Commit 685f0a40 authored by Martyn James Russell's avatar Martyn James Russell

Fixed warning from missing include.

	* 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.

svn path=/trunk/; revision=2933
parent 34fc42b4
2009-02-17 Martyn Russell <martyn@imendio.com>
* src/libtracker-common/tracker-albumart.c:
(tracker_albumart_queue_cb): Fixed warning from missing include.
* src/libtracker-common/tracker-utils.[ch]: Added g_dngettext()
which is in GLib 2.18 but we don't depend on it. Now all the utils
use tracker_dngettext() instead.
* 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.
2009-02-16 Martyn Russell <martyn@imendio.com>
* src/trackerd/tracker-status.c: Make sure we *ALWAYS* log state
......
......@@ -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 @@ get_albumart_requester (void)
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 @@ tracker_albumart_queue_cb (DBusGProxy *proxy,
g_free (info->local_uri);
g_slice_free (GetFileInfo, info);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
}
}
void
......
......@@ -20,6 +20,7 @@
*/
#include <string.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
......@@ -242,3 +243,65 @@ tracker_throttle (TrackerConfig *config,
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);
}
......@@ -45,4 +45,10 @@ gchar * tracker_seconds_to_string (gdouble seconds_elapsed,
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__ */
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
......
......@@ -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 @@ main (int argc, char **argv)
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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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");
......
......@@ -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 @@ main (int argc, char **argv)
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment