Commit 3f279bba1b058c39370bef91805463fb5df902b3

Authored by Perry Werneck
1 parent 4be60cbe

Refactorin window actions.

src/include/pw3270/actions.h
@@ -82,7 +82,7 @@ @@ -82,7 +82,7 @@
82 } PW3270ActionClass; 82 } PW3270ActionClass;
83 83
84 GType PW3270Action_get_type(void) G_GNUC_CONST; 84 GType PW3270Action_get_type(void) G_GNUC_CONST;
85 - PW3270Action * pw3270action_new(); 85 + PW3270Action * pw3270_action_new();
86 PW3270Action * pw3270_dialog_action_new(GtkWidget * (*factory)(PW3270Action *action, GtkApplication *application)); 86 PW3270Action * pw3270_dialog_action_new(GtkWidget * (*factory)(PW3270Action *action, GtkApplication *application));
87 87
88 // 88 //
src/objects/actions/abstract.c
@@ -249,8 +249,8 @@ @@ -249,8 +249,8 @@
249 // 249 //
250 // Action methods. 250 // Action methods.
251 // 251 //
252 - GAction * pw3270_action_new() {  
253 - return G_ACTION(g_object_new(PW3270_TYPE_ACTION, NULL)); 252 + PW3270Action * pw3270_action_new() {
  253 + return PW3270_ACTION(g_object_new(PW3270_TYPE_ACTION, NULL));
254 } 254 }
255 255
256 GdkPixbuf * pw3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) { 256 GdkPixbuf * pw3270_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) {
src/objects/application/actions/window.c
@@ -33,9 +33,9 @@ @@ -33,9 +33,9 @@
33 33
34 #include "../private.h" 34 #include "../private.h"
35 #include <pw3270/application.h> 35 #include <pw3270/application.h>
  36 + #include <pw3270/actions.h>
36 37
37 -  
38 - void pw3270_application_quit_activated(GSimpleAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), gpointer G_GNUC_UNUSED(application)) { 38 + static void quit_activated(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkApplication *application) {
39 39
40 g_print("Exiting application\n"); 40 g_print("Exiting application\n");
41 41
@@ -56,16 +56,56 @@ @@ -56,16 +56,56 @@
56 56
57 } 57 }
58 58
59 - void pw3270_application_new_tab_activated(GSimpleAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { 59 + GAction * pw3270_quit_action_new() {
  60 +
  61 + PW3270Action * action = pw3270_action_new();
  62 +
  63 + action->name = "quit";
  64 + action->label = _( "Quit" );
  65 + action->tooltip = _( "Quit application" );
  66 + action->icon_name = "gtk-quit";
  67 + action->activate = quit_activated;
  68 +
  69 + return G_ACTION(action);
  70 + }
  71 +
  72 + static void new_tab_activated(GAction *action, GVariant *parameter, GtkApplication *application) {
60 73
61 debug("%s",__FUNCTION__); 74 debug("%s",__FUNCTION__);
62 pw3270_application_window_new_tab(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), NULL); 75 pw3270_application_window_new_tab(GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))), NULL);
63 76
64 } 77 }
65 78
66 - void pw3270_application_new_window_activated(GSimpleAction G_GNUC_UNUSED(* action), GVariant G_GNUC_UNUSED(*parameter), gpointer application) { 79 + GAction * pw3270_new_tab_action_new() {
  80 +
  81 + PW3270Action * action = pw3270_action_new();
  82 +
  83 + action->name = "new.tab";
  84 + action->label = _( "New tab" );
  85 + action->tooltip = _( "New tab with default session" );
  86 + action->icon_name = "tab-new";
  87 + action->activate = new_tab_activated;
  88 +
  89 + return G_ACTION(action);
  90 + }
  91 +
  92 + static void new_window_activated(GAction *action, GVariant *parameter, GtkApplication *application) {
67 93
68 debug("%s",__FUNCTION__); 94 debug("%s",__FUNCTION__);
69 g_application_activate(application); 95 g_application_activate(application);
70 96
71 } 97 }
  98 +
  99 + GAction * pw3270_new_window_action_new() {
  100 +
  101 + PW3270Action * action = pw3270_action_new();
  102 +
  103 + action->name = "new.window";
  104 + action->label = _( "New window" );
  105 + action->tooltip = _( "New window with default session" );
  106 + action->icon_name = "window-new";
  107 + action->activate = new_window_activated;
  108 +
  109 + return G_ACTION(action);
  110 + }
  111 +
src/objects/application/application.c
@@ -378,7 +378,10 @@ @@ -378,7 +378,10 @@
378 378
379 GAction * actions[] = { 379 GAction * actions[] = {
380 pw3270_about_action_new(), 380 pw3270_about_action_new(),
381 - pw3270_preferences_action_new() 381 + pw3270_preferences_action_new(),
  382 + pw3270_new_tab_action_new(),
  383 + pw3270_new_window_action_new(),
  384 + pw3270_quit_action_new()
382 }; 385 };
383 386
384 for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) { 387 for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) {
src/objects/application/private.h
@@ -52,12 +52,11 @@ @@ -52,12 +52,11 @@
52 // Actions 52 // Actions
53 G_GNUC_INTERNAL GAction * pw3270_about_action_new(); 53 G_GNUC_INTERNAL GAction * pw3270_about_action_new();
54 G_GNUC_INTERNAL GAction * pw3270_preferences_action_new(); 54 G_GNUC_INTERNAL GAction * pw3270_preferences_action_new();
  55 + G_GNUC_INTERNAL GAction * pw3270_new_tab_action_new();
  56 + G_GNUC_INTERNAL GAction * pw3270_new_window_action_new();
  57 + G_GNUC_INTERNAL GAction * pw3270_quit_action_new();
55 58
56 G_GNUC_INTERNAL void pw3270_application_generic_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 59 G_GNUC_INTERNAL void pw3270_application_generic_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
57 - G_GNUC_INTERNAL void pw3270_application_quit_activated(GSimpleAction * action, GVariant *parameter, gpointer application);  
58 - G_GNUC_INTERNAL void pw3270_application_new_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application);  
59 - G_GNUC_INTERNAL void pw3270_application_new_window_activated(GSimpleAction * action, GVariant *parameter, gpointer application);  
60 - G_GNUC_INTERNAL void pw3270_application_preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application);  
61 60
62 G_GNUC_INTERNAL void pw3270_application_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 61 G_GNUC_INTERNAL void pw3270_application_open_activated(GSimpleAction * action, GVariant *parameter, gpointer application);
63 G_GNUC_INTERNAL void pw3270_application_open_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application); 62 G_GNUC_INTERNAL void pw3270_application_open_tab_activated(GSimpleAction * action, GVariant *parameter, gpointer application);