~leftyfb/gstm/gstm

« back to all changes in this revision

Viewing changes to src/callbacks.c

  • Committer: Mattias Eriksson
  • Date: 2009-10-29 17:45:24 UTC
  • Revision ID: mattias.eriksson@ardendo.se-20091029174524-8h0fmfa68i607us9
Initial checkin of gstm 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#  include <config.h>
 
3
#endif
 
4
 
 
5
#include <gnome.h>
 
6
 
 
7
#include "callbacks.h"
 
8
#include "interface.h"
 
9
#include "support.h"
 
10
 
 
11
#include "common.h"
 
12
#include "fniface.h"
 
13
#include "conffile.h"
 
14
 
 
15
extern void gstm_quit(void);
 
16
extern void docklet_x11_create(void);
 
17
extern void docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data);
 
18
 
 
19
/* quit handlers */
 
20
void
 
21
on_maindialog_remove                   (GtkContainer    *container,
 
22
                                        GtkWidget       *widget,
 
23
                                        gpointer         user_data)
 
24
{
 
25
        //gstm_quit();
 
26
}
 
27
 
 
28
void gstm_terminate()
 
29
{
 
30
        extern GtkWidget *maindialog;
 
31
        GtkWidget *confirm = gtk_message_dialog_new_with_markup (
 
32
                GTK_WINDOW (maindialog),
 
33
                0,
 
34
                GTK_MESSAGE_QUESTION,
 
35
                GTK_BUTTONS_NONE,
 
36
                "<b><big>Really quit?</big></b>\n\n"
 
37
                "All active tunnels will be stopped.");
 
38
                
 
39
        gtk_dialog_add_buttons (GTK_DIALOG (confirm),
 
40
                GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
 
41
                GTK_STOCK_QUIT, GTK_RESPONSE_YES,
 
42
                NULL);
 
43
        
 
44
        if (activeCount==0 || gtk_dialog_run(GTK_DIALOG(confirm))==GTK_RESPONSE_YES)
 
45
                gstm_quit();
 
46
 
 
47
        gtk_widget_destroy(confirm);
 
48
        gtk_window_set_focus(GTK_WINDOW(maindialog),lookup_widget(maindialog,"tunnellist"));
 
49
 
 
50
}
 
51
 
 
52
gboolean
 
53
on_maindialog_delete_event             (GtkWidget       *widget,
 
54
                                        GdkEvent        *event,
 
55
                                        gpointer         user_data)
 
56
{
 
57
        gstm_terminate();
 
58
}
 
59
 
 
60
void
 
61
on_btn_close_clicked                   (GtkButton       *button,
 
62
                                        gpointer         user_data)
 
63
{
 
64
        gstm_terminate();
 
65
}
 
66
 
 
67
/* show about dialog, disable main */
 
68
gboolean
 
69
on_eventbox1_button_press_event        (GtkWidget       *widget,
 
70
                                        GdkEventButton  *event,
 
71
                                        gpointer         user_data)
 
72
{
 
73
        GtkWidget *about;
 
74
        about = create_aboutdialog();
 
75
        gtk_window_set_skip_taskbar_hint(GTK_WINDOW(about),TRUE);
 
76
        gstm_interface_enable_maindialog(FALSE);
 
77
        gtk_widget_show(about);
 
78
  return FALSE;
 
79
}
 
80
 
 
81
/* re-enable main dialog */
 
82
void
 
83
on_aboutdialog_remove                  (GtkContainer    *container,
 
84
                                        GtkWidget       *widget,
 
85
                                        gpointer         user_data)
 
86
{
 
87
        gstm_interface_enable_maindialog(TRUE);
 
88
        gtk_widget_destroy(widget);
 
89
}
 
90
void
 
91
on_aboutdialog_response                (GtkDialog       *dialog,
 
92
                                        gint             response_id,
 
93
                                        gpointer         user_data)
 
94
{
 
95
        gstm_interface_enable_maindialog(TRUE);
 
96
        gtk_widget_destroy(GTK_WIDGET(dialog));
 
97
}
 
98
 
 
99
void
 
100
on_btn_properties_clicked              (GtkButton       *button,
 
101
                                        gpointer         user_data)
 
102
{
 
103
        GtkTreeSelection *s;
 
104
        int id;
 
105
        if (s=gstm_interface_get_selected_tunnel()) {
 
106
                id = gstm_interface_selection2id(s,COL_ID);
 
107
                gstm_interface_properties(id);
 
108
        }
 
109
}
 
110
 
 
111
 
 
112
void
 
113
on_btn_add_clicked                     (GtkButton       *button,
 
114
                                        gpointer         user_data)
 
115
{
 
116
        extern GtkWidget *maindialog;
 
117
        int id=-1;
 
118
        gchar *newname=NULL;
 
119
        if (gstm_interface_asknewname(&newname) == GTK_RESPONSE_OK) {
 
120
                id = gstm_tunnel_add(newname);
 
121
                if (id>-1) gstm_interface_properties(id);
 
122
        }
 
123
        free(newname);
 
124
        gtk_window_set_focus(GTK_WINDOW(maindialog),lookup_widget(maindialog,"tunnellist"));
 
125
}
 
126
 
 
127
void
 
128
on_btn_delete_clicked                  (GtkButton       *button,
 
129
                                        gpointer         user_data)
 
130
{
 
131
        extern GtkWidget *maindialog;
 
132
        GtkTreeSelection *s;
 
133
        GtkWidget *del = gtk_message_dialog_new (
 
134
                GTK_WINDOW (maindialog),
 
135
                0,
 
136
                GTK_MESSAGE_QUESTION,
 
137
                GTK_BUTTONS_YES_NO,
 
138
                "");
 
139
        gint id;
 
140
 
 
141
        if (s=gstm_interface_get_selected_tunnel()) {
 
142
                id = gstm_interface_selection2id(s,COL_ID);     
 
143
                gchar *messagemarkup = g_strdup_printf (
 
144
                        "<b><big>Delete tunnel?</big></b>\n\nAre you sure you want to delete "
 
145
                        "the tunnel '%s'?", gSTMtunnels[id]->name);
 
146
                gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (del), messagemarkup);
 
147
                if (gtk_dialog_run(GTK_DIALOG(del))==GTK_RESPONSE_YES) {
 
148
                        gstm_tunnel_del(gstm_interface_selection2id(s,COL_ID));
 
149
                }
 
150
                g_free (messagemarkup);
 
151
        } else {
 
152
                gstm_interface_error("oops, selected tunnel not found!");
 
153
        }
 
154
 
 
155
        gtk_widget_destroy(del);
 
156
        gtk_window_set_focus(GTK_WINDOW(maindialog), lookup_widget(maindialog, "tunnellist"));
 
157
        gstm_interface_rowactivity();
 
158
}
 
159
 
 
160
/* start or stop a tunnel */
 
161
void
 
162
on_btn_start_clicked                   (GtkButton       *button,
 
163
                                        gpointer         user_data)
 
164
{
 
165
        gstm_interface_rowaction();
 
166
}
 
167
void
 
168
on_tunnellist_row_activated            (GtkTreeView     *treeview,
 
169
                                        GtkTreePath     *path,
 
170
                                        GtkTreeViewColumn *column,
 
171
                                        gpointer         user_data)
 
172
{
 
173
        gstm_interface_rowaction();
 
174
}
 
175
 
 
176
/* possible rowselection change */
 
177
gboolean
 
178
on_tunnellist_button_release_event     (GtkWidget       *widget,
 
179
                                        GdkEventButton  *event,
 
180
                                        gpointer         user_data)
 
181
{
 
182
        gstm_interface_rowactivity();
 
183
  return FALSE;
 
184
}
 
185
gboolean
 
186
on_tunnellist_key_release_event        (GtkWidget       *widget,
 
187
                                        GdkEventKey     *event,
 
188
                                        gpointer         user_data)
 
189
{
 
190
        gstm_interface_rowactivity();
 
191
  return FALSE;
 
192
}
 
193
 
 
194
 
 
195
void redir_addedit(GtkButton *button, GtkWidget *tun, gint editid) {
 
196
        GtkWidget *t,*p1,*h,*p2,*w;
 
197
        GtkTreeIter iter;
 
198
        int ok = 0;
 
199
        struct portredir p;
 
200
        while (!ok){
 
201
                ok=1;
 
202
                if (gtk_dialog_run(GTK_DIALOG(tun))==GTK_RESPONSE_OK) {
 
203
                        if (t=lookup_widget(GTK_WIDGET(tun),"choice_type")) {
 
204
                                p.type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(t));
 
205
                        }
 
206
                        if (t && p.type && strlen(p.type)>0) {
 
207
                                if (p1=lookup_widget(GTK_WIDGET(tun),"input_port1")) {
 
208
                                        p.port1=(gchar *)gtk_entry_get_text(GTK_ENTRY(p1));
 
209
                                        if (!p.port1 || strlen(p.port1)==0) {
 
210
                                                gstm_interface_error("Port entry is empty");
 
211
                                                ok=0;
 
212
                                        }
 
213
                                }
 
214
                                if (ok) {
 
215
                                        if (strcmp(p.type,"dynamic")==0) {
 
216
                                                p.host = malloc(4);
 
217
                                                strcpy(p.host,"n/a\0");
 
218
                                                p.port2 = malloc(4);
 
219
                                                strcpy(p.port2,"n/a\0");
 
220
                                        } else {
 
221
                                                if (h=lookup_widget(GTK_WIDGET(tun),"input_host")) {
 
222
                                                        p.host=(gchar *)gtk_entry_get_text(GTK_ENTRY(h));
 
223
                                                        if (!p.host || strlen(p.host)==0) {
 
224
                                                                gstm_interface_error("Host entry is empty");
 
225
                                                                ok=0;
 
226
                                                        }
 
227
                                                }
 
228
                                                if (ok) {
 
229
                                                        if (p2=lookup_widget(GTK_WIDGET(tun),"input_port2")) {
 
230
                                                                p.port2=(gchar *)gtk_entry_get_text(GTK_ENTRY(p2));
 
231
                                                                if (!p.port2 || strlen(p.port2)==0) {
 
232
                                                                        gstm_interface_error("Port2 entry is empty");
 
233
                                                                        ok=0;
 
234
                                                                }
 
235
                                                        }
 
236
                                                }
 
237
                                        }
 
238
                                        if (ok) {
 
239
                                                if (w=lookup_widget(GTK_WIDGET(button),"redirlist")) {
 
240
                                                        if (editid>-1) {
 
241
                                                                /* edit existing */
 
242
                                                                gstm_interface_redirlist_edit(&p, editid, GTK_TREE_VIEW(w));
 
243
                                                        } else {
 
244
                                                                /* add as new */
 
245
                                                                gstm_interface_redirlist_add(&p, (int)random(), GTK_TREE_VIEW(w));
 
246
                                                        }
 
247
                                                }
 
248
                                        }
 
249
                                }
 
250
                        } else {
 
251
                                ok=0;
 
252
                                gstm_interface_error("No tunnel type selected");
 
253
                        }
 
254
                }
 
255
        }
 
256
}
 
257
 
 
258
void
 
259
on_btn_redir_add_clicked               (GtkButton       *button,
 
260
                                        gpointer         user_data)
 
261
{
 
262
        extern GtkWidget *prop;
 
263
        GtkWidget *t;
 
264
        GtkWidget *tun = create_tundialog();
 
265
        /* some dialog init */
 
266
        gtk_window_set_transient_for(GTK_WINDOW(tun),GTK_WINDOW(prop));
 
267
        if (t=lookup_widget(GTK_WIDGET(tun),"choice_type")) {
 
268
                gtk_combo_box_set_active(GTK_COMBO_BOX(t),0);
 
269
        }
 
270
        /* run the dialog */
 
271
        redir_addedit(button,tun,-1);
 
272
        gtk_widget_destroy(tun);
 
273
}
 
274
 
 
275
void
 
276
on_btn_redir_delete_clicked            (GtkButton       *button,
 
277
                                        gpointer         user_data)
 
278
{
 
279
        GtkWidget *w;
 
280
        GtkTreeSelection *s;
 
281
        if (w = lookup_widget(GTK_WIDGET(button),"redirlist")) {
 
282
                s = gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
 
283
                if (gtk_tree_selection_count_selected_rows(s)>0) {
 
284
                        gstm_interface_redirlist_del(GTK_TREE_VIEW(w),gstm_interface_selection2id(s,COL_RID));
 
285
                }
 
286
        }
 
287
}
 
288
 
 
289
 
 
290
 
 
291
void
 
292
on_check_auto_toggled                  (GtkToggleButton *togglebutton,
 
293
                                        gpointer         user_data)
 
294
{
 
295
 
 
296
}
 
297
 
 
298
 
 
299
void
 
300
on_choice_type_changed                 (GtkComboBox     *combobox,
 
301
                                        gpointer         user_data)
 
302
{
 
303
        GtkWidget *port1, *host, *port2;
 
304
        char *cbtext;
 
305
        port1 = lookup_widget(GTK_WIDGET(combobox),"input_port1");
 
306
        host = lookup_widget(GTK_WIDGET(combobox),"input_host");
 
307
        port2 = lookup_widget(GTK_WIDGET(combobox),"input_port2");
 
308
        cbtext = gtk_combo_box_get_active_text(combobox);
 
309
        if (port1 && host && port2 && cbtext!=NULL) {
 
310
                if (strcmp(cbtext,"dynamic")==0) {
 
311
                        //gtk_entry_set_text(GTK_ENTRY(port1),"");
 
312
                        gtk_entry_set_text(GTK_ENTRY(host),"n/a");
 
313
                        gtk_entry_set_text(GTK_ENTRY(port2),"n/a");
 
314
                        gtk_editable_set_editable(GTK_EDITABLE(host),FALSE);
 
315
                        gtk_editable_set_editable(GTK_EDITABLE(port2),FALSE);
 
316
                } else {
 
317
                        if (strcmp(gtk_entry_get_text(GTK_ENTRY(host)),"n/a")==0) {
 
318
                                //gtk_entry_set_text(GTK_ENTRY(port1),"");
 
319
                                gtk_entry_set_text(GTK_ENTRY(host),"");
 
320
                                gtk_entry_set_text(GTK_ENTRY(port2),"");
 
321
                                gtk_editable_set_editable(GTK_EDITABLE(host),TRUE);
 
322
                                gtk_editable_set_editable(GTK_EDITABLE(port2),TRUE);
 
323
                        }
 
324
                }
 
325
        }
 
326
}
 
327
 
 
328
void docklet_clicked(int buttontype) {
 
329
        extern GtkWidget *maindialog;
 
330
        static GtkWidget *menu = NULL;
 
331
        
 
332
        if (menu) {
 
333
                gtk_widget_destroy(menu);
 
334
        }
 
335
        
 
336
        switch (buttontype) {
 
337
                case 1:
 
338
                        //left mouse click
 
339
                        if (GTK_WIDGET_VISIBLE(maindialog)) {
 
340
                                //hide the main dialog
 
341
                                gtk_widget_hide(maindialog);
 
342
                        } else {
 
343
                                //show the dialog again
 
344
                                gtk_widget_show(maindialog);
 
345
                        }
 
346
                        break;
 
347
                case 2:
 
348
                        //middle mouse click
 
349
                        break;
 
350
                case 3:
 
351
                        //right mouse click
 
352
                        menu = gstm_create_dockletmenu();
 
353
                        gtk_widget_show_all(menu);
 
354
                        gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
 
355
                                                        docklet_x11_position_menu,
 
356
                                                        NULL, 0, gtk_get_current_event_time());
 
357
                        break;
 
358
        }
 
359
}
 
360
 
 
361
void
 
362
on_btn_redir_edit_clicked              (GtkButton       *button,                                        gpointer         user_data)
 
363
{
 
364
        GtkWidget *w;
 
365
        GtkTreeSelection *s;
 
366
        gint selid=-1,typeid=0;
 
367
        extern GtkWidget *prop;
 
368
        GtkWidget *t;
 
369
        GtkWidget *tun;
 
370
        GtkTreeModel *m;
 
371
        GtkTreeIter i;
 
372
        gchar *type,*port1,*host,*port2;
 
373
        if (w = lookup_widget(GTK_WIDGET(button),"redirlist")) {
 
374
                s = gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
 
375
                if (gtk_tree_selection_count_selected_rows(s)>0) {
 
376
                        selid=gstm_interface_selection2id(s,COL_RID);
 
377
                }
 
378
        }
 
379
        if (selid>-1 && gtk_tree_selection_get_selected(s,&m,&i)) {
 
380
                tun = create_tundialog();
 
381
                /* some dialog init */
 
382
                gtk_window_set_transient_for(GTK_WINDOW(tun),GTK_WINDOW(prop));
 
383
                gtk_window_set_title(GTK_WINDOW(tun),"Edit redirection");
 
384
                /* get values from the listselection */
 
385
                gtk_tree_model_get (m, &i, COL_TYPE, &type, -1);
 
386
                gtk_tree_model_get (m, &i, COL_PORT1, &port1, -1);
 
387
                gtk_tree_model_get (m, &i, COL_HOST, &host, -1);
 
388
                gtk_tree_model_get (m, &i, COL_PORT2, &port2, -1);
 
389
                /* put type into the dialog */
 
390
                if (strcmp(type,"remote")==0) {
 
391
                        typeid=1;
 
392
                } else if (strcmp(type,"dynamic")==0) {
 
393
                        typeid=2;
 
394
                }
 
395
                if (t=lookup_widget(GTK_WIDGET(tun),"choice_type")) {
 
396
                        gtk_combo_box_set_active(GTK_COMBO_BOX(t),typeid);
 
397
                }
 
398
                /* put port1 into the dialog */
 
399
                if (t=lookup_widget(GTK_WIDGET(tun),"input_port1")) {
 
400
                        gtk_entry_set_text(GTK_ENTRY(t),port1);
 
401
                }
 
402
                /* put host into the dialog */
 
403
                if (t=lookup_widget(GTK_WIDGET(tun),"input_host")) {
 
404
                        gtk_entry_set_text(GTK_ENTRY(t),host);
 
405
                }
 
406
                /* put port2 into the dialog */
 
407
                if (t=lookup_widget(GTK_WIDGET(tun),"input_port2")) {
 
408
                        gtk_entry_set_text(GTK_ENTRY(t),port2);
 
409
                }
 
410
                /* run the dialog */
 
411
                redir_addedit(button,tun,selid);
 
412
                gtk_widget_destroy(tun);
 
413
        }
 
414
}
 
415
 
 
416
void
 
417
on_dockletmenu_quit_activate           (GtkMenuItem     *menuitem,
 
418
                                        gpointer         user_data) {
 
419
        gstm_terminate();
 
420
}
 
421
void
 
422
on_dockletmenu_toggle_activate           (GtkMenuItem     *menuitem,
 
423
                                        gpointer         user_data) {
 
424
        docklet_clicked(1);
 
425
}
 
426
void
 
427
on_dockletmenu_tunnel_activate           (GtkMenuItem     *menuitem,
 
428
                                        gpointer         user_data) {
 
429
        int id = (int)user_data;
 
430
        int selid=-1;
 
431
        gboolean active = gSTMtunnels[id]->active;
 
432
        GtkTreeSelection *s;
 
433
                                                                                        
 
434
        if (s=gstm_interface_get_selected_tunnel()) {
 
435
                selid = gstm_interface_selection2id(s,COL_ID);
 
436
        }
 
437
        if (!active) {
 
438
                gstm_interface_paint_row_id(id, !active);
 
439
                if (selid==id) gstm_interface_enablebuttons(!active);
 
440
                gstm_ssht_starttunnel(id);
 
441
        } else {
 
442
                gstm_ssht_stoptunnel(id);
 
443
                gstm_interface_paint_row_id(id, !active);
 
444
                if (selid==id) gstm_interface_enablebuttons(!active);
 
445
        }
 
446
}
 
447
 
 
448
void
 
449
on_btn_copy_clicked                  (GtkButton       *button,
 
450
                                        gpointer         user_data)
 
451
{
 
452
        extern GtkWidget *maindialog;
 
453
        GtkTreeSelection *s;
 
454
        int i,id=-1;
 
455
        char *newname=NULL;
 
456
        char *fname, *temp;
 
457
        struct sshtunnel *tun;
 
458
        GtkTreeIter    iter;
 
459
        GdkPixbuf *pixbuf_red;
 
460
        extern GtkListStore *tunnellist_store;
 
461
        
 
462
        if (s=gstm_interface_get_selected_tunnel()) {
 
463
                id = gstm_interface_selection2id(s,COL_ID);     
 
464
                if (gstm_interface_asknewname(&newname) == GTK_RESPONSE_OK) {
 
465
                        /* create new filename */
 
466
                        fname = (char *)gstm_name2filename(newname);
 
467
                        if (fname) {
 
468
                                /* expand the list */
 
469
                                gSTMtunnels = realloc(gSTMtunnels, (tunnelCount+1)*sizeof(struct sshtunnel *));
 
470
                                gSTMtunnels[tunnelCount] = malloc(sizeof(struct sshtunnel));
 
471
                                /* copy the tunneldata */
 
472
                                gSTMtunnels[tunnelCount]->name = malloc(strlen(newname)+1);
 
473
                                strcpy(gSTMtunnels[tunnelCount]->name, newname);
 
474
                                gSTMtunnels[tunnelCount]->login = malloc(strlen(gSTMtunnels[id]->login)+1);
 
475
                                strcpy(gSTMtunnels[tunnelCount]->login, gSTMtunnels[id]->login);
 
476
                                gSTMtunnels[tunnelCount]->host = malloc(strlen(gSTMtunnels[id]->host)+1);
 
477
                                strcpy(gSTMtunnels[tunnelCount]->host, gSTMtunnels[id]->host);
 
478
                                gSTMtunnels[tunnelCount]->port = malloc(strlen(gSTMtunnels[id]->port)+1);
 
479
                                strcpy(gSTMtunnels[tunnelCount]->port, gSTMtunnels[id]->port);
 
480
                                gSTMtunnels[tunnelCount]->privkey = malloc(strlen(gSTMtunnels[id]->privkey)+1);
 
481
                                strcpy(gSTMtunnels[tunnelCount]->privkey, gSTMtunnels[id]->privkey);
 
482
                                gSTMtunnels[tunnelCount]->autostart = gSTMtunnels[id]->autostart;
 
483
                                gSTMtunnels[tunnelCount]->active = FALSE;
 
484
                                gSTMtunnels[tunnelCount]->sshpid = 0;
 
485
                                gSTMtunnels[tunnelCount]->defcount = gSTMtunnels[id]->defcount;
 
486
                                gSTMtunnels[tunnelCount]->portredirs = NULL;
 
487
                                gSTMtunnels[tunnelCount]->fn = malloc(strlen(fname)+1);
 
488
                                strcpy(gSTMtunnels[tunnelCount]->fn, fname);
 
489
                                for (i=0; i<gSTMtunnels[id]->defcount; i++) {
 
490
                                        gSTMtunnels[tunnelCount]->portredirs = realloc(gSTMtunnels[tunnelCount]->portredirs, (i+1)*sizeof(struct portredir *));
 
491
                                        gSTMtunnels[tunnelCount]->portredirs[i] = malloc(sizeof(struct portredir));
 
492
                                        gSTMtunnels[tunnelCount]->portredirs[i]->type = malloc(strlen(gSTMtunnels[id]->portredirs[i]->type));
 
493
                                        strcpy(gSTMtunnels[tunnelCount]->portredirs[i]->type,gSTMtunnels[id]->portredirs[i]->type);
 
494
                                        gSTMtunnels[tunnelCount]->portredirs[i]->port1 = malloc(strlen(gSTMtunnels[id]->portredirs[i]->port1));
 
495
                                        strcpy(gSTMtunnels[tunnelCount]->portredirs[i]->port1,gSTMtunnels[id]->portredirs[i]->port1);
 
496
                                        gSTMtunnels[tunnelCount]->portredirs[i]->host = malloc(strlen(gSTMtunnels[id]->portredirs[i]->host));
 
497
                                        strcpy(gSTMtunnels[tunnelCount]->portredirs[i]->host,gSTMtunnels[id]->portredirs[i]->host);
 
498
                                        gSTMtunnels[tunnelCount]->portredirs[i]->port2 = malloc(strlen(gSTMtunnels[id]->portredirs[i]->port2));
 
499
                                        strcpy(gSTMtunnels[tunnelCount]->portredirs[i]->port2,gSTMtunnels[id]->portredirs[i]->port2);
 
500
                                }
 
501
                                /* save to file */
 
502
                                gstm_tunnel2file(gSTMtunnels[tunnelCount], gSTMtunnels[tunnelCount]->fn);
 
503
                                
 
504
                                //put in interface
 
505
                                pixbuf_red = create_pixbuf("gstm/red.xpm");
 
506
                                gtk_list_store_append (tunnellist_store, &iter);
 
507
                                gtk_list_store_set (tunnellist_store, &iter,
 
508
                                                                  COL_ACTIVE, pixbuf_red,
 
509
                                                                  COL_NAME, newname,
 
510
                                                                  COL_ID, tunnelCount,
 
511
                                                                  -1);
 
512
                                tunnelCount+=1;
 
513
                                //sort it again
 
514
                                gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tunnellist_store),
 
515
                                         COL_NAME,
 
516
                                         GTK_SORT_ASCENDING);           
 
517
                        } else {
 
518
                                gstm_interface_error("error making new filename");
 
519
                        }
 
520
                }
 
521
        } else {
 
522
                gstm_interface_error("error getting selected tunnel");
 
523
        }
 
524
        free(newname);
 
525
        gtk_window_set_focus(GTK_WINDOW(maindialog),lookup_widget(maindialog,"tunnellist"));
 
526
}