update translated pane titles
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 21 Mar 2009 17:47:50 +0000 (17:47 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 21 Mar 2009 17:47:50 +0000 (17:47 +0000)
src/bar.c
src/bar.h
src/bar_comment.c
src/bar_exif.c
src/bar_histogram.c
src/bar_keywords.c

index a3c8286..4c3a01e 100644 (file)
--- a/src/bar.c
+++ b/src/bar.c
 #include "histogram.h"
 #include "rcfile.h"
 
-//#define BAR_SIZE_INCREMENT 48
-//#define BAR_ARROW_SIZE 7
+typedef struct _KnownPanes KnownPanes;
+struct _KnownPanes
+{
+       PaneType type;
+       gchar *id;
+       gchar *title;
+};
+
+static const KnownPanes known_panes[] = {
+/* default sidebar */
+       {PANE_HISTOGRAM,        "histogram",    N_("Histogram")},
+       {PANE_COMMENT,          "title",        N_("Title")},
+       {PANE_KEYWORDS,         "keywords",     N_("Keywords")},
+       {PANE_COMMENT,          "comment",      N_("Comment")},
+       {PANE_EXIF,             "exif",         N_("Exif")},
 
+       {PANE_UNDEF,            NULL,           NULL}
+};
 
 typedef struct _BarData BarData;
 struct _BarData
@@ -445,4 +460,23 @@ GtkWidget *bar_pane_expander_title(const gchar *title)
        return widget;
 }
 
+gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title)
+{
+       const KnownPanes *pane = known_panes;
+       
+       if (!title) return FALSE;
+       while (pane->id)
+               {
+               if (pane->type == type && strcmp(pane->id, id) == 0) break;
+               pane++;
+               }
+       if (!pane->id) return FALSE;
+       
+       if (*title && **title && strcmp(pane->title, *title) != 0) return FALSE;
+       
+       g_free(*title);
+       *title = g_strdup(_(pane->title));
+       return TRUE;
+}
+       
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 69a9fb7..6f8436b 100644 (file)
--- a/src/bar.h
+++ b/src/bar.h
@@ -15,6 +15,7 @@
 #define BAR_H
 
 typedef enum {
+       PANE_UNDEF = 0,
        PANE_COMMENT,
        PANE_EXIF,
        PANE_HISTOGRAM,
@@ -62,5 +63,6 @@ gint bar_get_width(GtkWidget *bar);
 
 GtkWidget *bar_pane_expander_title(const gchar *title);
 void bar_update_expander(GtkWidget *pane);
+gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title);
 #endif
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index c2228b0..b54b1c2 100644 (file)
@@ -263,7 +263,7 @@ GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar
 
 GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
 {
-       gchar *title = g_strdup(_("Comment"));
+       gchar *title = NULL;
        gchar *key = g_strdup(COMMENT_KEY);
        gboolean expanded = TRUE;
        gint height = 50;
@@ -285,6 +285,7 @@ GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const
                log_printf("unknown attribute %s = %s\n", option, value);
                }
        
+       bar_pane_translate_title(PANE_COMMENT, id, &title);
        ret = bar_pane_comment_new(id, title, key, expanded, height);
        g_free(title);
        g_free(key);
@@ -318,6 +319,7 @@ void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribut
 
        if (title)
                {
+               bar_pane_translate_title(PANE_COMMENT, pcd->pane.id, &title);
                gtk_label_set_text(GTK_LABEL(pcd->pane.title), title);
                g_free(title);
                }
index 67ad81e..db6b2c9 100644 (file)
@@ -775,7 +775,7 @@ GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expan
 
 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
 {
-       gchar *title = g_strdup(_("Exif"));
+       gchar *title = NULL;
        gchar *id = g_strdup("exif");
        gboolean expanded = TRUE;
        GtkWidget *ret;
@@ -792,6 +792,7 @@ GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gc
                log_printf("unknown attribute %s = %s\n", option, value);
                }
        
+       bar_pane_translate_title(PANE_EXIF, id, &title);
        ret = bar_pane_exif_new(id, title, expanded, FALSE);
        g_free(title);
        g_free(id);
@@ -822,6 +823,7 @@ void bar_pane_exif_update_from_config(GtkWidget *pane, const gchar **attribute_n
 
        if (title)
                {
+               bar_pane_translate_title(PANE_EXIF, ped->pane.id, &title);
                gtk_label_set_text(GTK_LABEL(ped->pane.title), title);
                g_free(title);
                }
index c1a35f2..c52dd2f 100644 (file)
@@ -379,7 +379,7 @@ GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gint heig
 
 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
 {
-       gchar *title = g_strdup(_("NoName"));
+       gchar *title = NULL;
        gchar *id = g_strdup("histogram");
        gboolean expanded = TRUE;
        gint height = 80;
@@ -401,6 +401,7 @@ GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, con
                log_printf("unknown attribute %s = %s\n", option, value);
                }
        
+       bar_pane_translate_title(PANE_HISTOGRAM, id, &title);
        ret = bar_pane_histogram_new(id, title, height, expanded, histogram_channel, histogram_mode);
        g_free(title);
        g_free(id);
index 8e8e99d..5bb0d4b 100644 (file)
@@ -1350,7 +1350,7 @@ GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gcha
 GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
 {
        gchar *id = g_strdup("keywords");
-       gchar *title = g_strdup(_("Keywords"));
+       gchar *title = NULL;
        gchar *key = g_strdup(COMMENT_KEY);
        gboolean expanded = TRUE;
        GtkWidget *ret;
@@ -1369,6 +1369,7 @@ GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, cons
                log_printf("unknown attribute %s = %s\n", option, value);
                }
        
+       bar_pane_translate_title(PANE_KEYWORDS, id, &title);
        ret = bar_pane_keywords_new(id, title, key, expanded);
        g_free(id);
        g_free(title);
@@ -1401,6 +1402,7 @@ void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribu
 
        if (title)
                {
+               bar_pane_translate_title(PANE_KEYWORDS, pkd->pane.id, &title);
                gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
                g_free(title);
                }