Commit 4b6b7ca34e780e3822a70db67ae10368399b9172

Authored by Perry Werneck
1 parent 92790c48

Implementing "open session in the window" action.

src/include/pw3270/window.h
@@ -57,10 +57,10 @@ @@ -57,10 +57,10 @@
57 typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow; 57 typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow;
58 58
59 GType pw3270ApplicationWindow_get_type(); 59 GType pw3270ApplicationWindow_get_type();
60 - GtkWidget * pw3270_application_window_new(GtkApplication * app); 60 + GtkWidget * pw3270_application_window_new(GtkApplication * app, const gchar *session_file);
61 61
62 /// @brief Create a new terminal tab. 62 /// @brief Create a new terminal tab.
63 - GtkWidget * pw3270_terminal_new(GtkWidget *window, const gchar *session_file); 63 + GtkWidget * pw3270_application_window_new_tab(GtkWidget *window, const gchar *session_file);
64 64
65 /// @brief Get the active terminal widget. 65 /// @brief Get the active terminal widget.
66 GtkWidget * pw3270_window_get_terminal_widget(GtkWidget *window); 66 GtkWidget * pw3270_window_get_terminal_widget(GtkWidget *window);
src/objects/application/actions/open.c
@@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
78 g_autofree gchar * session_file_name = get_session_file_name(GTK_APPLICATION(application),_("Open session in new tab")); 78 g_autofree gchar * session_file_name = get_session_file_name(GTK_APPLICATION(application),_("Open session in new tab"));
79 79
80 if(session_file_name) { 80 if(session_file_name) {
81 - pw3270_terminal_new(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), session_file_name); 81 + pw3270_application_window_new_tab(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), session_file_name);
82 } 82 }
83 83
84 g_simple_action_set_enabled(action,TRUE); 84 g_simple_action_set_enabled(action,TRUE);
@@ -91,7 +91,9 @@ @@ -91,7 +91,9 @@
91 g_autofree gchar * session_file_name = get_session_file_name(GTK_APPLICATION(application),_("Open session in new window")); 91 g_autofree gchar * session_file_name = get_session_file_name(GTK_APPLICATION(application),_("Open session in new window"));
92 92
93 if(session_file_name) { 93 if(session_file_name) {
94 -// pw3270_terminal_new(pw3270_application_window_new(GTK_APPLICATION(application)), session_file_name); 94 + GtkWidget *window = pw3270_application_window_new(GTK_APPLICATION(application), session_file_name);
  95 + pw3270_window_set_current_page(window,0);
  96 + gtk_window_present(GTK_WINDOW(window));
95 } 97 }
96 98
97 g_simple_action_set_enabled(action,TRUE); 99 g_simple_action_set_enabled(action,TRUE);
src/objects/application/actions/window.c
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 void pw3270_application_new_tab_activated(GSimpleAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { 59 void pw3270_application_new_tab_activated(GSimpleAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) {
60 60
61 debug("%s",__FUNCTION__); 61 debug("%s",__FUNCTION__);
62 - pw3270_terminal_new(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), NULL); 62 + pw3270_application_window_new_tab(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), NULL);
63 63
64 } 64 }
65 65
src/objects/application/application.c
@@ -286,29 +286,7 @@ @@ -286,29 +286,7 @@
286 286
287 void activate(GApplication *application) { 287 void activate(GApplication *application) {
288 288
289 - size_t ix;  
290 -  
291 - GtkWidget * window = pw3270_application_window_new(GTK_APPLICATION(application));  
292 -  
293 - // Create terminal widget & associated widget  
294 - GtkWidget * terminal = pw3270_terminal_new(window, NULL);  
295 -  
296 - // Create property actions  
297 - static const gchar * properties[] = {  
298 - "model-number",  
299 - "font-family",  
300 - "dynamic-font-spacing",  
301 - "trace",  
302 - };  
303 -  
304 - for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) {  
305 -  
306 - g_action_map_add_action(  
307 - G_ACTION_MAP(window),  
308 - v3270_property_action_new(terminal,properties[ix])  
309 - );  
310 -  
311 - } 289 + GtkWidget * window = pw3270_application_window_new(GTK_APPLICATION(application),NULL);
312 290
313 // Present the new window 291 // Present the new window
314 pw3270_window_set_current_page(window,0); 292 pw3270_window_set_current_page(window,0);
@@ -318,6 +296,11 @@ @@ -318,6 +296,11 @@
318 296
319 void open(GApplication *application, GFile **files, gint n_files, const gchar G_GNUC_UNUSED(*hint)) { 297 void open(GApplication *application, GFile **files, gint n_files, const gchar G_GNUC_UNUSED(*hint)) {
320 298
  299 +#ifndef DEBUG
  300 + #error Implementar
  301 +#endif // DEBUG
  302 +
  303 + /*
321 GtkWindow * window = gtk_application_get_active_window(GTK_APPLICATION(application)); 304 GtkWindow * window = gtk_application_get_active_window(GTK_APPLICATION(application));
322 305
323 debug("%s was called with %d files (active_window=%p)", __FUNCTION__, n_files, window); 306 debug("%s was called with %d files (active_window=%p)", __FUNCTION__, n_files, window);
@@ -338,6 +321,8 @@ @@ -338,6 +321,8 @@
338 if(last != -1) 321 if(last != -1)
339 pw3270_window_set_current_page(GTK_WIDGET(window),last); 322 pw3270_window_set_current_page(GTK_WIDGET(window),last);
340 323
  324 + */
  325 +
341 } 326 }
342 327
343 void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) { 328 void pw3270_application_set_ui_style(GApplication *app, PW3270_UI_STYLE type) {
src/objects/window/terminal.c
@@ -377,7 +377,7 @@ @@ -377,7 +377,7 @@
377 } 377 }
378 378
379 379
380 - GtkWidget * pw3270_terminal_new(GtkWidget *widget, const gchar *session_file) { 380 + GtkWidget * pw3270_application_window_new_tab(GtkWidget *widget, const gchar *session_file) {
381 381
382 struct SessionDescriptor * descriptor; 382 struct SessionDescriptor * descriptor;
383 383
@@ -468,7 +468,7 @@ @@ -468,7 +468,7 @@
468 if(path) { 468 if(path) {
469 469
470 // It's a session file 470 // It's a session file
471 - pw3270_terminal_new(widget, path); 471 + pw3270_application_window_new_tab(widget, path);
472 return 0; 472 return 0;
473 473
474 } 474 }
src/objects/window/window.c
@@ -199,7 +199,7 @@ @@ -199,7 +199,7 @@
199 199
200 } 200 }
201 201
202 - GtkWidget * pw3270_application_window_new(GtkApplication * application) { 202 + GtkWidget * pw3270_application_window_new(GtkApplication * application, const gchar *session_file) {
203 203
204 gchar *title = _( "IBM 3270 Terminal emulator" ); 204 gchar *title = _( "IBM 3270 Terminal emulator" );
205 205
@@ -316,9 +316,32 @@ @@ -316,9 +316,32 @@
316 G_SETTINGS_BIND_DEFAULT 316 G_SETTINGS_BIND_DEFAULT
317 ); 317 );
318 318
  319 +
  320 + // Setup default position and size
319 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); 321 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
320 gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); 322 gtk_window_set_default_size (GTK_WINDOW (window), 800, 500);
321 323
  324 + // Create terminal widget
  325 + GtkWidget * terminal = pw3270_application_window_new_tab(window, session_file);
  326 +
  327 + // Create property actions
  328 + static const gchar * properties[] = {
  329 + "model-number",
  330 + "font-family",
  331 + "dynamic-font-spacing",
  332 + "trace",
  333 + };
  334 +
  335 + for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) {
  336 +
  337 + g_action_map_add_action(
  338 + G_ACTION_MAP(window),
  339 + v3270_property_action_new(terminal,properties[ix])
  340 + );
  341 +
  342 + }
  343 +
  344 +
322 // gtk_window_set_interactive_debugging(TRUE); 345 // gtk_window_set_interactive_debugging(TRUE);
323 346
324 return GTK_WIDGET(window); 347 return GTK_WIDGET(window);