summaryrefslogtreecommitdiffhomepage
path: root/mixgtk/mixgtk_wm.c
blob: 6534eea94bfd9268c5a16c48c7075be1830f09e0 (plain)
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
/* -*-c-*- -------------- mixgtk_wm.c :
 * Implementation of the functions declared in mixgtk_wm.h
 * ------------------------------------------------------------------
 * Copyright (C) 2001, 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
 *
 * 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 3 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.
 *
 */

#include <string.h>

#include "mixgtk_wm.h"

#include "mixgtk_config.h"
#include "mixgtk_device.h"
#include "mixgtk_mixvm.h"
#include "mixgtk_mixal.h"
#include "mixgtk_widgets.h"
#include "mixgtk_cmd_dispatcher.h"
#include "mixgtk.h"


typedef struct window_info_t_
{
  mixgtk_dialog_id_t dialog;
  GtkWidget *widget;
  GtkCheckMenuItem *menu;
  const gchar *menu_name;
  const gchar *config_key;
  gboolean detached;
  void (*detach) (void);
  void (*attach) (void);
} window_info_t_;

static const gchar *DETACH_YES_ = "Yes";
static const gchar *DETACH_NO_ = "No";
static GtkWidget *about_ = NULL;

static GtkContainer *mixvm_container_ = NULL;
static GtkContainer *mixal_container_ = NULL;
static GtkContainer *dev_container_ = NULL;

static GtkToolItem *attach_button_ = NULL;
static GtkToolItem *detach_button_ = NULL;

static const gchar *TB_MENU_NAME_ = "show_toolbars";
static GtkCheckMenuItem *tb_menu_ = NULL;
static GtkNotebook *notebook_ = NULL;

static mix_vm_t *vm_ = NULL;

static void init_info_ (void);
static void init_notebook_ (void);
static void init_dispatcher_ (void);
static void init_mixvm_ (void);
static void init_mixal_ (void);
static void init_dev_ (void);
static void init_signals_ (void);
static void init_visibility_ (void);
static void init_tb_ (void);
static void init_about_ (void);
static void init_autosave_ (void);
static void show_toolbars_ (gboolean show);
static void add_page_ (GtkWidget *w, mixgtk_window_id_t id);
static void mixvm_attach_ (void);
static void mixvm_detach_ (void);
static void mixal_attach_ (void);
static void mixal_detach_ (void);
static void dev_attach_ (void);
static void dev_detach_ (void);
static void update_attach_buttons_ (void);
static void on_tb_style_ (GtkMenuItem *w, gpointer style);
static void on_nb_switch_ (GtkNotebook *notebook, GtkWidget *page,
                           guint page_num, gpointer user_data);

static window_info_t_ infos_[] = {
  {MIXGTK_MIXVM_DIALOG, NULL, NULL, "detach_vm", "MIX.detach",
   FALSE, mixvm_detach_, mixvm_attach_},
  {MIXGTK_MIXAL_DIALOG, NULL, NULL, "detach_source", "MIXAL.detach",
   FALSE, mixal_detach_, mixal_attach_},
  {MIXGTK_DEVICES_DIALOG, NULL, NULL, "detach_dev", "Devices.detach",
   FALSE, dev_detach_, dev_attach_}
};

static size_t INF_NO_ = sizeof (infos_) / sizeof (infos_[0]);


gboolean
mixgtk_wm_init (void)
{
  gint k;

  init_info_ ();
  init_notebook_ ();
  init_dispatcher_ ();
  init_mixvm_ ();
  init_mixal_ ();
  init_dev_ ();
  init_tb_ ();

  for (k = 0; k < INF_NO_; ++k)
    {
      if (infos_[k].detached)
        mixgtk_wm_detach_window (k);
      else
        mixgtk_wm_attach_window (k);
    }

  init_about_ ();
  init_autosave_ ();
  init_visibility_ ();
  init_signals_ ();

  return TRUE;
}

void
mixgtk_wm_detach_window (mixgtk_window_id_t w)
{
  if (w < INF_NO_)
    {
      (*(infos_[w].detach)) ();
      infos_[w].detached = TRUE;
      gtk_check_menu_item_set_active (infos_[w].menu, TRUE);
      mixgtk_config_update (infos_[w].config_key, DETACH_YES_);
      if (infos_[w].widget != NULL) gtk_widget_show (infos_[w].widget);
      if (gtk_notebook_get_n_pages (notebook_) < 1)
        gtk_widget_hide (GTK_WIDGET (notebook_));
      gtk_widget_show (mixgtk_widget_factory_get_dialog (infos_[w].dialog));
      update_attach_buttons_ ();
    }
}

void
mixgtk_wm_attach_window (mixgtk_window_id_t w)
{
  if (w < INF_NO_)
    {
      gint page = gtk_notebook_page_num (notebook_, infos_[w].widget);

      gtk_widget_hide (mixgtk_widget_factory_get_dialog (infos_[w].dialog));

      if (page < 0) (*(infos_[w].attach)) ();

      infos_[w].detached = FALSE;
      gtk_check_menu_item_set_active (infos_[w].menu, FALSE);
      mixgtk_config_update (infos_[w].config_key, DETACH_NO_);
      if (gtk_notebook_get_n_pages (notebook_) == 1)
        gtk_widget_show (GTK_WIDGET (notebook_));
      update_attach_buttons_ ();
    }
}



/* callbacks */
void
on_detach_clicked (GtkWidget *ignored)
{
  gint page = gtk_notebook_get_current_page (notebook_);
  if (page >= 0)
    {
      gint k;
      GtkWidget *w = gtk_notebook_get_nth_page (notebook_, page);

      for (k = 0; k < INF_NO_; ++k)
        if (infos_[k].widget == w) mixgtk_wm_detach_window (k);
    }
}

void
on_attach_all_clicked ()
{
  gint k;
  for (k = INF_NO_; k > 0; --k)
    if (infos_[k - 1].detached) mixgtk_wm_attach_window (k - 1);
}

void
on_attach_toggled (GtkCheckMenuItem *item)
{
  gint k;
  for (k = 0; k < INF_NO_; ++k)
    if (item == infos_[k].menu) break;
  g_return_if_fail (k < INF_NO_);
  if (item->active) mixgtk_wm_detach_window (k);
  else mixgtk_wm_attach_window (k);
  mixgtk_config_update (infos_[k].config_key,
                        (item->active)? DETACH_YES_ : DETACH_NO_);
}

void
on_window_hide (GtkWidget *w)
{
  gint k;
  for (k = 0; k < INF_NO_; ++k)
    if (w == mixgtk_widget_factory_get_dialog (infos_[k].dialog)) break;
  g_return_if_fail (k < INF_NO_);
  mixgtk_wm_attach_window (k);
}

void
on_show_toolbars_toggled (GtkCheckMenuItem *item)
{
  if (item->active != mixgtk_config_show_toolbars ())
    show_toolbars_ (item->active);
}

void
on_widget_attach (GtkWidget *ign, gpointer id)
{
  mixgtk_wm_attach_window (GPOINTER_TO_INT (id));
}

/* about box */
void
on_about_activate (GtkWidget *w, gpointer data)
{
  if (!about_) init_about_ ();
  gtk_widget_show (about_);
}

void
on_about_clicked (GtkWidget *w)
{
  if (about_) gtk_widget_hide (about_);
}



static void
init_info_ (void)
{
  gint k;
  for (k = 0; k < INF_NO_; ++k)
    {
      const gchar *txt;

      infos_[k].menu =
        GTK_CHECK_MENU_ITEM
        (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN,
                                                  infos_[k].menu_name));
      g_assert (infos_[k].menu != NULL);
      txt = mixgtk_config_get (infos_[k].config_key);
      infos_[k].detached = txt && !g_ascii_strcasecmp (txt, DETACH_YES_);
    }
}

static void
init_notebook_ (void)
{
  notebook_ =
    GTK_NOTEBOOK (mixgtk_widget_factory_get (MIXGTK_MAIN,
                                             MIXGTK_WIDGET_NOTEBOOK));
  g_assert (notebook_ != NULL);
  gtk_widget_show (GTK_WIDGET (notebook_));
}

static void
add_page_ (GtkWidget *page, mixgtk_window_id_t id)
{
  static const gchar *LABELS[] = {
    N_("_Virtual machine"), N_("_Source"), N_("_Devices")
  };

  gint p = 0;

  g_assert (page != NULL);
  g_assert (id < INF_NO_);
  g_assert (notebook_ != NULL);

  if (id > MIXGTK_MIXVM_WINDOW)
    {
      if (id == MIXGTK_DEVICES_WINDOW)
        p = gtk_notebook_get_n_pages (notebook_);
      else
        p = infos_[MIXGTK_MIXVM_WINDOW].detached ? 0 : 1;
    }

  gtk_notebook_insert_page (notebook_, page,
                            gtk_label_new_with_mnemonic (LABELS[id]),
                            p);
  gtk_notebook_set_current_page (notebook_, p);
  gtk_widget_show (page);
  gtk_widget_show (GTK_WIDGET (notebook_));
}

static void
init_signals_ (void)
{
  gint k;
  for (k = 0; k < INF_NO_; ++k)
    {
      GObject *dialog =
        G_OBJECT (mixgtk_widget_factory_get_dialog (infos_[k].dialog));

      GObject *button =
        G_OBJECT (mixgtk_widget_factory_get (infos_[k].dialog,
                                             MIXGTK_WIDGET_ATTACH_BUTTON));

      g_assert (dialog != NULL);
      g_assert (button != NULL);

      g_signal_connect (button, "clicked",
                        G_CALLBACK (on_widget_attach), GINT_TO_POINTER (k));
      g_signal_connect (dialog, "destroy",
                        G_CALLBACK (on_window_hide), NULL);
      g_signal_connect (dialog, "destroy_event",
                        G_CALLBACK (on_window_hide), NULL);
      g_signal_connect (dialog, "delete_event",
                        G_CALLBACK (on_window_hide), NULL);
      g_signal_connect (G_OBJECT (infos_[k].menu), "toggled",
                        G_CALLBACK (on_attach_toggled), NULL);
    }

}

static void
init_visibility_ (void)
{
  gint k;
  for (k = 0; k < INF_NO_; ++k)
    if (infos_[k].detached)
      gtk_widget_show (mixgtk_widget_factory_get_dialog (infos_[k].dialog));

  if (gtk_notebook_get_n_pages (notebook_) > 0)
    gtk_notebook_set_current_page (notebook_, 0);

  gtk_widget_show (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN));
}

static void
init_dispatcher_ (void)
{
  if (!mixgtk_cmd_dispatcher_init (MIXGTK_MAIN))
    g_assert (FALSE);
  vm_ = mixgtk_cmd_dispatcher_get_vm ();
  g_assert (vm_ != NULL);
}

static void
init_mixvm_ (void)
{
  GtkContainer *vm =
    GTK_CONTAINER
    (mixgtk_widget_factory_get (MIXGTK_MIXVM_DIALOG, MIXGTK_WIDGET_MIXVM));

  mixvm_container_ =
    GTK_CONTAINER (mixgtk_widget_factory_get (MIXGTK_MIXVM_DIALOG,
                                              MIXGTK_WIDGET_MIXVM_CONTAINER));

  g_assert (mixvm_container_ != NULL);

  g_assert (vm != NULL);
  g_object_ref (G_OBJECT (vm));
  infos_[MIXGTK_MIXVM_WINDOW].widget = GTK_WIDGET (vm);

  mixgtk_mixvm_init (vm_);
  mixgtk_mixvm_update_vm_widgets ();

  gtk_widget_show (GTK_WIDGET (vm));

}

static void
init_mixal_ (void)
{
  GtkWidget *page = gtk_scrolled_window_new (NULL, NULL);
  GtkWidget *mixal = mixgtk_mixal_init (vm_);

  g_assert (page != NULL);
  g_assert (mixal != NULL);

  g_object_ref (page);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (page),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_container_add (GTK_CONTAINER (page), mixal);

  infos_[MIXGTK_MIXAL_WINDOW].widget = page;

  mixal_container_ =
    GTK_CONTAINER (mixgtk_widget_factory_get (MIXGTK_MIXAL_DIALOG,
                                              MIXGTK_WIDGET_MIXAL_CONTAINER));

  g_assert (mixal_container_ != NULL);

  gtk_container_add (mixal_container_, page);

  gtk_widget_show (mixal);
  gtk_widget_show (page);
  gtk_widget_show (GTK_WIDGET (mixal_container_));
}

static void
init_dev_ (void)
{
  GtkWidget *page = gtk_scrolled_window_new (NULL, NULL);
  GtkWidget *devs = mixgtk_device_init (vm_);

  g_assert (page != NULL);
  g_assert (devs != NULL);

  g_object_ref (page);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (page),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (page), devs);

  infos_[MIXGTK_DEVICES_WINDOW].widget = page;

  dev_container_ =
    GTK_CONTAINER (mixgtk_widget_factory_get (MIXGTK_DEVICES_DIALOG,
                                              MIXGTK_WIDGET_DEV_CONTAINER));

  g_assert (dev_container_ != NULL);

  gtk_container_add (dev_container_, page);

  gtk_widget_show (devs);
  gtk_widget_show (page);
}

static void
init_tb_ (void)
{
  gchar *names[4];
  gint k;
  gint tb_style = mixgtk_config_tb_style ();

  tb_menu_ = GTK_CHECK_MENU_ITEM
    (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN,
  					      TB_MENU_NAME_));
  g_assert (tb_menu_ != NULL);

  gtk_check_menu_item_set_active (tb_menu_, mixgtk_config_show_toolbars ());
  show_toolbars_ (mixgtk_config_show_toolbars ());

  g_signal_connect (G_OBJECT (tb_menu_), "toggled",
                    G_CALLBACK (on_show_toolbars_toggled), NULL);

  attach_button_ = GTK_TOOL_ITEM
    (mixgtk_widget_factory_get (MIXGTK_MAIN, MIXGTK_WIDGET_ATTACH_BUTTON));
  detach_button_ = GTK_TOOL_ITEM
    (mixgtk_widget_factory_get (MIXGTK_MAIN, MIXGTK_WIDGET_DETACH_BUTTON));

  g_assert (attach_button_);
  g_assert (detach_button_);

  names[GTK_TOOLBAR_ICONS] = "tb_style_icons";
  names[GTK_TOOLBAR_TEXT] = "tb_style_labels";
  names[GTK_TOOLBAR_BOTH] = "tb_style_both";
  names[GTK_TOOLBAR_BOTH_HORIZ] = "tb_style_bothh";

  for (k = 0; k < 4; ++k)
    {
      GtkWidget *item =
        mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, names[k]);
      g_signal_connect (G_OBJECT (item),
                        "activate",
                        G_CALLBACK (on_tb_style_), GUINT_TO_POINTER (k));
      if (k == tb_style)
        {
          gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
        }
    }
}

static void
on_tb_style_ (GtkMenuItem *w, gpointer style)
{
  static const gchar *TB_NAME = "main_toolbar";
  static const gchar *TB_DNAME = "dlg_toolbar";

  guint ui_style = GPOINTER_TO_UINT (style);
  gint k;

  GtkToolbar *tb = GTK_TOOLBAR
    (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, TB_NAME));
  gtk_toolbar_set_style (tb, ui_style);

  for (k = 0; k < INF_NO_; ++k)
    {
      GtkToolbar *tb = GTK_TOOLBAR
        (mixgtk_widget_factory_get_child_by_name (infos_[k].dialog, TB_DNAME));
      gtk_toolbar_set_style (tb, ui_style);
    }

  mixgtk_config_set_tb_style (ui_style);
}

static void
show_toolbars_ (gboolean show)
{
  static const gchar *HANDLE_NAME = "tb_handle";

  gint k;

  GtkWidget *handle =
    mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, HANDLE_NAME);

  if (show)
    gtk_widget_show (handle);
  else
    gtk_widget_hide (handle);

  for (k = 0; k < INF_NO_; ++k)
    {
      GtkWidget *hd =
        mixgtk_widget_factory_get_child_by_name (infos_[k].dialog, HANDLE_NAME);
      if (show) gtk_widget_show (hd); else gtk_widget_hide (hd);
    }

  mixgtk_config_set_show_toolbars (show);
}

static void
init_autosave_ (void)
{
#define AUTOSAVE_ITEM_ "save_on_exit"

  GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM
    (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, AUTOSAVE_ITEM_));
  if (item)
    {
      gtk_check_menu_item_set_active (item, mixgtk_config_is_autosave ());
    }
}

static void
init_about_ (void)
{
#define VERSION_LABEL_ "version_label"
#define GPL_TEXT_ "gpl_text"
  GtkWidget *label;
  about_ = mixgtk_widget_factory_get_dialog (MIXGTK_ABOUT_DIALOG);
  g_assert (about_ != NULL);
  label = mixgtk_widget_factory_get_child_by_name (MIXGTK_ABOUT_DIALOG,
						   VERSION_LABEL_);
  g_assert (label != NULL);
  gtk_label_set_text (GTK_LABEL (label), VERSION);
  gtk_widget_show (label);
}

static void
mixvm_attach_ (void)
{
  gtk_container_remove (mixvm_container_, infos_[MIXGTK_MIXVM_WINDOW].widget);
  add_page_ (infos_[MIXGTK_MIXVM_WINDOW].widget, MIXGTK_MIXVM_WINDOW);
}

static void
mixvm_detach_ (void)
{
  gtk_widget_reparent (infos_[MIXGTK_MIXVM_WINDOW].widget,
                       GTK_WIDGET (mixvm_container_));
}

static void
mixal_attach_ (void)
{
  static GtkStatusbar *stat = NULL;

  if (stat == NULL)
    {
      stat =
        GTK_STATUSBAR
        (mixgtk_widget_factory_get (MIXGTK_MAIN, MIXGTK_WIDGET_STATUSBAR));
      g_assert (stat);

      g_signal_connect (G_OBJECT (notebook_), "switch-page",
                        G_CALLBACK (on_nb_switch_), NULL);
    }

  mixgtk_mixal_reparent (stat);
  gtk_container_remove (mixal_container_, infos_[MIXGTK_MIXAL_WINDOW].widget);
  add_page_ (infos_[MIXGTK_MIXAL_WINDOW].widget, MIXGTK_MIXAL_WINDOW);
}

static void
mixal_detach_ (void)
{
  static GtkStatusbar *stat = NULL;

  if (stat == NULL)
    {
      stat =
        GTK_STATUSBAR
        (mixgtk_widget_factory_get (MIXGTK_MIXAL_DIALOG,
                                    MIXGTK_WIDGET_MIXAL_STATUSBAR));
      g_assert (stat);
    }

  mixgtk_mixal_reparent (stat);
  gtk_widget_reparent (infos_[MIXGTK_MIXAL_WINDOW].widget,
                       GTK_WIDGET (mixal_container_));
}

static void
dev_attach_ (void)
{
  gtk_container_remove (dev_container_, infos_[MIXGTK_DEVICES_WINDOW].widget);
  add_page_ (infos_[MIXGTK_DEVICES_WINDOW].widget, MIXGTK_DEVICES_WINDOW);
}

static void
dev_detach_ (void)
{
  gtk_widget_reparent (infos_[MIXGTK_DEVICES_WINDOW].widget,
                       GTK_WIDGET (dev_container_));
}

static void
on_nb_switch_ (GtkNotebook *notebook, GtkWidget *page,
               guint page_num, gpointer user_data)
{
  if (!(infos_[MIXGTK_MIXAL_WINDOW].detached)
      && (page != infos_[MIXGTK_MIXAL_WINDOW].widget))
    mixgtk_mixal_pop_status ();
}

static void
update_attach_buttons_ (void)
{
  gint k;
  gboolean wants_attach = FALSE;
  gboolean wants_detach = FALSE;

  g_assert (attach_button_);
  g_assert (detach_button_);

  for (k = 0; k < INF_NO_; ++k)
    {
      wants_attach = wants_attach || infos_[k].detached;
      wants_detach = wants_detach || !infos_[k].detached;
    }

  gtk_tool_item_set_visible_horizontal (attach_button_, wants_attach);
  gtk_tool_item_set_visible_vertical (attach_button_, wants_attach);
  gtk_tool_item_set_visible_horizontal (detach_button_, wants_detach);
  gtk_tool_item_set_visible_vertical (detach_button_, wants_detach);
}