2 * ui.c -- GTK+ 2 omnplay
3 * Copyright (C) 2011 Maksym Veremeyenko <verem@m1stereo.tv>
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.
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.
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.
24 #include <sys/types.h>
30 #include <gdk/gdkkeysyms.h>
35 #include "ui_buttons.h"
38 typedef struct column_desc
44 static const column_desc_t playlist_columns
[] =
80 const static column_desc_t library_columns
[] =
101 static GtkWidget
* create_label(GtkWidget
* top
, char* text
, char* reg
, GtkJustification jtype
)
105 label
= gtk_label_new ("");
106 gtk_widget_show (label
);
108 gtk_label_set_justify (GTK_LABEL (label
), jtype
);
111 GLADE_HOOKUP_OBJECT (top
, label
, reg
);
114 gtk_label_set_text(GTK_LABEL (label
), text
);
119 static GtkWidget
* create_treeview(GtkWidget
* top
, char* name
, const column_desc_t columns
[])
124 GtkCellRenderer
*renderer
;
125 GtkTreeViewColumn
*column
;
126 GtkListStore
*list_store
;
127 GType list_store_types
[32];
129 treeview
= gtk_tree_view_new ();
130 gtk_widget_show (treeview
);
132 for(i
= 0, count
= 0; columns
[i
].title
; i
++, count
++)
133 list_store_types
[i
] = (columns
[i
].type
== G_TYPE_OBJECT
)?GDK_TYPE_PIXBUF
:columns
[i
].type
;
135 list_store
= gtk_list_store_newv(count
, list_store_types
);
137 gtk_tree_view_set_model( GTK_TREE_VIEW( treeview
), GTK_TREE_MODEL( list_store
) );
139 for(i
= 0; columns
[i
].title
; i
++)
143 if(columns
[i
].type
== G_TYPE_OBJECT
)
145 renderer
= gtk_cell_renderer_pixbuf_new();
146 gtk_cell_renderer_set_padding(renderer
, 0, 0);
149 else if(columns
[i
].type
== G_TYPE_BOOLEAN
)
151 renderer
= gtk_cell_renderer_toggle_new();
156 renderer
= gtk_cell_renderer_text_new();
160 column
= gtk_tree_view_column_new_with_attributes(
161 columns
[i
].title
, renderer
, prop
, i
, NULL
);
162 gtk_tree_view_append_column(GTK_TREE_VIEW( treeview
), column
);
165 g_object_unref(list_store
);
167 GLADE_HOOKUP_OBJECT (top
, treeview
, name
);
172 static GtkWidget
* pane_library_grid(GtkWidget
* top
, omnplay_instance_t
* app
)
174 GtkWidget
*scrolledwindow
;
176 scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
177 gtk_widget_show (scrolledwindow
);
178 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow
),
179 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
181 gtk_container_add (GTK_CONTAINER (scrolledwindow
),
182 app
->library_grid
= create_treeview(top
, "treeview_library", library_columns
));
184 return scrolledwindow
;
187 static GtkWidget
* pane_library_buttons(GtkWidget
* top
, omnplay_instance_t
* app
)
191 hbox
= gtk_hbox_new (FALSE
, 0);
192 gtk_widget_show (hbox
);
194 /* playlist modify buttons */
195 gtk_box_pack_start (GTK_BOX (hbox
),
196 ui_create_button(top
, app
, BUTTON_LIBRARY_ADD
),
198 gtk_box_pack_start (GTK_BOX (hbox
),
199 ui_create_button(top
, app
, BUTTON_LIBRARY_REFRESH
),
203 gtk_box_pack_start (GTK_BOX (hbox
),
204 create_label(top
, NULL
, NULL
, GTK_JUSTIFY_CENTER
),
210 static GtkWidget
* pane_library(GtkWidget
* top
, omnplay_instance_t
* app
)
214 vbox
= gtk_vbox_new (FALSE
, 0);
215 gtk_widget_show (vbox
);
216 gtk_widget_set_size_request(vbox
, 300, -1);
218 /* add buttons box */
219 gtk_box_pack_start (GTK_BOX (vbox
),
220 pane_library_buttons(top
, app
),
223 /* add buttons box */
224 gtk_box_pack_start (GTK_BOX (vbox
),
225 pane_library_grid(top
, app
),
231 static GtkWidget
* create_channel_status(GtkWidget
* top
, omnplay_instance_t
* app
, int idx
)
236 omnplay_player_t
* player
;
238 player
= &app
->players
.item
[idx
];
240 frame
= gtk_frame_new(player
->name
);
241 gtk_widget_show(frame
);
243 vbox
= gtk_vbox_new(FALSE
, 0);
244 gtk_container_add(GTK_CONTAINER(frame
), vbox
);
245 gtk_widget_show(vbox
);
248 gtk_box_pack_start(GTK_BOX (vbox
),
249 player
->label_status
= create_label(top
, "OFFLINE", NULL
, GTK_JUSTIFY_LEFT
),
253 gtk_box_pack_start(GTK_BOX (vbox
),
254 create_label(top
, " ", NULL
, GTK_JUSTIFY_CENTER
),
258 gtk_box_pack_start (GTK_BOX (vbox
),
259 player
->label_clip
= create_label(top
, "U0002323", NULL
, GTK_JUSTIFY_LEFT
),
262 /* block state/current timecode */
263 gtk_box_pack_start(GTK_BOX (vbox
),
264 hbox
= gtk_hbox_new(TRUE
, 0),
266 gtk_widget_show(hbox
);
270 gtk_box_pack_start(GTK_BOX (hbox
),
271 player
->label_state
= create_label(top
, "PLAYING", NULL
, GTK_JUSTIFY_LEFT
),
274 /* current timecode */
275 gtk_box_pack_start(GTK_BOX (hbox
),
276 player
->label_tc_cur
= create_label(top
, "00:00:00:00", NULL
, GTK_JUSTIFY_LEFT
),
280 /* block remain label/remain timecode */
281 gtk_box_pack_start(GTK_BOX (vbox
),
282 hbox
= gtk_hbox_new(TRUE
, 0),
284 gtk_widget_show (hbox
);
288 gtk_box_pack_start(GTK_BOX (hbox
),
289 create_label(top
, "remain:", NULL
, GTK_JUSTIFY_LEFT
),
292 /* remaining timecode */
293 gtk_box_pack_start(GTK_BOX (hbox
),
294 player
->label_tc_rem
= create_label(top
, "00:00:00:00", NULL
, GTK_JUSTIFY_LEFT
),
301 static GtkWidget
* pane_operate_status(GtkWidget
* top
, omnplay_instance_t
* app
)
306 vbox
= gtk_vbox_new (FALSE
, 0);
307 gtk_widget_show (vbox
);
308 gtk_widget_set_size_request(vbox
, 250, -1);
310 for(i
= 0; i
< app
->players
.count
; i
++)
312 gtk_box_pack_start (GTK_BOX (vbox
),
313 create_channel_status(top
, app
, i
),
317 gtk_box_pack_start (GTK_BOX (vbox
),
318 create_label(top
, NULL
, NULL
, GTK_JUSTIFY_CENTER
),
323 gtk_box_pack_start (GTK_BOX (vbox
),
324 create_label(top
, NULL
, NULL
, GTK_JUSTIFY_CENTER
),
330 static GtkWidget
* pane_operate_buttons_playlist(GtkWidget
* top
, omnplay_instance_t
* app
)
334 hbox
= gtk_hbox_new (FALSE
, 0);
335 gtk_widget_show (hbox
);
337 /* playlist load/save buttons */
338 gtk_box_pack_start (GTK_BOX (hbox
),
339 ui_create_button(top
, app
, BUTTON_PLAYLIST_LOAD
),
341 gtk_box_pack_start (GTK_BOX (hbox
),
342 ui_create_button(top
, app
, BUTTON_PLAYLIST_SAVE
),
346 gtk_box_pack_start (GTK_BOX (hbox
),
347 create_label(top
, " ", NULL
, GTK_JUSTIFY_CENTER
),
350 /* playlist modify buttons */
351 gtk_box_pack_start (GTK_BOX (hbox
),
352 ui_create_button(top
, app
, BUTTON_PLAYLIST_ITEM_ADD
),
354 gtk_box_pack_start (GTK_BOX (hbox
),
355 ui_create_button(top
, app
, BUTTON_PLAYLIST_ITEM_EDIT
),
357 gtk_box_pack_start (GTK_BOX (hbox
),
358 ui_create_button(top
, app
, BUTTON_PLAYLIST_ITEM_DEL
),
362 gtk_box_pack_start (GTK_BOX (hbox
),
363 create_label(top
, " ", NULL
, GTK_JUSTIFY_CENTER
),
366 /* playlist block buttons */
367 gtk_box_pack_start (GTK_BOX (hbox
),
368 ui_create_button(top
, app
, BUTTON_PLAYLIST_BLOCK_SINGLE
),
370 gtk_box_pack_start (GTK_BOX (hbox
),
371 ui_create_button(top
, app
, BUTTON_PLAYLIST_BLOCK_LOOP
),
375 gtk_box_pack_start (GTK_BOX (hbox
),
376 create_label(top
, " ", NULL
, GTK_JUSTIFY_CENTER
),
379 /* playlist move items buttons */
380 gtk_box_pack_start (GTK_BOX (hbox
),
381 ui_create_button(top
, app
, BUTTON_PLAYLIST_ITEM_UP
),
383 gtk_box_pack_start (GTK_BOX (hbox
),
384 ui_create_button(top
, app
, BUTTON_PLAYLIST_ITEM_DOWN
),
390 static GtkWidget
* pane_operate_grid(GtkWidget
* top
, omnplay_instance_t
* app
)
392 GtkWidget
*scrolledwindow
;
394 scrolledwindow
= gtk_scrolled_window_new (NULL
, NULL
);
395 gtk_widget_show (scrolledwindow
);
396 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow
),
397 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
399 gtk_container_add (GTK_CONTAINER (scrolledwindow
),
400 app
->playlist_grid
= create_treeview(top
, "treeview_playlist", playlist_columns
));
402 return scrolledwindow
;
405 static GtkWidget
* pane_operate_buttons_operate(GtkWidget
* top
, omnplay_instance_t
* app
)
409 hbox
= gtk_hbox_new (FALSE
, 0);
410 gtk_widget_show (hbox
);
413 gtk_box_pack_start (GTK_BOX (hbox
),
414 create_label(top
, NULL
, NULL
, GTK_JUSTIFY_CENTER
),
417 /* playlist modify buttons */
418 gtk_box_pack_start (GTK_BOX (hbox
),
419 ui_create_button(top
, app
, BUTTON_PLAYER_CUE
),
421 gtk_box_pack_start (GTK_BOX (hbox
),
422 ui_create_button(top
, app
, BUTTON_PLAYER_PLAY
),
424 gtk_box_pack_start (GTK_BOX (hbox
),
425 ui_create_button(top
, app
, BUTTON_PLAYER_PAUSE
),
427 gtk_box_pack_start (GTK_BOX (hbox
),
428 ui_create_button(top
, app
, BUTTON_PLAYER_STOP
),
432 gtk_box_pack_start (GTK_BOX (hbox
),
433 create_label(top
, NULL
, NULL
, GTK_JUSTIFY_CENTER
),
439 static GtkWidget
* pane_operate_operate(GtkWidget
* top
, omnplay_instance_t
* app
)
443 vbox
= gtk_vbox_new (FALSE
, 0);
444 gtk_widget_show (vbox
);
446 /* add buttons box #1 */
447 gtk_box_pack_start (GTK_BOX (vbox
),
448 pane_operate_buttons_playlist(top
, app
),
451 /* add buttons box */
452 gtk_box_pack_start (GTK_BOX (vbox
),
453 pane_operate_grid(top
, app
),
456 /* add buttons box #1 */
457 gtk_box_pack_start (GTK_BOX (vbox
),
458 pane_operate_buttons_operate(top
, app
),
465 static GtkWidget
* pane_operate(GtkWidget
* top
, omnplay_instance_t
* app
)
469 hbox
= gtk_hbox_new (FALSE
, 0);
470 gtk_widget_show (hbox
);
472 /* add buttons box */
473 gtk_box_pack_start (GTK_BOX (hbox
),
474 pane_operate_status(top
, app
),
477 /* add buttons box */
478 gtk_box_pack_start (GTK_BOX (hbox
),
479 pane_operate_operate(top
, app
),
486 static GtkWidget
* pane_top(GtkWidget
* top
, omnplay_instance_t
* app
)
490 pane
= gtk_hpaned_new ();
491 gtk_widget_show (pane
);
493 gtk_paned_set_position (GTK_PANED (pane
), 800);
495 gtk_paned_pack1 (GTK_PANED (pane
),
496 pane_operate(top
, app
),
499 gtk_paned_pack2 (GTK_PANED (pane
),
500 pane_library(top
, app
),
506 GtkWidget
* ui_omnplay (omnplay_instance_t
* app
)
510 wnd
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
511 GLADE_HOOKUP_OBJECT_NO_REF (wnd
, wnd
, "omnplay_window");
513 gtk_window_set_title (GTK_WINDOW (wnd
), _("Omneon Player"));
514 gtk_window_set_default_size (GTK_WINDOW (wnd
), 1024, 768);
516 gtk_container_add (GTK_CONTAINER (wnd
),
519 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN
] =
520 create_pixbuf("block_type_block_start_16x16.png");
521 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY
] =
522 create_pixbuf("block_type_block_middle_16x16.png");
523 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_BLOCK_END
] =
524 create_pixbuf("block_type_block_end_16x16.png");
525 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE
] =
526 create_pixbuf("block_type_block_single_16x16.png");
527 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN
] =
528 create_pixbuf("block_type_loop_start_16x16.png");
529 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_LOOP_BODY
] =
530 create_pixbuf("block_type_loop_middle_16x16.png");
531 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_LOOP_END
] =
532 create_pixbuf("block_type_loop_end_16x16.png");
533 app
->playlist
.block_icons
[OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE
] =
534 create_pixbuf("block_type_block_loop_16x16.png");