Commit ad40e52537a4aabc6cea8a3acc5df2524bbb3fe8
1 parent
61c32a7a
Exists in
master
and in
5 other branches
Implementando processo de construção da janela principal, ajuste do nome da aplicação no gtk, etc.
Showing
7 changed files
with
65 additions
and
49 deletions
Show diff stats
src/gtk/common/config.c
... | ... | @@ -43,12 +43,12 @@ |
43 | 43 | |
44 | 44 | #ifdef WIN_REGISTRY_ENABLED |
45 | 45 | |
46 | - static const gchar *registry_path = "SOFTWARE\\"PACKAGE_NAME; | |
46 | + static const gchar *registry_path = "SOFTWARE\\"; | |
47 | 47 | |
48 | 48 | #else |
49 | 49 | |
50 | 50 | static GKeyFile * program_config = NULL; |
51 | - static const gchar * mask = "%s" G_DIR_SEPARATOR_S PACKAGE_NAME ".conf"; | |
51 | + static const gchar * mask = "%s" G_DIR_SEPARATOR_S "%s.conf"; | |
52 | 52 | |
53 | 53 | #endif // WIN_REGISTRY_ENABLED |
54 | 54 | |
... | ... | @@ -87,7 +87,7 @@ gchar * get_last_error_msg(void) |
87 | 87 | { |
88 | 88 | static HKEY predefined[] = { HKEY_CURRENT_USER, HKEY_USERS, HKEY_LOCAL_MACHINE }; |
89 | 89 | int f; |
90 | - gchar * path = g_strdup_printf("%s\\%s",registry_path,group); | |
90 | + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); | |
91 | 91 | |
92 | 92 | for(f=0;f<G_N_ELEMENTS(predefined);f++) |
93 | 93 | { |
... | ... | @@ -119,7 +119,7 @@ gchar * get_last_error_msg(void) |
119 | 119 | const gchar * const *sysconfig; |
120 | 120 | |
121 | 121 | #ifdef DEBUG |
122 | - filename = g_strdup_printf(mask,"."); | |
122 | + filename = g_strdup_printf(mask,".",g_get_application_name()); | |
123 | 123 | trace("Checking for %s",filename); |
124 | 124 | if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) |
125 | 125 | return filename; |
... | ... | @@ -128,7 +128,7 @@ gchar * get_last_error_msg(void) |
128 | 128 | |
129 | 129 | for(f=0;f<G_N_ELEMENTS(dir);f++) |
130 | 130 | { |
131 | - filename = g_strdup_printf(mask,dir[f]()); | |
131 | + filename = g_strdup_printf(mask,dir[f](),g_get_application_name()); | |
132 | 132 | trace("Checking for %s",filename); |
133 | 133 | if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) |
134 | 134 | return filename; |
... | ... | @@ -138,7 +138,7 @@ gchar * get_last_error_msg(void) |
138 | 138 | sysconfig = g_get_system_config_dirs(); |
139 | 139 | for(f=0;sysconfig[f];f++) |
140 | 140 | { |
141 | - filename = g_strdup_printf(mask,sysconfig[f]); | |
141 | + filename = g_strdup_printf(mask,sysconfig[f],g_get_application_name()); | |
142 | 142 | trace("Checking for %s",filename); |
143 | 143 | if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) |
144 | 144 | return filename; |
... | ... | @@ -148,14 +148,14 @@ gchar * get_last_error_msg(void) |
148 | 148 | sysconfig = g_get_system_data_dirs(); |
149 | 149 | for(f=0;sysconfig[f];f++) |
150 | 150 | { |
151 | - filename = g_strdup_printf(mask,sysconfig[f]); | |
151 | + filename = g_strdup_printf(mask,sysconfig[f],g_get_application_name()); | |
152 | 152 | trace("Checking for %s",filename); |
153 | 153 | if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) |
154 | 154 | return filename; |
155 | 155 | g_free(filename); |
156 | 156 | } |
157 | 157 | |
158 | - return g_strdup_printf(mask,g_get_user_config_dir()); | |
158 | + return g_strdup_printf(mask,g_get_user_config_dir(),g_get_application_name()); | |
159 | 159 | } |
160 | 160 | #endif // #ifdef WIN_REGISTRY_ENABLED |
161 | 161 | |
... | ... | @@ -177,7 +177,7 @@ gchar * get_last_error_msg(void) |
177 | 177 | if(datatype == REG_DWORD) |
178 | 178 | ret = data ? TRUE : FALSE; |
179 | 179 | else |
180 | - g_warning("Unexpected registry data type in %s\\%s\\%s",registry_path,group,key); | |
180 | + g_warning("Unexpected registry data type in %s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); | |
181 | 181 | } |
182 | 182 | |
183 | 183 | RegCloseKey(key_handle); |
... | ... | @@ -220,7 +220,7 @@ gchar * get_last_error_msg(void) |
220 | 220 | if(datatype == REG_DWORD) |
221 | 221 | ret = (gint) data; |
222 | 222 | else |
223 | - g_warning("Unexpected registry data type in %s\\%s\\%s",registry_path,group,key); | |
223 | + g_warning("Unexpected registry data type in %s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); | |
224 | 224 | } |
225 | 225 | |
226 | 226 | RegCloseKey(key_handle); |
... | ... | @@ -321,7 +321,7 @@ static void set_string(const gchar *group, const gchar *key, const gchar *fmt, v |
321 | 321 | |
322 | 322 | #ifdef WIN_REGISTRY_ENABLED |
323 | 323 | |
324 | - gchar * path = g_strdup_printf("%s\\%s",registry_path,group); | |
324 | + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); | |
325 | 325 | HKEY hKey; |
326 | 326 | DWORD disp; |
327 | 327 | |
... | ... | @@ -356,7 +356,7 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) |
356 | 356 | |
357 | 357 | HKEY hKey; |
358 | 358 | DWORD disp; |
359 | - gchar * path = g_strdup_printf("%s\\%s",registry_path,group); | |
359 | + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); | |
360 | 360 | |
361 | 361 | trace("Creating key %s",path); |
362 | 362 | if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) |
... | ... | @@ -398,7 +398,7 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) |
398 | 398 | |
399 | 399 | HKEY hKey; |
400 | 400 | DWORD disp; |
401 | - gchar * path = g_strdup_printf("%s\\%s",registry_path,group); | |
401 | + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); | |
402 | 402 | |
403 | 403 | trace("Creating key %s",path); |
404 | 404 | if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) |
... | ... | @@ -449,7 +449,7 @@ void configuration_deinit(void) |
449 | 449 | |
450 | 450 | if(text) |
451 | 451 | { |
452 | - gchar *filename = g_strdup_printf(mask,g_get_user_config_dir()); | |
452 | + gchar *filename = g_strdup_printf(mask,g_get_user_config_dir(),g_get_application_name()); | |
453 | 453 | |
454 | 454 | trace("Saving configuration in \"%s\"",filename); |
455 | 455 | ... | ... |
src/gtk/globals.h
... | ... | @@ -50,20 +50,25 @@ |
50 | 50 | ACTION_COUNT |
51 | 51 | }; |
52 | 52 | |
53 | - // Configuration | |
53 | + | |
54 | +/*--[ Statics ]--------------------------------------------------------------------------------------*/ | |
55 | + | |
56 | + | |
57 | +/*--[ Global prototipes ]----------------------------------------------------------------------------*/ | |
58 | + | |
54 | 59 | #include "common/common.h" |
55 | 60 | |
56 | - GtkWidget * create_main_window(void); | |
57 | - void setup_font_list(GtkWidget *widget, GtkWidget *obj); | |
58 | - void load_color_schemes(GtkWidget *widget, gchar *active); | |
61 | + G_GNUC_INTERNAL GtkWidget * create_main_window(void); | |
62 | + G_GNUC_INTERNAL void setup_font_list(GtkWidget *widget, GtkWidget *obj); | |
63 | + G_GNUC_INTERNAL void load_color_schemes(GtkWidget *widget, gchar *active); | |
59 | 64 | |
60 | 65 | // actions |
61 | - void paste_file_action(GtkAction *action, GtkWidget *widget); | |
62 | - void hostname_action(GtkAction *action, GtkWidget *widget); | |
63 | - void save_all_action(GtkAction *action, GtkWidget *widget); | |
64 | - void save_selected_action(GtkAction *action, GtkWidget *widget); | |
65 | - void save_copy_action(GtkAction *action, GtkWidget *widget); | |
66 | - void print_all_action(GtkAction *action, GtkWidget *widget); | |
67 | - void print_selected_action(GtkAction *action, GtkWidget *widget); | |
68 | - void print_copy_action(GtkAction *action, GtkWidget *widget); | |
66 | + G_GNUC_INTERNAL void paste_file_action(GtkAction *action, GtkWidget *widget); | |
67 | + G_GNUC_INTERNAL void hostname_action(GtkAction *action, GtkWidget *widget); | |
68 | + G_GNUC_INTERNAL void save_all_action(GtkAction *action, GtkWidget *widget); | |
69 | + G_GNUC_INTERNAL void save_selected_action(GtkAction *action, GtkWidget *widget); | |
70 | + G_GNUC_INTERNAL void save_copy_action(GtkAction *action, GtkWidget *widget); | |
71 | + G_GNUC_INTERNAL void print_all_action(GtkAction *action, GtkWidget *widget); | |
72 | + G_GNUC_INTERNAL void print_selected_action(GtkAction *action, GtkWidget *widget); | |
73 | + G_GNUC_INTERNAL void print_copy_action(GtkAction *action, GtkWidget *widget); | |
69 | 74 | ... | ... |
src/gtk/main.c
... | ... | @@ -105,25 +105,32 @@ static int initialize(void) |
105 | 105 | return 0; |
106 | 106 | } |
107 | 107 | |
108 | -int main (int argc, char *argv[]) | |
108 | +int main(int argc, char *argv[]) | |
109 | 109 | { |
110 | + int rc = 0; | |
111 | + | |
112 | + g_set_application_name(PACKAGE_NAME); | |
113 | + | |
110 | 114 | gtk_init(&argc, &argv); |
111 | 115 | |
112 | - if(initialize()) | |
113 | - return -1; | |
116 | + rc = initialize(); | |
117 | + if(!rc) | |
118 | + { | |
119 | + configuration_init(); | |
120 | + | |
121 | + lib3270_set_popup_handler(popup_handler); | |
114 | 122 | |
115 | - configuration_init(); | |
116 | - lib3270_set_popup_handler(popup_handler); | |
123 | + toplevel = create_main_window(); | |
117 | 124 | |
118 | - toplevel = create_main_window(); | |
125 | + if(toplevel) | |
126 | + { | |
127 | + gtk_window_present(GTK_WINDOW(toplevel)); | |
128 | + gtk_main(); | |
129 | + } | |
119 | 130 | |
120 | - if(toplevel) | |
121 | - { | |
122 | - gtk_widget_show(toplevel); | |
123 | - gtk_main(); | |
131 | + configuration_deinit(); | |
124 | 132 | } |
125 | 133 | |
126 | - configuration_deinit(); | |
127 | - return 0; | |
134 | + return rc; | |
128 | 135 | } |
129 | 136 | ... | ... |
src/gtk/mainwindow.c
... | ... | @@ -313,7 +313,11 @@ |
313 | 313 | } |
314 | 314 | |
315 | 315 | // Create window |
316 | - window = ui_parse_xml_folder(path,groupname,popupname,terminal,widget_setup); | |
316 | + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
317 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
318 | + gtk_window_set_role(GTK_WINDOW(window),"toplevel"); | |
319 | + | |
320 | + ui_parse_xml_folder(GTK_WINDOW(window),path,groupname,popupname,terminal,widget_setup); | |
317 | 321 | group = g_object_get_data(G_OBJECT(window),"action_groups"); |
318 | 322 | popup = g_object_get_data(G_OBJECT(window),"popup_menus"); |
319 | 323 | ... | ... |
src/gtk/uiparser/parser.c
... | ... | @@ -217,7 +217,7 @@ static void release_list(GObject **obj) |
217 | 217 | g_free(obj); |
218 | 218 | } |
219 | 219 | |
220 | -GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) | |
220 | +int ui_parse_xml_folder(GtkWindow *toplevel, const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) | |
221 | 221 | { |
222 | 222 | struct parser p; |
223 | 223 | GDir * dir; |
... | ... | @@ -248,7 +248,7 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con |
248 | 248 | gtk_dialog_run(GTK_DIALOG (dialog)); |
249 | 249 | gtk_widget_destroy(dialog); |
250 | 250 | |
251 | - return NULL; | |
251 | + return -1; | |
252 | 252 | } |
253 | 253 | |
254 | 254 | while( (ptr = (gchar *) g_dir_read_name(dir)) != NULL) |
... | ... | @@ -264,7 +264,7 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con |
264 | 264 | g_dir_close(dir); |
265 | 265 | |
266 | 266 | parser_init(&p); |
267 | - p.toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
267 | + p.toplevel = GTK_WIDGET(toplevel); | |
268 | 268 | p.center_widget = widget; |
269 | 269 | p.group = groupname; |
270 | 270 | p.popupname = popupname; |
... | ... | @@ -303,5 +303,5 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con |
303 | 303 | |
304 | 304 | parser_destroy(&p); |
305 | 305 | |
306 | - return p.toplevel; | |
306 | + return 0; | |
307 | 307 | } | ... | ... |
src/gtk/uiparser/parser.h
... | ... | @@ -51,9 +51,9 @@ |
51 | 51 | void (*setup)(GtkWidget *widget, GtkWidget *obj); |
52 | 52 | } UI_WIDGET_SETUP; |
53 | 53 | |
54 | - GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | |
55 | - const gchar * ui_get_attribute(const gchar *key, const gchar **name, const gchar **value); | |
56 | - gboolean ui_get_bool_attribute(const gchar *key, const gchar **name, const gchar **value, gboolean def); | |
57 | - GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error); | |
54 | + int ui_parse_xml_folder(GtkWindow *toplevel, const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | |
55 | + const gchar * ui_get_attribute(const gchar *key, const gchar **name, const gchar **value); | |
56 | + gboolean ui_get_bool_attribute(const gchar *key, const gchar **name, const gchar **value, gboolean def); | |
57 | + GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error); | |
58 | 58 | |
59 | 59 | #endif // UI_PARSER_H_INCLUDED | ... | ... |
src/gtk/v3270/widget.c
... | ... | @@ -171,7 +171,7 @@ void get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural |
171 | 171 | *minimum_height = height ? height : 10; |
172 | 172 | |
173 | 173 | if(natural_height) |
174 | - *natural_height = height ? height : 200; | |
174 | + *natural_height = 400; | |
175 | 175 | |
176 | 176 | } |
177 | 177 | |
... | ... | @@ -183,7 +183,7 @@ void get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_w |
183 | 183 | *minimum_width = width ? width : 10; |
184 | 184 | |
185 | 185 | if(natural_width) |
186 | - *natural_width = width ? width : 320; | |
186 | + *natural_width = 600; | |
187 | 187 | } |
188 | 188 | |
189 | 189 | /* | ... | ... |