Skip to content

Commit

Permalink
update translated pane titles
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Mar 21, 2009
1 parent 4f46f6c commit 9b9f197
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
38 changes: 36 additions & 2 deletions src/bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,24 @@
#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
Expand Down Expand Up @@ -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: */
2 changes: 2 additions & 0 deletions src/bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define BAR_H

typedef enum {
PANE_UNDEF = 0,
PANE_COMMENT,
PANE_EXIF,
PANE_HISTOGRAM,
Expand Down Expand Up @@ -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: */
4 changes: 3 additions & 1 deletion src/bar_comment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/bar_exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/bar_histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/bar_keywords.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9b9f197

Please sign in to comment.