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
|
/*
terminatorX - realtime audio scratching software
Copyright (C) 1999-2016 Alexander König
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, see <http://www.gnu.org/licenses/>.
*/
#include "tX_panel.h"
#include "tX_pbutton.h"
#include <string.h>
#include <stdio.h>
#define WID_DYN TRUE, TRUE, 0
#define WID_FIX FALSE, FALSE, 0
void tX_panel :: minimize(GtkWidget *w, tX_panel *p)
{
if (!p->client_hidden) {
gtk_widget_hide(p->pixmap_min);
gtk_widget_show(p->pixmap_max);
gtk_widget_hide(p->clientframe);
p->client_hidden=1;
} else {
gtk_widget_hide(p->pixmap_max);
gtk_widget_show(p->pixmap_min);
gtk_widget_show(p->clientframe);
p->client_hidden=0;
}
gboolean expand;
gboolean fill;
guint padding;
GtkPackType pack_type;
if (p->container) {
gtk_box_query_child_packing(GTK_BOX(p->container), p->mainbox,
&expand, &fill, &padding, &pack_type);
gtk_box_set_child_packing(GTK_BOX(p->container), p->mainbox,
expand, fill, padding, pack_type);
gtk_container_check_resize(GTK_CONTAINER(p->container));
}
}
void tX_panel_make_label_bold(GtkWidget *widget) {
char label[128];
sprintf(label, "<b>%s</b>", gtk_label_get_text(GTK_LABEL(widget)));
gtk_label_set_markup(GTK_LABEL (widget), label);
}
tX_panel :: tX_panel (const char *name, GtkWidget *par)
{
client_hidden=0;
container=par;
minbutton=gtk_button_new();
pixmap_min=tx_pixmap_widget(MINIMIZE);
pixmap_max=tx_pixmap_widget(MAXIMIZE);
labelbutton=gtk_label_new(name);
gtk_widget_set_halign(labelbutton, GTK_ALIGN_START);
tX_panel_make_label_bold(labelbutton);
button_box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_pack_start(GTK_BOX(button_box), pixmap_min, WID_FIX);
gtk_box_pack_start(GTK_BOX(button_box), pixmap_max, WID_FIX);
gtk_box_pack_start(GTK_BOX(button_box), labelbutton, WID_DYN);
gtk_container_set_border_width(GTK_CONTAINER(button_box), 2);
gtk_container_add (GTK_CONTAINER (minbutton), button_box);
mainbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
topbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
clientbox=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
clientframe=gtk_frame_new((char *) NULL);
gtk_container_set_border_width( GTK_CONTAINER(clientframe), 0);
gtk_container_add(GTK_CONTAINER(clientframe), clientbox);
gtk_box_pack_start(GTK_BOX(mainbox), topbox, WID_FIX);
gtk_box_pack_start(GTK_BOX(mainbox), clientframe, WID_FIX);
gtk_box_pack_start(GTK_BOX(topbox), minbutton, WID_DYN);
gtk_widget_show(pixmap_min);
gtk_widget_show(button_box);
gtk_widget_show(labelbutton);
gtk_widget_show(minbutton);
gtk_widget_show(topbox);
gtk_widget_show(clientbox);
gtk_widget_show(clientframe);
gtk_widget_show(mainbox);
g_signal_connect(G_OBJECT(minbutton), "clicked", (GCallback) tX_panel::minimize, (void *) this);
}
void tX_panel :: add_client_widget(GtkWidget *w)
{
gtk_box_pack_start(GTK_BOX(clientbox), w, WID_FIX);
gtk_widget_show(w);
}
tX_panel :: ~tX_panel()
{
gtk_widget_destroy(minbutton);
gtk_widget_destroy(clientbox);
gtk_widget_destroy(clientframe);
gtk_widget_destroy(topbox);
gtk_widget_destroy(mainbox);
}
|