forked from puppylinux-woof-CE/gtkdialog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.c
823 lines (681 loc) · 25.3 KB
/
actions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
/*
* actions.c:
* Gtkdialog - A small utility for fast and easy GUI building.
* Copyright (C) 2003-2007 László Pere <pipas@linux.pte.hu>
* Copyright (C) 2011-2012 Thunor <thunorsif@hotmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <gtk/gtk.h>
#ifndef G_OS_WIN32
#include <sys/types.h>
#include <regex.h>
#endif
#include "gtkdialog.h"
#include "widgets.h"
#include "actions.h"
#include "attributes.h"
#include "variables.h"
#include "tag_attributes.h"
#include "config.h"
extern gchar *option_include_file;
/* Local function prototypes */
void action_closewindow(GtkWidget *widget, char *string);
void action_launchwindow(GtkWidget *widget, char *string);
void action_exitprogram(GtkWidget *widget, char *string);
void action_refreshwidget(GtkWidget *widget, char *string);
void action_savewidget(GtkWidget *widget, char *string);
void action_fileselect(GtkWidget *widget, char *string);
#if GTK_CHECK_VERSION(2,4,0)
void action_fileselection_made(GtkWidget *w, actioncommand *ac);
#endif
void action_fileselection_destroy(GtkWidget *w, actioncommand *ac);
void action_clearwidget(GtkWidget *widget, char *string);
void action_removeselected(GtkWidget *widget, char *string);
/* int action_append(GtkWidget *widget, char *string); Redundant: Isn't being used anyway so purge it */
void action_enable(GtkWidget *widget, char *string);
void action_disable(GtkWidget *widget, char *string);
void action_show(GtkWidget *widget, char *string);
void action_hide(GtkWidget *widget, char *string);
void action_activate(GtkWidget *widget, char *string);
void action_grabfocus(GtkWidget *widget, char *string);
void action_presentwindow(GtkWidget *widget, char *string);
void action_shellcommand(GtkWidget *widget, char *string);
/***********************************************************************
* Action closewindow *
***********************************************************************/
/* Thunor: This function will close an existing window that contains a
* variable that matches string although ideally the application developer
* would have supplied a unique name in the window widget's variable
* directive.
*/
void action_closewindow(GtkWidget *widget, char *string)
{
GtkWidget *window;
variable *existing;
g_assert(GTK_IS_WIDGET(widget));
#ifdef DEBUG
fprintf(stderr, "%s(): Entering.\n", __func__);
#endif
/**
* Patriot Oct 2009: zigbert has been dreaming for this to be fixed.
* Issue: closewindow command closes THE window its called from.
* Fixed: Workaround applied to point to the correct window.
**/
existing = variables_get_by_name(string);
#ifdef DEBUG
fprintf(stderr, "%s(): string=%s existing=%p\n",
__func__, string, existing);
fflush(stderr);
#endif
if (existing != NULL && existing->Widget != NULL) {
#ifdef DEBUG
fprintf(stderr, "%s(): Name=%s Type=%i\n",
__func__, existing->Name, existing->Type);
fflush(stderr);
#endif
//Redundant: parent = gtk_widget_get_toplevel(existing->Widget);
window = gtk_widget_get_ancestor(existing->Widget, GTK_TYPE_WINDOW);
//Redundant: variables_drop_by_parent(NULL, parent);
variables_drop_by_window_id(NULL, existing->window_id);
gtk_widget_destroy(window);
#ifdef DEBUG
fprintf(stderr, "%s(): variables_count_widgets()=%i\n", __func__,
variables_count_widgets());
#endif
/* If we are closing the last window then we can exit gtkdialog */
if (variables_count_widgets() == 0) {
printf("EXIT=\"closewindow\"\n");
/* Redundant: Since being here requires that there are no
* remaining variables therefore there's nothing to print.
* print_variables(NULL); */
#ifdef DEBUG
fprintf(stderr, "%s(): Calling exit(EXIT_SUCCESS)\n", __func__);
#endif
exit(EXIT_SUCCESS);
}
}
#ifdef DEBUG
fprintf(stderr, "%s(): Exiting.\n", __func__);
#endif
}
/***********************************************************************
* Action launchwindow *
***********************************************************************/
/* Thunor: This function will launch a new window, the source of which
* should be contained within an existing exported shell variable.
*
* The parameter to this function is the shell variable name which MUST
* match any widget's variable within the program, although it would be
* better practice to use a dedicated window widget's variable for this.
*
* Currently the variable name matching requirement remains unenforced
* and will require to remain so as there will be broken applications
* out there using fixes and workarounds. The best that can be hoped for
* is a warning message once the new window has been loaded.
*/
void action_launchwindow(GtkWidget *widget, char *string)
{
#ifdef DEBUG
extern gchar *program_src;
extern gint charsreaded;
#endif
extern int instruction_counter;
GtkWidget *window;
variable *existing;
variable *var;
#ifdef DEBUG
fprintf(stderr, "%s(): string=%s\n", __func__, string);
#endif
/* Thunor: Added to check that a program isn't being launched from a
* timer because this won't return and the timer stops functioning */
var = find_variable_by_widget(widget);
if (var->Type != WIDGET_TIMER) {
/* Thunor: Added to check that a program isn't already being parsed
* as run_program() is not reentrant and it'll error with a parser
* message that actually relates to the newly launched program
* (see Issue16 on the gtkdialog website) */
if (instruction_counter == 0) {
/* Check if a variable already exists with the same name as that
* passed as the parameter to launch to establish if the window
* has already been launched (it's not foolproof but it works) */
existing = variables_get_by_name(string);
if (existing != NULL && existing->Widget != NULL) {
/* The window has already been launched so just give it the focus */
#ifdef DEBUG
fprintf(stderr, "%s(): existing=%p Name=%s\n", __func__,
existing, existing->Name);
#endif
/**
* Patriot Oct 2009: Fixing the issue above [in action_closewindow]
* also requires a minor adjustment to this section.
**/
//Redundant: parent = gtk_widget_get_toplevel(existing->Widget);
window = gtk_widget_get_ancestor(existing->Widget, GTK_TYPE_WINDOW);
gtk_window_present(GTK_WINDOW(window));
} else {
/* Get the program source from the envvar and initialise
* everything necessary ready for a new parse */
//Redundant: set_program_source(string);
get_program_from_variable(string);
#ifdef DEBUG
fprintf(stderr, "%s():\ncharsreaded=%i\nprogram_src=%s\n",
__func__, charsreaded, program_src);
#endif
/* Export all variables */
variables_export_all();
#ifdef DEBUG
fprintf(stderr, "%s():\ncharsreaded=%i\nprogram_src=%s\n",
__func__, charsreaded, program_src);
#endif
/* Call the parser to interpret the new code (it won't return) */
gtkdialog_parse();
g_warning("%s(): This won't be reached.", __func__);
}
} else {
fprintf(stderr, "%s(): It's not possible to launch %s at this time: \
try launching after the originating window has fully loaded.\n",
__func__, string);
}
} else {
fprintf(stderr, "%s(): It's not possible to launch %s from within a timer: \
try launching from a checkbox which is activated by the timer.\n",
__func__, string);
}
}
/***********************************************************************
* Action exit *
***********************************************************************/
void action_exitprogram(GtkWidget *widget, char *string)
{
print_variables(NULL);
if (string[0] == '=')
/* Thunor: An interesting undocumented feature temp temp */
printf("EXIT%s", string);
else
printf("EXIT=\"%s\"\n", string);
#ifdef DEBUG
fprintf(stderr, "%s(): Calling exit(EXIT_SUCCESS)\n", __func__);
#endif
exit(EXIT_SUCCESS);
}
/***********************************************************************
* Action refresh *
***********************************************************************/
void action_refreshwidget(GtkWidget *widget, char *string)
{
variables_refresh(string);
}
/***********************************************************************
* Action save *
***********************************************************************/
void action_savewidget(GtkWidget *widget, char *string)
{
variables_save(string);
}
/***********************************************************************
* Action fileselect *
***********************************************************************/
/* This function will create and open a fileselection dialog and
* connect it to the action_fileselection_made function to take
* the selected file name */
#if GTK_CHECK_VERSION(2,4,0)
void action_fileselect(GtkWidget *widget, char *string)
{
list_t *mime_types = NULL;
list_t *patterns = NULL;
variable *var = NULL;
GList *element;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
GtkFileFilter *filter;
GtkWidget *chooser;
gchar *filename = NULL;
gchar *title = "Gtkdialog";
gchar *value;
gint count;
gint response;
#ifdef DEBUG
fprintf(stderr, "%s(): string='%s'\n", __func__, string);
#endif
if (var = variables_get_by_name(string)) {
/* Set the title of the chooser dialog to the label directive
* of the target widget if available (this was the original
* behaviour that although used in the 16.00-fileselect example
* it is undocumented so possibly few people have realised this) */
if (attributeset_is_avail(var->Attributes, ATTR_LABEL)) {
title = attributeset_get_first(&element, var->Attributes, ATTR_LABEL);
#ifdef DEBUG
fprintf(stderr, "%s(): title='%s' from label directive\n",
__func__, title);
#endif
}
if (var->widget_tag_attr) {
/* Set title if present */
if ((value = get_tag_attribute(var->widget_tag_attr, "fs-title"))) {
title = value;
#ifdef DEBUG
fprintf(stderr, "%s(): title='%s' from tag attribute\n",
__func__, title);
#endif
}
/* Set file chooser action if present */
if ((value = get_tag_attribute(var->widget_tag_attr, "fs-action")) ||
(value = get_tag_attribute(var->widget_tag_attr, "accept"))) { /* Deprecated */
if ((strcasecmp(value, "file") == 0) ||
(strcasecmp(value, "filename") == 0)) { /* Deprecated */
action = GTK_FILE_CHOOSER_ACTION_OPEN;
} else if ((strcasecmp(value, "newfile") == 0) ||
(strcasecmp(value, "savefilename") == 0)) { /* Deprecated */
action = GTK_FILE_CHOOSER_ACTION_SAVE;
} else if ((strcasecmp(value, "folder") == 0) ||
(strcasecmp(value, "directory") == 0)) { /* Deprecated */
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
} else if ((strcasecmp(value, "newfolder") == 0) ||
(strcasecmp(value, "newdirectory") == 0)) { /* Deprecated */
action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
}
#ifdef DEBUG
fprintf(stderr, "%s(): action=%i\n", __func__, action);
#endif
}
}
/* Create the file chooser dialog */
chooser = gtk_file_chooser_dialog_new(title, NULL, action,
GTK_STOCK_OK, GTK_RESPONSE_OK,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
/* Set current folder if present */
if (var->widget_tag_attr &&
((value = get_tag_attribute(var->widget_tag_attr, "fs-folder")))) {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), value);
#ifdef DEBUG
fprintf(stderr, "%s(): current folder='%s'\n", __func__, value);
#endif
}
/* Add file filters */
if (var->widget_tag_attr) {
/* Filters of type pattern */
if ((value = get_tag_attribute(var->widget_tag_attr, "fs-filters"))) {
patterns = linecutter(g_strdup(value), '|');
for (count = 0; count < patterns->n_lines; count++) {
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, patterns->line[count]);
gtk_file_filter_add_pattern(filter, patterns->line[count]);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
#ifdef DEBUG
fprintf(stderr, "%s(): patterns->line[count]='%s'\n",
__func__, patterns->line[count]);
#endif
}
}
/* Filters of type mime */
if ((value = get_tag_attribute(var->widget_tag_attr, "fs-filters-mime"))) {
mime_types = linecutter(g_strdup(value), '|');
for (count = 0; count < mime_types->n_lines; count++) {
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, mime_types->line[count]);
gtk_file_filter_add_mime_type(filter, mime_types->line[count]);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
#ifdef DEBUG
fprintf(stderr, "%s(): mime_types->line[count]='%s'\n",
__func__, mime_types->line[count]);
#endif
}
}
}
/* Add an "All files" "*" filter which will become the
* default if no user filters were added above */
filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, "All files");
gtk_file_filter_add_pattern(filter, "*");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);
/* Run the file chooser dialog and get the response.
* Note that accept="newdirectory" (fs-action="newfolder")
* currently crashes the file chooser dialog if nothing is
* selected or created which is mentioned in the example */
response = gtk_dialog_run(GTK_DIALOG(chooser));
#ifdef DEBUG
fprintf(stderr, "%s(): response=%i\n", __func__, response);
#endif
/* If the user pressed the OK button we set the target widget */
switch (response) {
case GTK_RESPONSE_CANCEL:
/* Nothing to do */
break;
case GTK_RESPONSE_OK:
filename = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(chooser));
#ifdef DEBUG
fprintf(stderr, "%s(): filename=%s\n", __func__, filename);
#endif
if (filename) {
variables_set_value(string, filename);
g_free(filename);
}
break;
}
/* Free linecutter memory */
if (patterns) list_t_free(patterns);
if (mime_types) list_t_free(mime_types);
/* Destroy the file chooser dialog */
gtk_widget_destroy(chooser);
}
}
#else
void action_fileselect(GtkWidget *widget, char *string)
{
actioncommand *ac;
/*
** We create a new actioncommand.
*/
ac = g_malloc(sizeof(actioncommand));
ac->source_widget = gtk_file_selection_new("gtkwindow");
ac->destination_name = string;
gtk_widget_show(ac->source_widget);
/*
** We connect the OK button in fileselection dialog
*/
g_signal_connect(G_OBJECT
(GTK_FILE_SELECTION(ac->source_widget)->
ok_button), "clicked",
G_CALLBACK(action_fileselection_made),
(gpointer) ac);
/*
** We connect the Cancel button in fileselection dialog
*/
g_signal_connect(G_OBJECT
(GTK_FILE_SELECTION(ac->source_widget)->
cancel_button), "clicked",
G_CALLBACK(action_fileselection_destroy),
(gpointer) ac);
}
/***********************************************************************
* *
***********************************************************************/
/* This function is called when the user presses the OK button in
* a fileselection dialog */
void action_fileselection_made(GtkWidget *w, actioncommand * ac)
{
/*
** Let's copy the selected file name to the destination widget.
*/
variables_set_value((const char *)ac->destination_name,
gtk_file_selection_get_filename(GTK_FILE_SELECTION(ac->source_widget))
);
/*
** We destroy the fileselection dialog and free the actioncommand
** memory.
*/
gtk_widget_destroy(ac->source_widget);
free(ac);
}
#endif
/***********************************************************************
* *
***********************************************************************/
/* This function is called when the user presses the Cancel button in
* a fileselection dialog */
void action_fileselection_destroy(GtkWidget *w, actioncommand *ac)
{
/*
** We destroy the fileselection dialog and free the actioncommand
** memory.
*/
gtk_widget_destroy(ac->source_widget);
free(ac);
}
/***********************************************************************
* Action clear *
***********************************************************************/
/* This action removes all elements from a widget */
void action_clearwidget(GtkWidget *widget, char *string)
{
variables_clear(string);
}
/***********************************************************************
* Action removeselected *
***********************************************************************/
/* This action removes a selected element from a widget */
void action_removeselected(GtkWidget *widget, char *string)
{
remove_selected_variable(string);
}
/***********************************************************************
* *
***********************************************************************/
/* Redundant: Isn't being used anyway so purge it.
int action_append(GtkWidget *widget, char *string)
{
#ifndef G_OS_WIN32
regex_t twoparams;
regmatch_t matched[3];
char *regular = "[ ]*([A-Za-z_]+),[ ]*([A-Za-z_]+)";
char *from, *to;
int length_from, length_to;
g_assert(string != NULL);
if (regcomp(&twoparams, regular, REG_EXTENDED) != 0)
g_error("%s(): Internal error: %m", __func__);
if (regexec(&twoparams, string, 3, matched, 0) != 0) {
yywarning("Insert action needs two parameters.");
return FALSE;
}
length_from = matched[1].rm_eo - matched[1].rm_so;
from = g_malloc(length_from + 1);
length_to = matched[2].rm_eo - matched[2].rm_so;
to = g_malloc(length_to + 1);
strncpy(from, string, length_from);
from[length_from] = '\0';
strncpy(to, string + matched[2].rm_so, length_to);
to[length_to] = '\0';
return append_fromto_variable(from, to);
#else
g_warning("%s(): Unimplemented.", __func__);
#endif
} */
/***********************************************************************
* Action enable *
***********************************************************************/
void action_enable(GtkWidget *widget, char *string)
{
variables_enable(string);
}
/***********************************************************************
* Action disable *
***********************************************************************/
void action_disable(GtkWidget *widget, char *string)
{
variables_disable(string);
}
/***********************************************************************
* Action show *
***********************************************************************/
void action_show(GtkWidget *widget, char *string)
{
variables_show(string);
}
/***********************************************************************
* Action hide *
***********************************************************************/
void action_hide(GtkWidget *widget, char *string)
{
variables_hide(string);
}
/***********************************************************************
* Action activate *
***********************************************************************/
void action_activate(GtkWidget *widget, char *string)
{
variables_activate(string);
}
/***********************************************************************
* Action grabfocus *
***********************************************************************/
void action_grabfocus(GtkWidget *widget, char *string)
{
variables_grabfocus(string);
}
/***********************************************************************
* Action presentwindow *
***********************************************************************/
void action_presentwindow(GtkWidget *widget, char *string)
{
variables_presentwindow(string);
}
/***********************************************************************
* Action command *
***********************************************************************/
static void _action_shellcommand(const char *command)
{
#if HAVE_BASH
char *argv[] = {"bash", "-c", command, NULL};
g_spawn_sync(NULL,
argv,
NULL,
G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_SEARCH_PATH,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
#else
system(command);
#endif
}
/* This fuction will export variables and run a shell command */
void action_shellcommand(GtkWidget *widget, char *string)
{
char *command;
variables_export_all();
if (option_include_file == NULL) {
_action_shellcommand(string);
} else {
/* Debian 01_bashism patch: use dot rather than source.
command = g_strdup_printf("source %s; %s", */
command = g_strdup_printf(". %s; %s",
option_include_file, string);
_action_shellcommand(command);
g_free(command);
}
}
/***********************************************************************
* Execute Action *
***********************************************************************/
/* On exit: returns 0 if action function is unknown
* 1 if action function is valid
* 2 if break function detected */
int execute_action(GtkWidget *widget, const char *command, const char *type)
{
gchar *command_prefix;
gchar *command_string;
gint retval = 1;
CommandType t;
/* Thunor: I've re-engineered my signal blocking mechanism.
* All signal callbacks end up here, so if the global flag is
* true then the action functions simply don't get executed */
if (!function_signals_block) {
if (type == NULL || g_utf8_strlen(type, -1) == 0) {
command_get_prefix(command, &command_prefix, &command_string);
} else {
command_prefix = g_strdup(type);
command_string = g_strdup(command);
}
#ifdef DEBUG
fprintf(stderr, "%s(): command: '%s' type: '%s'.\n", __func__,
command_string, command_prefix);
#endif
t = command_prefix_get_type(command_prefix);
switch (t) {
case CommandShellCommand:
action_shellcommand(widget, command_string);
break;
case CommandExit:
action_exitprogram(widget, command_string);
break;
case CommandCloseWindow:
action_closewindow(widget, command_string);
break;
case CommandLaunch:
action_launchwindow(widget, command_string);
break;
case CommandEnable:
action_enable(widget, command_string);
break;
case CommandDisable:
action_disable(widget, command_string);
break;
case CommandShow:
action_show(widget, command_string);
break;
case CommandHide:
action_hide(widget, command_string);
break;
case CommandActivate:
action_activate(widget, command_string);
break;
case CommandGrabFocus:
action_grabfocus(widget, command_string);
break;
case CommandPresentWindow:
action_presentwindow(widget, command_string);
break;
case CommandRefresh:
variables_export_all();
action_refreshwidget(widget, command_string);
break;
case CommandSave:
action_savewidget(widget, command_string);
break;
case CommandFileSelect:
action_fileselect(widget, command_string);
break;
case CommandClear:
action_clearwidget(widget, command_string);
break;
case CommandRemoveSelected:
action_removeselected(widget, command_string);
break;
case CommandBreak:
retval = 2;
break;
case CommandLoadStyles:
load_styles_file(command_string);
retval = 0;
break;
/* Thunor: It looks like work on insert and append was started
* but there's not much code so I wouldn't expect it to work
* (I haven't tried it since it's not documented). Note that
* both are calling action_append() which is strange */
case CommandInsert:
/* action_append(widget, command_string); Redundant: Isn't being used anyway so purge it */
retval = 0;
break;
case CommandAppend:
/* action_append(widget, command_string); Redundant: Isn't being used anyway so purge it */
retval = 0;
break;
default:
g_error("%s(): Unknown action type", __func__);
retval = 0;
break;
}
g_free(command_prefix);
g_free(command_string);
}
return retval;
}