add a relink button image
[melted_gui] / src / ui_buttons.c
1 /*
2 * ui_buttons.h -- GTK+ 2 omnplay
3 * Copyright (C) 2011 Maksym Veremeyenko <verem@m1stereo.tv>
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 Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #ifndef UI_BUTTONS_H
21 #define UI_BUTTONS_H
22
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <stdio.h>
32
33 #include <gdk/gdkkeysyms.h>
34 #include <gtk/gtk.h>
35
36 #include "ui.h"
37 #include "ui_utils.h"
38 #include "ui_buttons.h"
39 #include "support.h"
40
41 typedef struct button_desc
42 {
43 control_buttons_t id;
44 char* tooltip;
45 char* stock;
46 char* label;
47 char* hookup;
48 char* filename;
49 } button_desc_t;
50
51 static const button_desc_t buttons[] =
52 {
53 {
54 BUTTON_PLAYLIST_ITEM_ADD,
55 "Add item to playlist (Insert)",
56 NULL,
57 NULL,
58 "button_playlist_add",
59 "Axialis_Team_item_add_16x116.png"
60 },
61 {
62 BUTTON_PLAYLIST_RELINK,
63 "Relink items in playlist",
64 NULL,
65 NULL,
66 "button_playlist_relink",
67 "Axialis_Team_playlist_relink_16x16.png"
68 },
69 {
70 BUTTON_PLAYLIST_ITEM_EDIT,
71 "Edit item in playlist (E)",
72 NULL,
73 NULL,
74 "button_playlist_edit",
75 "Axialis_Team_item_edit_16x116.png"
76 },
77 {
78 BUTTON_PLAYLIST_ITEM_DEL,
79 "Delete item from playlist (Del)",
80 NULL,
81 NULL,
82 "button_playlist_del",
83 "Axialis_Team_item_delete_16x116.png"
84 },
85 {
86 BUTTON_PLAYLIST_ITEM_UP,
87 "Move item above (Ctrl-UP)",
88 NULL,
89 NULL,
90 "button_playlist_up",
91 "Axialis_Team_item_move_up_16x116.png"
92 },
93 {
94 BUTTON_PLAYLIST_ITEM_DOWN,
95 "Move item below (Ctrl-DOWN)",
96 NULL,
97 NULL,
98 "button_playlist_down",
99 "Axialis_Team_item_move_down_16x116.png"
100 },
101 {
102 BUTTON_PLAYLIST_LOAD,
103 "Load playlist (Ctrl-O)",
104 NULL,
105 NULL,
106 "button_playlist_load",
107 "Axialis_Team_playlist_open_16x16.png"
108 },
109 {
110 BUTTON_PLAYLIST_SAVE,
111 "Save playlist (Ctrl-S)",
112 NULL,
113 NULL,
114 "button_playlist_load",
115 "Axialis_Team_playlist_save_16x16.png"
116 },
117 {
118 BUTTON_PLAYLIST_BLOCK_LOOP,
119 "Make a loop block",
120 NULL,
121 NULL,
122 "button_playlist_block_loop",
123 "Axialis_Team_item_loop_16x116.png"
124 },
125 {
126 BUTTON_PLAYLIST_BLOCK_SINGLE,
127 "Make a single block",
128 NULL,
129 NULL,
130 "button_playlist_block_single",
131 "Axialis_Team_item_block_16x116.png"
132 },
133 {
134 BUTTON_PLAYER_CUE,
135 "Cue block (Enter)",
136 NULL,
137 NULL,
138 "button_playlist_cue",
139 "Axialis_Team_player_cue_32x32.png"
140 },
141 {
142 BUTTON_PLAYER_PLAY,
143 "Play (Space)",
144 NULL,
145 NULL,
146 "button_playlist_play",
147 "Axialis_Team_player_play_64x32.png"
148 },
149 {
150 BUTTON_PLAYER_PAUSE,
151 "Pause",
152 NULL,
153 NULL,
154 "button_playlist_pause",
155 "Axialis_Team_player_pause_32x32.png"
156 },
157 {
158 BUTTON_PLAYER_STOP,
159 "STOP",
160 NULL,
161 NULL,
162 "button_playlist_stop",
163 "Axialis_Team_player_stop_32x32.png"
164 },
165 {
166 BUTTON_LIBRARY_ADD,
167 "Add to playlist (Enter)",
168 NULL,
169 NULL,
170 "button_library_add",
171 "Axialis_Team_item_add_from_library_16x16.png"
172 },
173 {
174 BUTTON_LIBRARY_REFRESH,
175 "Refresh library (F5)",
176 NULL,
177 NULL,
178 "button_library_refresh",
179 "Axialis_Team_library_refresh_16x16.png"
180 },
181 {
182 BUTTON_LIBRARY_FIND,
183 "Find item",
184 NULL,
185 NULL,
186 "button_library_find",
187 "Axialis_Team_search_in_library_16x16.png"
188 },
189 {
190 BUTTON_LIBRARY_FIND_NEXT,
191 "Find next item",
192 NULL,
193 NULL,
194 "button_library_find_next",
195 "Axialis_Team_search_next_16x16.png"
196 },
197
198 {
199 BUTTON_LAST,
200 }
201 };
202
203 GtkWidget* ui_create_button(GtkWidget* top, omnplay_instance_t* app, control_buttons_t id)
204 {
205 int idx;
206 GtkWidget *button, *alignment, *hbox, *image = NULL, *label;
207 const button_desc_t* info = NULL;
208
209 for(idx = 0; !info && buttons[idx].id != BUTTON_LAST; idx++)
210 if(buttons[idx].id == id)
211 info = &buttons[idx];
212
213 if(!info)
214 return NULL;
215
216 button = gtk_button_new();
217 gtk_widget_show(button);
218 GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
219 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
220 gtk_button_set_relief(GTK_BUTTON (button), GTK_RELIEF_NONE);
221 if(info->tooltip)
222 gtk_widget_set_tooltip_text(button, info->tooltip);
223
224 alignment = gtk_alignment_new(0, 0.5, 0, 0);
225 gtk_widget_show(alignment);
226 gtk_container_add(GTK_CONTAINER (button), alignment);
227
228 hbox = gtk_hbox_new(FALSE, 2);
229 gtk_widget_show(hbox);
230 gtk_container_add(GTK_CONTAINER(alignment), hbox);
231
232 if(info->stock)
233 image = gtk_image_new_from_stock(info->stock, GTK_ICON_SIZE_MENU);
234 else if(info->filename)
235 image = gtk_image_new_from_pixbuf(create_pixbuf(info->filename));
236 if(image)
237 {
238 gtk_widget_show(image);
239 gtk_box_pack_start(GTK_BOX (hbox), image, FALSE, FALSE, 0);
240 }
241
242 label = gtk_label_new_with_mnemonic("");
243 if(info->label)
244 gtk_label_set_text(GTK_LABEL (label), info->label);
245 gtk_widget_show(label);
246 gtk_box_pack_start(GTK_BOX (hbox), label, FALSE, FALSE, 0);
247 gtk_label_set_justify(GTK_LABEL (label), GTK_JUSTIFY_LEFT);
248
249 if(info->hookup)
250 GLADE_HOOKUP_OBJECT (top, button, info->hookup);
251
252 app->buttons[id] = button;
253
254 return button;
255 }
256
257
258 #endif /* UI_BUTTONS_H */