Use theme icons instead of the old clunky ones
[terminatorX.git] / src / tX_pbutton.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2016  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, see <http://www.gnu.org/licenses/>.
17  
18     File: tX_pbutton.cc
19  
20     Description: This implements the pixmaped buttons - based on
21                  gtk+ tutorial.
22
23 */
24
25 #include <gtk/gtk.h>
26 #include <gdk-pixbuf/gdk-pixbuf.h>
27 #include <stdio.h>
28 #include "tX_mastergui.h"
29 #include "tX_pbutton.h"
30 #include "tX_global.h"
31
32 #include "icons/tX_icons_resources.c"
33
34 const char* tx_icons[ALL_ICONS];
35
36 int tx_icon_size=20;
37
38 void tx_icons_init(int size) 
39 {
40         tx_icon_size=size;
41
42         tx_icons[AUDIOENGINE] = "audio-speakers-symbolic";
43         tx_icons[POWER] = "system-shutdown-symbolic";
44         tx_icons[GRAB] = "input-mouse-symbolic";        
45
46         tx_icons[SEQUENCER] = "emblem-music-symbolic";
47         
48         tx_icons[PLAY] = "media-playback-start-symbolic";
49         tx_icons[STOP] = "media-playback-stop-symbolic";
50         tx_icons[RECORD] = "media-record-symbolic";
51         tx_icons[MIN_AUDIO] = "audio-x-generic-symbolic";
52         tx_icons[MIN_CONTROL] = "multimedia-volume-control-symbolic";
53         
54         tx_icons[MINIMIZE] = "go-top-symbolic";
55         tx_icons[MAXIMIZE] = "go-bottom-symbolic";
56         tx_icons[FX_UP] = "go-up-symbolic";
57         tx_icons[FX_DOWN] = "go-down-symbolic";
58         tx_icons[FX_CLOSE] = "window-close-symbolic";
59         tx_icons[MINIMIZE_PANEL] = "window-minimize-symbolic";
60 }
61
62 GtkWidget *tx_pixmap_widget(tX_icon id)
63 {
64         return gtk_image_new_from_icon_name (tx_icons[id], GTK_ICON_SIZE_SMALL_TOOLBAR);
65 }
66
67 GtkWidget *tx_xpm_label_box(tX_icon id, const gchar *label_text, GtkWidget **labelwidget)
68 {
69         GtkWidget *box1;
70         GtkWidget *label;
71         GtkWidget *pixmapwid;
72         
73         switch (globals.button_type) {
74                 case BUTTON_TYPE_TEXT:
75                         label = gtk_label_new(label_text);
76                         gtk_widget_show(label);
77                         if (labelwidget!=NULL) *labelwidget=label;
78                         return label;
79                         break;
80                 case BUTTON_TYPE_ICON:
81                         pixmapwid=tx_pixmap_widget(id);
82                         gtk_widget_show(pixmapwid);
83                         return pixmapwid;
84                         break;
85                 default:
86                         box1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
87                         gtk_container_set_border_width (GTK_CONTAINER (box1), 2);
88                         pixmapwid=tx_pixmap_widget(id);
89                         gtk_box_pack_start (GTK_BOX (box1), pixmapwid, FALSE, FALSE, 0);
90                         gtk_widget_show(pixmapwid);
91                         label = gtk_label_new (label_text);
92                         gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
93                         gtk_widget_show(label); 
94                         if (labelwidget!=NULL)  *labelwidget=label;
95                         return box1;
96         }    
97 }
98
99 extern GtkWidget *tx_xpm_button_new(tX_icon id, const char *label, int toggle, GtkWidget **labelwidget)
100 {
101         GtkWidget *box;
102         GtkWidget *button;
103         
104         if (toggle) button=gtk_toggle_button_new();
105         else button=gtk_button_new();
106         
107         box=tx_xpm_label_box(id, label, labelwidget);
108         gtk_widget_show(box);
109         gtk_container_add (GTK_CONTAINER (button), box);                
110         
111         return(button);
112 }