Drop the old SVGs that have been replaced with the stock versions
[terminatorX.git] / src / tX_pbutton.cc
1 /*
2     terminatorX - realtime audio scratching software
3     Copyright (C) 1999-2020  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 const char* tx_icons[ALL_ICONS];
33
34 int tx_icon_size=20;
35
36 static const char tx_css[] = "#close:hover { background-color: #FF5555; color: #FFFFFF; }";
37
38 void tx_icons_init(int size) {
39         tx_icon_size=size;
40
41         tx_icons[AUDIOENGINE] = "audio-speakers-symbolic";
42         tx_icons[POWER] = "system-shutdown-symbolic";
43         tx_icons[GRAB] = "input-mouse-symbolic";
44
45         tx_icons[SEQUENCER] = "emblem-music-symbolic";
46
47         tx_icons[PLAY] = "media-playback-start-symbolic";
48         tx_icons[STOP] = "media-playback-stop-symbolic";
49         tx_icons[RECORD] = "media-record-symbolic";
50         tx_icons[MIN_AUDIO] = "audio-x-generic-symbolic";
51         tx_icons[MIN_CONTROL] = "multimedia-volume-control-symbolic";
52
53         tx_icons[MINIMIZE] = "window-minimize-symbolic";
54         tx_icons[MAXIMIZE] = "view-more-symbolic";
55         tx_icons[FX_UP] = "go-up-symbolic";
56         tx_icons[FX_DOWN] = "go-down-symbolic";
57         tx_icons[FX_CLOSE] = "window-close-symbolic";
58         tx_icons[ADD_ITEM] = "list-add-symbolic";
59         tx_icons[ADD_DRYWET] = "list-add-symbolic";
60         tx_icons[REMOVE_DRYWET] = "list-remove-symbolic";
61
62         GtkCssProvider *provider = gtk_css_provider_new();
63         gtk_css_provider_load_from_data(provider, tx_css, -1, NULL);
64         gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
65 }
66
67 GtkWidget *tx_pixmap_widget(tX_icon id)
68 {
69         return gtk_image_new_from_icon_name (tx_icons[id], GTK_ICON_SIZE_SMALL_TOOLBAR);
70 }
71
72 GtkWidget *tx_xpm_label_box(tX_icon id, const gchar *label_text, GtkWidget **labelwidget)
73 {
74         GtkWidget *box1;
75         GtkWidget *label;
76         GtkWidget *pixmapwid;
77
78         switch (globals.button_type) {
79                 case BUTTON_TYPE_TEXT:
80                         label = gtk_label_new(label_text);
81                         gtk_widget_show(label);
82                         if (labelwidget!=NULL) *labelwidget=label;
83                         return label;
84                         break;
85                 case BUTTON_TYPE_ICON:
86                         pixmapwid=tx_pixmap_widget(id);
87                         gtk_widget_show(pixmapwid);
88                         return pixmapwid;
89                         break;
90                 default:
91                         box1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
92                         gtk_container_set_border_width (GTK_CONTAINER (box1), 2);
93                         pixmapwid=tx_pixmap_widget(id);
94                         gtk_box_pack_start (GTK_BOX (box1), pixmapwid, FALSE, FALSE, 0);
95                         gtk_widget_show(pixmapwid);
96                         label = gtk_label_new (label_text);
97                         gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
98                         gtk_widget_show(label);
99                         if (labelwidget!=NULL)  *labelwidget=label;
100                         return box1;
101         }
102 }
103
104 extern GtkWidget *tx_xpm_button_new(tX_icon id, const char *label, int toggle, GtkWidget **labelwidget)
105 {
106         GtkWidget *box;
107         GtkWidget *button;
108
109         if (toggle) button=gtk_toggle_button_new();
110         else button=gtk_button_new();
111
112         box=tx_xpm_label_box(id, label, labelwidget);
113         gtk_widget_show(box);
114         gtk_container_add (GTK_CONTAINER (button), box);
115
116         return(button);
117 }
118
119 GtkWidget* create_top_button(int icon_id) {
120         GtkWidget* button = gtk_button_new_from_icon_name(tx_icons[icon_id], GTK_ICON_SIZE_SMALL_TOOLBAR);
121         gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
122         gtk_widget_set_margin_end(button, 0);
123         gtk_container_set_border_width(GTK_CONTAINER(button),0);
124         return button;
125 }