Commit f7ff40d9e6e9d558344a7e2d1225e60e277bf750
1 parent
247a690e
Exists in
master
and in
4 other branches
Adding toolbar models.
Activating locale support.
Showing
3 changed files
with
66 additions
and
41 deletions
Show diff stats
src/main/main.c
... | ... | @@ -37,6 +37,7 @@ |
37 | 37 | #include <pw3270/application.h> |
38 | 38 | #include <lib3270.h> |
39 | 39 | #include <lib3270/log.h> |
40 | + #include <locale.h> | |
40 | 41 | |
41 | 42 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
42 | 43 | |
... | ... | @@ -45,6 +46,24 @@ int main (int argc, char **argv) { |
45 | 46 | GtkApplication *app; |
46 | 47 | int status; |
47 | 48 | |
49 | + // Setup locale | |
50 | +#ifdef LC_ALL | |
51 | + setlocale( LC_ALL, "" ); | |
52 | +#endif | |
53 | + | |
54 | +#ifdef _WIN32 | |
55 | + { | |
56 | + g_autofree gchar * appdir = g_win32_get_package_installation_directory_of_module(NULL); | |
57 | + g_autofree gchar * locdir = g_build_filename(appdir,"locale",NULL); | |
58 | + bindtextdomain( PACKAGE_NAME, locdir ); | |
59 | + } | |
60 | +#endif // _WIN32 | |
61 | + | |
62 | + bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); | |
63 | + textdomain(PACKAGE_NAME); | |
64 | + | |
65 | + // Setup and start application. | |
66 | + | |
48 | 67 | g_set_application_name(G_STRINGIFY(PRODUCT_NAME)); |
49 | 68 | app = pw3270_application_new("br.com.bb." G_STRINGIFY(PRODUCT_NAME),G_APPLICATION_HANDLES_OPEN); |
50 | 69 | ... | ... |
src/objects/toolbar/private.h
... | ... | @@ -44,7 +44,10 @@ |
44 | 44 | #include <pw3270/toolbar.h> |
45 | 45 | #include <lib3270/log.h> |
46 | 46 | |
47 | - G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new(GAction *action); | |
48 | - G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new_from_action_name(const gchar * action_name); | |
47 | + G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new(GAction *action); | |
48 | + G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new_from_action_name(const gchar * action_name); | |
49 | + | |
50 | + G_GNUC_INTERNAL GtkTreeModel * pw3270_toolbar_style_model_new(); | |
51 | + G_GNUC_INTERNAL GtkTreeModel * pw3270_toolbar_icon_size_model_new(); | |
49 | 52 | |
50 | 53 | #endif // PRIVATE_H_INCLUDED | ... | ... |
src/objects/toolbar/toolbar.c
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
39 | 39 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
40 | 40 | |
41 | - static const struct icon_size { | |
41 | + const struct icon_size { | |
42 | 42 | const gchar * label; |
43 | 43 | GtkIconSize icon_size; |
44 | 44 | } icon_sizes[] = { |
... | ... | @@ -60,7 +60,7 @@ |
60 | 60 | }, |
61 | 61 | }; |
62 | 62 | |
63 | - static const struct toolbar_style { | |
63 | + static const struct style { | |
64 | 64 | const gchar * label; |
65 | 65 | GtkToolbarStyle style; |
66 | 66 | } styles[] = { |
... | ... | @@ -184,7 +184,7 @@ |
184 | 184 | static void set_style(GtkCheckMenuItem *menuitem, GtkWidget *toolbar) { |
185 | 185 | |
186 | 186 | if(gtk_check_menu_item_get_active(menuitem)) { |
187 | - struct toolbar_style * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | |
187 | + struct style * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | |
188 | 188 | pw3270_toolbar_toolbar_set_style(GTK_TOOLBAR(toolbar), style->style); |
189 | 189 | } |
190 | 190 | |
... | ... | @@ -270,42 +270,6 @@ |
270 | 270 | return g_object_new(PW3270_TYPE_TOOLBAR, NULL); |
271 | 271 | } |
272 | 272 | |
273 | - /* | |
274 | - GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos) { | |
275 | - | |
276 | - g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); | |
277 | - | |
278 | - if(!action) { | |
279 | - g_message(_("Invalid action identifier")); | |
280 | - return NULL; | |
281 | - } | |
282 | - | |
283 | - if(!action->icon) { | |
284 | - g_message(_("Action \"%s\" doesn't have an icon"), action->name); | |
285 | - return NULL; | |
286 | - } | |
287 | - | |
288 | - if(!action->label) { | |
289 | - g_message(_("Action \"%s\" doesn't have a label"), action->name); | |
290 | - return NULL; | |
291 | - } | |
292 | - | |
293 | - debug("Action: %s icon: %s", action->name, action->icon); | |
294 | - | |
295 | - GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); | |
296 | - gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); | |
297 | - | |
298 | - gtk_widget_set_name(GTK_WIDGET(item), action->name); | |
299 | - | |
300 | - if(action->summary) | |
301 | - gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); | |
302 | - | |
303 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); | |
304 | - | |
305 | - return GTK_WIDGET(item); | |
306 | - } | |
307 | - */ | |
308 | - | |
309 | 273 | gboolean popup_context_menu(GtkToolbar *widget, gint G_GNUC_UNUSED(x), gint G_GNUC_UNUSED(y), gint button_number) { |
310 | 274 | |
311 | 275 | pw3270ToolBar * toolbar = PW3270_TOOLBAR(widget); |
... | ... | @@ -417,3 +381,42 @@ |
417 | 381 | |
418 | 382 | return g_string_free(str,FALSE); |
419 | 383 | } |
384 | + | |
385 | + GtkTreeModel * pw3270_toolbar_style_model_new() { | |
386 | + | |
387 | + size_t ix; | |
388 | + GtkTreeIter iter; | |
389 | + GtkListStore * model = gtk_list_store_new(2, G_TYPE_STRING,G_TYPE_UINT); | |
390 | + | |
391 | + for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { | |
392 | + gtk_list_store_append(model,&iter); | |
393 | + gtk_list_store_set( model, | |
394 | + &iter, | |
395 | + 0, gettext(styles[ix].label), | |
396 | + 1, (guint) styles[ix].style, | |
397 | + -1); | |
398 | + | |
399 | + } | |
400 | + | |
401 | + return GTK_TREE_MODEL(model); | |
402 | + | |
403 | + } | |
404 | + | |
405 | + GtkTreeModel * pw3270_toolbar_icon_size_model_new() { | |
406 | + | |
407 | + size_t ix; | |
408 | + GtkTreeIter iter; | |
409 | + GtkListStore * model = gtk_list_store_new(2, G_TYPE_STRING,G_TYPE_UINT); | |
410 | + | |
411 | + for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { | |
412 | + gtk_list_store_append(model,&iter); | |
413 | + gtk_list_store_set( model, | |
414 | + &iter, | |
415 | + 0, gettext(icon_sizes[ix].label), | |
416 | + 1, (guint) icon_sizes[ix].icon_size, | |
417 | + -1); | |
418 | + | |
419 | + } | |
420 | + | |
421 | + return GTK_TREE_MODEL(model); | |
422 | + } | ... | ... |