aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-12 09:35:55 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-12 09:35:55 +0200
commit45a8958dcf27d499773a33da4fcf15edbe643897 (patch)
tree7acfe3d527982acd02cded7f1afcfc9fe896f6c5
parente623d4cf67246b1fa7dc8a82af2c03e1ca7c4f02 (diff)
downloadgnunet-gtk-45a8958dcf27d499773a33da4fcf15edbe643897.tar.gz
gnunet-gtk-45a8958dcf27d499773a33da4fcf15edbe643897.zip
-make gnunet-gtk respect NLS settings from GNUNET_OS-project data
-rw-r--r--gnunet-setup.desktop.in2
-rw-r--r--src/include/gnunet_gtk.h12
-rw-r--r--src/lib/about.c9
-rw-r--r--src/lib/nls.c48
-rw-r--r--src/lib/os_installation.c26
-rw-r--r--src/lib/trayicon.c20
6 files changed, 67 insertions, 50 deletions
diff --git a/gnunet-setup.desktop.in b/gnunet-setup.desktop.in
index 7c90d3c8..bb987a70 100644
--- a/gnunet-setup.desktop.in
+++ b/gnunet-setup.desktop.in
@@ -5,7 +5,7 @@ GenericName=GNUnet Setup
5Comment=Configure GNUnet 5Comment=Configure GNUnet
6 6
7Type=Application 7Type=Application
8Exec=gnunet-setup-pkexec 8Exec=gnunet-setup
9Icon=gnunet-setup 9Icon=gnunet-setup
10Terminal=false 10Terminal=false
11Categories=GTK;Network;P2P;FileTransfer; 11Categories=GTK;Network;P2P;FileTransfer;
diff --git a/src/include/gnunet_gtk.h b/src/include/gnunet_gtk.h
index 5ec8901e..b7370390 100644
--- a/src/include/gnunet_gtk.h
+++ b/src/include/gnunet_gtk.h
@@ -62,7 +62,8 @@ struct GNUNET_GTK_MainLoop;
62 * @return new main window to initialize 62 * @return new main window to initialize
63 */ 63 */
64GtkWidget * 64GtkWidget *
65GNUNET_GTK_plug_me (const char *env_name, GtkWidget *main_window); 65GNUNET_GTK_plug_me (const char *env_name,
66 GtkWidget *main_window);
66 67
67 68
68/** 69/**
@@ -91,7 +92,8 @@ GNUNET_GTK_get_data_dir (void);
91 92
92/** 93/**
93 * @brief get the path to a specific GNUnet installation directory or, 94 * @brief get the path to a specific GNUnet installation directory or,
94 * with #GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory 95 * with #GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation
96 * directory
95 * @author Milan 97 * @author Milan
96 * 98 *
97 * @param dirkind which directory should be returned 99 * @param dirkind which directory should be returned
@@ -202,8 +204,10 @@ GNUNET_FS_GTK_remove_treestore_subtree (GtkTreeStore *ts, GtkTreeIter *root);
202 * @param argv command line options 204 * @param argv command line options
203 * @param options allowed command line options 205 * @param options allowed command line options
204 * @param main_window_file glade file for the main window 206 * @param main_window_file glade file for the main window
205 * @param main_task first task to run, closure will be set to the `struct GNUNET_GTK_MainLoop` 207 * @param main_task first task to run, closure will be set to the `struct
206 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (i.e. bad command-line options, etc) 208 * GNUNET_GTK_MainLoop`
209 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (i.e. bad command-line
210 * options, etc)
207 */ 211 */
208int 212int
209GNUNET_GTK_main_loop_start (const char *binary_name, 213GNUNET_GTK_main_loop_start (const char *binary_name,
diff --git a/src/lib/about.c b/src/lib/about.c
index 8181bc4b..b8def8d0 100644
--- a/src/lib/about.c
+++ b/src/lib/about.c
@@ -212,12 +212,15 @@ GNUNET_GTK_display_about (const char *dialogfile)
212 return; 212 return;
213 } 213 }
214 ctx->about_credits_notebook = GTK_WIDGET ( 214 ctx->about_credits_notebook = GTK_WIDGET (
215 gtk_builder_get_object (ctx->builder, "about_credits_notebook")); 215 gtk_builder_get_object (ctx->builder,
216 "about_credits_notebook"));
216 ctx->about_license_scroller = GTK_WIDGET ( 217 ctx->about_license_scroller = GTK_WIDGET (
217 gtk_builder_get_object (ctx->builder, "about_license_scroller")); 218 gtk_builder_get_object (ctx->builder, "about_license_scroller"));
218 ctx->ad = GTK_WIDGET (gtk_builder_get_object (ctx->builder, "about_window")); 219 ctx->ad = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
220 "about_window"));
219 ctx->license_contents = 221 ctx->license_contents =
220 GTK_TEXT_BUFFER (gtk_builder_get_object (ctx->builder, "license_contents")); 222 GTK_TEXT_BUFFER (gtk_builder_get_object (ctx->builder,
223 "license_contents"));
221 gtk_widget_show (ctx->ad); 224 gtk_widget_show (ctx->ad);
222} 225}
223 226
diff --git a/src/lib/nls.c b/src/lib/nls.c
index cc6f0e5f..ca57ce32 100644
--- a/src/lib/nls.c
+++ b/src/lib/nls.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010, 2011 GNUnet e.V. 3 Copyright (C) 2010, 2011, 2021 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. 18 Boston, MA 02110-1301, USA.
19*/ 19*/
20
21/** 20/**
22 * @file src/lib/nls.c 21 * @file src/lib/nls.c
23 * @brief natural language support 22 * @brief natural language support
@@ -30,24 +29,32 @@
30#endif 29#endif
31 30
32 31
33/**
34 * Initialize GNU gettext for message translation.
35 */
36void 32void
37GNUNET_GTK_setup_nls () 33GNUNET_GTK_setup_nls ()
38{ 34{
39#if ENABLE_NLS 35#if ENABLE_NLS
36 struct GNUNET_OS_ProjectData *mypd;
37 struct GNUNET_OS_ProjectData *pd;
40 char *path; 38 char *path;
41 39
40 pd = GNUNET_OS_project_data_get ();
42 setlocale (LC_ALL, ""); 41 setlocale (LC_ALL, "");
43 GNUNET_asprintf (&path, 42 GNUNET_asprintf (&path,
44 "%s/%s/locale/", 43 "%s/%s/locale/",
45 GNUNET_GTK_get_data_dir (), 44 GNUNET_GTK_get_data_dir (),
46 PACKAGE_NAME); 45 PACKAGE_NAME);
47 bindtextdomain ("gnunet-gtk", path); 46 bindtextdomain ("gnunet-gtk",
48 textdomain ("gnunet-gtk"); 47 path);
49 bind_textdomain_codeset ("GNUnet", "UTF-8"); 48 if (NULL != pd->gettext_path)
50 bind_textdomain_codeset ("gnunet-gtk", "UTF-8"); 49 bindtextdomain (pd->gettext_domain,
50 pd->gettext_path);
51 textdomain (pd->gettext_domain);
52 bind_textdomain_codeset ("GNUnet",
53 "UTF-8");
54 bind_textdomain_codeset ("gnunet-gtk",
55 "UTF-8");
56 bind_textdomain_codeset (pd->gettext_domain,
57 "UTF-8");
51 GNUNET_free (path); 58 GNUNET_free (path);
52#else 59#else
53 fprintf ( 60 fprintf (
@@ -71,20 +78,12 @@ get_filename_charset (const gchar **filename_charset)
71 gboolean is_utf8; 78 gboolean is_utf8;
72 79
73 is_utf8 = g_get_filename_charsets (&charsets); 80 is_utf8 = g_get_filename_charsets (&charsets);
74
75 if (filename_charset) 81 if (filename_charset)
76 *filename_charset = charsets[0]; 82 *filename_charset = charsets[0];
77
78 return is_utf8; 83 return is_utf8;
79} 84}
80 85
81 86
82/**
83 * Convert a string from the current locale to UTF-8.
84 *
85 * @param str_loc string in current locale
86 * @return string in UTF-8, NULL if str_loc was NULL
87 */
88char * 87char *
89GNUNET_GTK_from_loc_to_utf8 (const char *str_loc) 88GNUNET_GTK_from_loc_to_utf8 (const char *str_loc)
90{ 89{
@@ -99,7 +98,9 @@ GNUNET_GTK_from_loc_to_utf8 (const char *str_loc)
99 if (is_UTF8) 98 if (is_UTF8)
100 str_utf8 = GNUNET_strdup (str_loc); 99 str_utf8 = GNUNET_strdup (str_loc);
101 else 100 else
102 str_utf8 = GNUNET_STRINGS_to_utf8 (str_loc, strlen (str_loc), loc_charset); 101 str_utf8 = GNUNET_STRINGS_to_utf8 (str_loc,
102 strlen (str_loc),
103 loc_charset);
103 return str_utf8; 104 return str_utf8;
104} 105}
105 106
@@ -125,18 +126,14 @@ from_filename_to_utf8 (gchar *filename)
125 str_utf8 = GNUNET_strdup (filename); 126 str_utf8 = GNUNET_strdup (filename);
126 else 127 else
127 str_utf8 = 128 str_utf8 =
128 GNUNET_STRINGS_to_utf8 (filename, strlen (filename), filename_charset); 129 GNUNET_STRINGS_to_utf8 (filename,
130 strlen (filename),
131 filename_charset);
129 132
130 return str_utf8; 133 return str_utf8;
131} 134}
132 135
133 136
134/**
135 * Returns filename form filechooser, encoded in UTF-8.
136 *
137 * @param fc file chooser to inspect
138 * @return selected filename as UTF-8, NULL on errors
139 */
140char * 137char *
141GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc) 138GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc)
142{ 139{
@@ -150,4 +147,5 @@ GNUNET_GTK_filechooser_get_filename_utf8 (GtkFileChooser *fc)
150 return filename_utf8; 147 return filename_utf8;
151} 148}
152 149
150
153/* end of nls.c */ 151/* end of nls.c */
diff --git a/src/lib/os_installation.c b/src/lib/os_installation.c
index 762ce3e6..7fc8d627 100644
--- a/src/lib/os_installation.c
+++ b/src/lib/os_installation.c
@@ -30,16 +30,19 @@
30 * for gnunet-gtk. 30 * for gnunet-gtk.
31 */ 31 */
32static const struct GNUNET_OS_ProjectData gtk_pd = 32static const struct GNUNET_OS_ProjectData gtk_pd =
33 {.libname = "libgnunetgtk", 33{.libname = "libgnunetgtk",
34 .project_dirname = "gnunet", 34 .project_dirname = "gnunet",
35 .binary_name = "gnunet-fs-gtk", 35 .binary_name = "gnunet-fs-gtk",
36 .env_varname = "GNUNET_GTK_PREFIX", 36 .env_varname = "GNUNET_GTK_PREFIX",
37 .env_varname_alt = "GNUNET_PREFIX", 37 .env_varname_alt = "GNUNET_PREFIX",
38 .base_config_varname = "GNUNET_BASE_CONFIG", 38 .base_config_varname = "GNUNET_BASE_CONFIG",
39 .bug_email = "gnunet-developers@gnu.org", 39 .bug_email = "gnunet-developers@gnu.org",
40 .homepage = "http://www.gnu.org/s/gnunet/", 40 .homepage = "http://www.gnu.org/s/gnunet/",
41 .config_file = "gnunet.conf", 41 .config_file = "gnunet.conf",
42 .user_config_file = "~/.config/gnunet.conf"}; 42 .user_config_file = "~/.config/gnunet.conf",
43 .gettext_domain = "gnunet-gtk",
44 .version = PACKAGE_VERSION,
45 .is_gnu = 1};
43 46
44 47
45/** 48/**
@@ -55,7 +58,8 @@ GNUNET_GTK_project_data_default (void)
55/** 58/**
56 * Initialize libgnunetgtk. 59 * Initialize libgnunetgtk.
57 */ 60 */
58void __attribute__ ((constructor)) GNUNET_GTK_init () 61void __attribute__ ((constructor))
62GNUNET_GTK_init (void)
59{ 63{
60 GNUNET_OS_init (&gtk_pd); 64 GNUNET_OS_init (&gtk_pd);
61} 65}
diff --git a/src/lib/trayicon.c b/src/lib/trayicon.c
index 1b8edd85..788f4f86 100644
--- a/src/lib/trayicon.c
+++ b/src/lib/trayicon.c
@@ -88,7 +88,9 @@ GNUNET_GTK_tray_icon_quit (GtkMenuItem *menuitem, gpointer user_data)
88 * @param user_data unused 88 * @param user_data unused
89 */ 89 */
90static int 90static int
91tray_icon_on_menu (GtkWidget *widget, GdkEvent *event, gpointer user_data) 91tray_icon_on_menu (GtkWidget *widget,
92 GdkEvent *event,
93 gpointer user_data)
92{ 94{
93 struct GNUNET_GTK_MainLoop *ml = user_data; 95 struct GNUNET_GTK_MainLoop *ml = user_data;
94 GtkMenu *tray_menu; 96 GtkMenu *tray_menu;
@@ -103,7 +105,8 @@ tray_icon_on_menu (GtkWidget *widget, GdkEvent *event, gpointer user_data)
103 builder = 105 builder =
104 GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade", ml); 106 GNUNET_GTK_get_new_builder ("gnunet_gtk_status_bar_menu.glade", ml);
105 tray_menu = GTK_MENU ( 107 tray_menu = GTK_MENU (
106 gtk_builder_get_object (builder, "GNUNET_GTK_status_bar_popup_menu")); 108 gtk_builder_get_object (builder,
109 "GNUNET_GTK_status_bar_popup_menu"));
107 g_object_ref (tray_menu); 110 g_object_ref (tray_menu);
108 gtk_menu_popup (tray_menu, 111 gtk_menu_popup (tray_menu,
109 NULL, 112 NULL,
@@ -161,13 +164,17 @@ GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml,
161 * @param tooltip tooltip for the tray icon 164 * @param tooltip tooltip for the tray icon
162 */ 165 */
163void 166void
164GNUNET_GTK_tray_icon_change (const char *icon_name, const char *tooltip) 167GNUNET_GTK_tray_icon_change (const char *icon_name,
168 const char *tooltip)
165{ 169{
166 if (NULL == tray_icon) 170 if (NULL == tray_icon)
167 return; 171 return;
168 gtk_status_icon_set_from_icon_name (tray_icon, icon_name); 172 gtk_status_icon_set_from_icon_name (tray_icon,
169 gtk_status_icon_set_tooltip_text (tray_icon, tooltip); 173 icon_name);
170 gtk_status_icon_set_visible (tray_icon, TRUE); 174 gtk_status_icon_set_tooltip_text (tray_icon,
175 tooltip);
176 gtk_status_icon_set_visible (tray_icon,
177 TRUE);
171} 178}
172 179
173 180
@@ -184,4 +191,5 @@ GNUNET_GTK_tray_icon_destroy ()
184 main_window = NULL; 191 main_window = NULL;
185} 192}
186 193
194
187/* end of trayicon.c */ 195/* end of trayicon.c */