~maza-team/remote-apps/panel.gtest-infrastructure

« back to all changes in this revision

Viewing changes to src/cc-remoteapp-panel.c

  • Committer: Ying-Chun Liu (PaulLiu)
  • Date: 2012-08-17 05:45:43 UTC
  • Revision ID: grandpaul@gmail.com-20120817054543-toyljjmycg6dgw6n
Add more callbacks.
UI interaction.

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
  serverlist=NULL;
195
195
}
196
196
 
197
 
static void treeview_selection1_changed_cb(GtkTreeSelection *treeselection,
 
197
static void treeview_selection_serverlist_changed_cb(
 
198
                                           GtkTreeSelection *treeselection,
198
199
                                           gpointer user_data) {
199
200
  GtkTreeModel *model=NULL;
200
201
  GtkTreeIter iter,iter1;
234
235
 
235
236
}
236
237
 
 
238
static void treeview_selection_uccs_changed_cb(
 
239
                                           GtkTreeSelection *treeselection,
 
240
                                           gpointer user_data) {
 
241
  GtkTreeModel *model=NULL;
 
242
  GtkTreeIter iter,iter1;
 
243
  gboolean result1;
 
244
  gchar *str=NULL;
 
245
  CcRemoteappPanel *self;
 
246
  int row;
 
247
  GObject *remoteappserver;
 
248
  GtkWidget *entry;
 
249
 
 
250
  self = CC_REMOTEAPP_PANEL (user_data);
 
251
 
 
252
  if (self->priv->debug)
 
253
    g_printf("%s:%d %s()\n",__FILE__,__LINE__,__func__);
 
254
 
 
255
  result1 = gtk_tree_selection_get_selected (treeselection, &model, &iter);
 
256
  if (!result1) {
 
257
    entry = WID("button_connect");
 
258
    gtk_widget_set_sensitive(entry, FALSE);
 
259
    return;
 
260
  }
 
261
 
 
262
  if (self->priv->debug)
 
263
    g_printf("%s:%d %s()\n",__FILE__,__LINE__,__func__);
 
264
 
 
265
  gtk_tree_model_get(model, &iter, 0, &str, -1);
 
266
 
 
267
  if (self->priv->debug)
 
268
    g_printf("%s:%d %s() selected %s\n",__FILE__,__LINE__,__func__,str);
 
269
 
 
270
  entry = WID("button_connect");
 
271
  gtk_widget_set_sensitive(entry, TRUE);
 
272
}
 
273
 
 
274
static void button_login_clicked_cb(GtkButton *button, gpointer   user_data)
 
275
{
 
276
  CcRemoteappPanel *self;
 
277
  const char *username, *password;
 
278
  GtkWidget *widget;
 
279
 
 
280
  self = CC_REMOTEAPP_PANEL (user_data);
 
281
  widget = GTK_WIDGET(gtk_builder_get_object (self->priv->builder,"entry_email"));
 
282
  username = gtk_entry_get_text(GTK_ENTRY(widget));
 
283
 
 
284
  widget = GTK_WIDGET(gtk_builder_get_object (self->priv->builder,"entry_password"));
 
285
  password = gtk_entry_get_text(GTK_ENTRY(widget));
 
286
 
 
287
  if (self->priv->debug)
 
288
    g_printf("%s:%d %s() e-mail: %s password: %s\n",__FILE__,__LINE__,__func__,username,password);
 
289
 
 
290
  /* FIXME: Authentication here */
 
291
 
 
292
  /* Assume login success */
 
293
  widget = GTK_WIDGET(gtk_builder_get_object (self->priv->builder,"label_uccs"));
 
294
  gtk_widget_show(widget);
 
295
  widget = GTK_WIDGET(gtk_builder_get_object (self->priv->builder,"treeview_uccs"));
 
296
  gtk_widget_show(widget);
 
297
  gtk_widget_hide(GTK_WIDGET(button));
 
298
 
 
299
}
 
300
 
 
301
static void button_connect_clicked_cb(GtkButton *button, gpointer   user_data)
 
302
{
 
303
  CcRemoteappPanel *self;
 
304
  const char *name;
 
305
  GtkWidget *widget;
 
306
  GtkTreeView *treeview1;
 
307
  GtkTreeSelection *treeselection;
 
308
  GtkTreeModel *model=NULL;
 
309
  GtkTreeIter iter;
 
310
 
 
311
  self = CC_REMOTEAPP_PANEL (user_data);
 
312
 
 
313
  treeview1 = GTK_TREE_VIEW(gtk_builder_get_object (self->priv->builder,"treeview_uccs"));
 
314
  treeselection = gtk_tree_view_get_selection(treeview1);
 
315
  if (!gtk_tree_selection_get_selected(treeselection, &model, &iter)) {
 
316
    return;
 
317
  }
 
318
  
 
319
  gtk_tree_model_get(model, &iter, 0, &name, -1);
 
320
  if (name && self->priv->debug) {
 
321
    g_printf("%s:%d %s() connect %s\n",__FILE__,__LINE__,__func__,name);
 
322
  }
 
323
 
 
324
 
 
325
}
 
326
 
237
327
static void button_add_clicked_cb(GtkButton *button, gpointer   user_data)
238
328
{
239
329
  const char *protocol, *address, *username, *password, *domain;
456
546
{
457
547
        GObject *widget = NULL;
458
548
 
459
 
        widget = G_OBJECT(gtk_builder_get_object (self->priv->builder,"treeview-selection1"));
460
 
        g_signal_connect(widget, "changed", G_CALLBACK(treeview_selection1_changed_cb), self);
461
 
 
 
549
        widget = G_OBJECT(gtk_builder_get_object (self->priv->builder,"treeview-selection_serverlist"));
 
550
        g_signal_connect(widget, "changed", G_CALLBACK(treeview_selection_serverlist_changed_cb), self);
 
551
 
 
552
        widget = G_OBJECT(gtk_builder_get_object (self->priv->builder,"button_login"));
 
553
        g_signal_connect(widget, "clicked", G_CALLBACK(button_login_clicked_cb), self);
 
554
 
 
555
        widget = G_OBJECT(gtk_builder_get_object (self->priv->builder,"button_connect"));
 
556
        g_signal_connect(widget, "clicked", G_CALLBACK(button_connect_clicked_cb), self);
 
557
 
 
558
        widget = G_OBJECT(gtk_builder_get_object (self->priv->builder,"treeview-selection_uccs"));
 
559
        g_signal_connect(widget, "changed", G_CALLBACK(treeview_selection_uccs_changed_cb), self);
462
560
 
463
561
}
464
562
 
515
613
        cc_signal_connect(self);
516
614
 
517
615
        gtk_widget_show_all (GTK_WIDGET (self));
518
 
 
 
616
        widget = WID ("label_uccs");
 
617
        gtk_widget_hide(widget);
 
618
        widget = WID ("treeview_uccs");
 
619
        gtk_widget_hide(widget);
519
620
        if (self->priv->debug)
520
621
          g_printf("%s:%d %s()\n",__FILE__,__LINE__,__func__);
521
622
}