Commit 189e386b86eaafd656d9a7bfe1d6b4b7a9f4203b

Authored by Perry Werneck
1 parent ba467025

Adding command for action test.

Showing 1 changed file with 23 additions and 1 deletions   Show diff stats
src/actions/testprogram/testprogram.c
@@ -44,6 +44,25 @@ @@ -44,6 +44,25 @@
44 return NULL; 44 return NULL;
45 } 45 }
46 46
  47 + static gboolean handle_command(GtkWidget *trace, const gchar *cmd, const gchar *args, GtkWidget *window) {
  48 +
  49 + if(!g_ascii_strcasecmp(cmd,"activate")) {
  50 +
  51 + GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window),args);
  52 +
  53 + if(!action) {
  54 + g_message("Invalid action name: \"%s\"",args);
  55 + } else {
  56 + g_message("Activating action \"%s\"",args);
  57 + g_action_activate(action,NULL);
  58 + }
  59 +
  60 + return TRUE;
  61 + }
  62 +
  63 + return FALSE;
  64 + }
  65 +
47 static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { 66 static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
48 67
49 GtkWidget * window = gtk_application_window_new(app); 68 GtkWidget * window = gtk_application_window_new(app);
@@ -70,7 +89,10 @@ @@ -70,7 +89,10 @@
70 } 89 }
71 90
72 // Create trace window 91 // Create trace window
73 - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),v3270_trace_new(terminal),gtk_label_new("Trace")); 92 + GtkWidget * trace = v3270_trace_new(terminal);
  93 + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),trace,gtk_label_new("Trace"));
  94 +
  95 + g_signal_connect(trace,"command",G_CALLBACK(handle_command),window);
74 96
75 // Setup and show main window 97 // Setup and show main window
76 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); 98 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);