Adding some missing GPL headers - Alex
[terminatorX.git] / terminatorX / src / tX_panel.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2003  Alexander K├Ânig
4  
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9  
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14  
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20     
21 #include "tX_panel.h"
22 #include "tX_pbutton.h"
23 #include <string.h>
24 #include <stdio.h>
25
26 #define WID_DYN TRUE, TRUE, 0
27 #define WID_FIX FALSE, FALSE, 0
28
29 void tX_panel :: minimize(GtkWidget *w, tX_panel *p)
30 {
31         p->client_hidden=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p->minbutton));
32         
33         if (p->client_hidden)
34                 gtk_widget_hide(p->clientframe);
35         else
36                 gtk_widget_show(p->clientframe);
37                 
38         gboolean expand;
39         gboolean fill;
40         guint padding;
41         GtkPackType pack_type;
42                 
43         if (p->container) {
44                 gtk_box_query_child_packing(GTK_BOX(p->container), p->mainbox,
45                                                                         &expand, &fill, &padding, &pack_type);
46                 gtk_box_set_child_packing(GTK_BOX(p->container), p->mainbox,
47                                                                         expand, fill, padding, pack_type);
48                 gtk_container_check_resize(GTK_CONTAINER(p->container));                            
49         }
50 }
51
52 void tX_panel_make_label_bold(GtkWidget *widget) {
53         char label[128];        
54         sprintf(label, "<b>%s</b>", gtk_label_get_text(GTK_LABEL(widget)));
55         gtk_label_set_markup(GTK_LABEL (widget), label);
56 }
57
58 tX_panel :: tX_panel (const char *name, GtkWidget *par)
59 {
60         GtkWidget *pixmap;
61         client_hidden=0;
62         
63         container=par;
64         minbutton=gtk_toggle_button_new();
65         pixmap=tx_pixmap_widget(TX_ICON_MINIMIZE);
66         gtk_container_add (GTK_CONTAINER (minbutton), pixmap);
67         labelbutton=gtk_button_new_with_label(name);
68         gtk_container_foreach(GTK_CONTAINER(labelbutton), (GtkCallback) tX_panel_make_label_bold, NULL);
69         mainbox=gtk_vbox_new(FALSE, 0);
70         
71         topbox=gtk_hbox_new(FALSE, 0);
72         clientbox=gtk_vbox_new(FALSE, 0);
73         clientframe=gtk_frame_new((char *) NULL);
74         gtk_container_set_border_width( GTK_CONTAINER(clientframe), 0);
75         gtk_container_add(GTK_CONTAINER(clientframe), clientbox);
76         
77         gtk_box_pack_start(GTK_BOX(mainbox), topbox, WID_FIX);
78         gtk_box_pack_start(GTK_BOX(mainbox), clientframe, WID_FIX);
79         
80         gtk_box_pack_start(GTK_BOX(topbox), labelbutton, WID_DYN);
81         gtk_box_pack_start(GTK_BOX(topbox), minbutton, WID_FIX);
82         
83         gtk_widget_show(pixmap);
84         gtk_widget_show(labelbutton);
85         gtk_widget_show(minbutton);
86         gtk_widget_show(topbox);
87         gtk_widget_show(clientbox);
88         gtk_widget_show(clientframe);   
89         gtk_widget_show(mainbox);
90         
91         g_signal_connect(G_OBJECT(minbutton), "clicked", (GtkSignalFunc) tX_panel::minimize, (void *) this);
92 }
93
94 void tX_panel :: add_client_widget(GtkWidget *w)
95 {
96         gtk_box_pack_start(GTK_BOX(clientbox), w, WID_FIX);
97         gtk_widget_show(w);
98 }
99
100
101 tX_panel :: ~tX_panel()
102 {
103         gtk_widget_destroy(minbutton);
104         gtk_widget_destroy(labelbutton);
105         gtk_widget_destroy(clientbox);
106         gtk_widget_destroy(clientframe);
107         gtk_widget_destroy(topbox);
108         gtk_widget_destroy(mainbox);
109 }