From: Darren S. <ds...@us...> - 2005-07-13 23:10:33
|
Update of /cvsroot/xine/gnome-xine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18765/src Modified Files: key_events.c mediamarks.c playlist.c Log Message: Switch to action-based toolbars. Some memset replacement and minor tweaks. Index: key_events.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/key_events.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- key_events.c 30 Jun 2005 00:09:18 -0000 1.72 +++ key_events.c 13 Jul 2005 23:10:08 -0000 1.73 @@ -135,9 +135,8 @@ static key_binding_t *lookup_binding (GtkTreeIter *iter) { key_binding_t *k; - GValue v; + GValue v = {0}; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (kb_store), iter, 2, &v); k = g_value_peek_pointer (&v); g_value_unset (&v); @@ -353,8 +352,7 @@ /* add new key binding */ - key_binding = malloc (sizeof (key_binding_t)); - memset (key_binding, 0, sizeof (key_binding_t)); + key_binding = g_malloc0 (sizeof (key_binding_t)); key_binding->keyval = GDK_VoidSymbol; gtk_list_store_append (kb_store, &iter); @@ -1227,28 +1225,16 @@ hbox = gtk_hbox_new (FALSE, 2); - b = gtk_button_new_from_stock (GTK_STOCK_NEW); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", - G_CALLBACK(kb_new_binding), kb_bindings_list_dlg); - - b = gtk_button_new_from_stock (GTK_STOCK_EDIT); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", - G_CALLBACK(kb_edit_binding), kb_bindings_list_dlg); - - b = gtk_button_new_from_stock (GTK_STOCK_DELETE); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", - G_CALLBACK(kb_delete_binding), kb_bindings_list_dlg); - { static const GtkActionEntry kb_menu_data[] = { { "binding", NULL, N_("_Reload...") }, - { "reload", GTK_STOCK_REVERT_TO_SAVED, N_("_Reload bindings"), NULL, NULL, kb_reload_keymap }, - { "addnew", GTK_STOCK_ADD, N_("_Add new default bindings"), NULL, NULL, kb_add_defaults }, - { "merge", NULL, N_("_Merge default bindings"), NULL, NULL, kb_merge_defaults }, - { "replace", GTK_STOCK_CLEAR, N_("Replace with _default bindings"), NULL, NULL, kb_reset_keymap }, + { "reload", GTK_STOCK_REVERT_TO_SAVED, N_("_Reload bindings"), NULL, NULL, kb_reload_keymap }, + { "addnew", GTK_STOCK_ADD, N_("_Add new default bindings"), NULL, NULL, kb_add_defaults }, + { "merge", NULL, N_("_Merge default bindings"), NULL, NULL, kb_merge_defaults }, + { "replace", GTK_STOCK_CLEAR, N_("Replace with _default bindings"), NULL, NULL, kb_reset_keymap }, + { "new", GTK_STOCK_NEW, NULL, NULL, N_("Add a key binding"), kb_new_binding }, + { "edit", GTK_STOCK_EDIT, NULL, "<Control>E", N_("Edit the selected item"), kb_edit_binding }, + { "delete", GTK_STOCK_DELETE, NULL, "Delete", N_("Delete the selected item"), kb_delete_binding }, }; static const char kb_menu_structure[] = "<ui>" @@ -1260,16 +1246,24 @@ "<menuitem action='replace' />" "</menu>" "</menubar>" + "<toolbar>" + "<toolitem action='new' />" + "<toolitem action='edit' />" + "<toolitem action='delete' />" + "</toolbar>" "</ui>"; GError *error; GtkUIManager *ui = ui_create_manager ("bindings", kb_bindings_list_dlg); + gtk_action_group_add_actions (ui_get_action_group (ui), kb_menu_data, G_N_ELEMENTS(kb_menu_data), kb_bindings_list_dlg); gtk_ui_manager_add_ui_from_string (ui, kb_menu_structure, -1, &error); - gtk_box_pack_end_defaults - (GTK_BOX(hbox), gtk_ui_manager_get_widget (ui, "/menubar")); + gtk_box_pack_start + (GTK_BOX(hbox), gtk_ui_manager_get_widget (ui, "/toolbar"), TRUE, TRUE, 0); + gtk_box_pack_end + (GTK_BOX(hbox), gtk_ui_manager_get_widget (ui, "/menubar"), FALSE, FALSE, 0); } gtk_box_pack_start (GTK_BOX(GTK_DIALOG(kb_bindings_list_dlg)->vbox), hbox, Index: mediamarks.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/mediamarks.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- mediamarks.c 12 Jul 2005 18:41:40 -0000 1.53 +++ mediamarks.c 13 Jul 2005 23:10:08 -0000 1.54 @@ -43,10 +43,12 @@ #include "play_item.h" static GtkTreeStore *mm_store; +static GtkTreeSelection *sel; static GtkWidget *manage_dlg, *cat_dlg, *cat_entry, *mm_tree; static GtkTreeIter cat_iter; static gboolean is_visible, cat_edited; +static GtkUIManager *mm_ui; static GtkActionGroup *media_group = NULL; static guint media_merge; @@ -60,10 +62,9 @@ GtkTreeIter *iter, int count) { do { - GValue v; + GValue v = {0}; char *id; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 0, &v); id = g_value_peek_pointer (&v); @@ -76,7 +77,6 @@ free (name); g_value_unset (&v); - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 2, &v); item = g_value_peek_pointer (&v); @@ -109,10 +109,9 @@ guint merge, int count) { do { - GValue v; + GValue v = {0}; char *id; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 0, &v); id = g_value_peek_pointer (&v); @@ -121,7 +120,6 @@ play_item_t *item; g_value_unset (&v); - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 2, &v); item = g_value_peek_pointer (&v); @@ -149,8 +147,6 @@ return count; } -extern GtkUIManager *ui; - static void update_menu (void) { GtkTreeIter iter; @@ -345,29 +341,24 @@ static gboolean do_category_edit (void) { cat_edited = FALSE; - gtk_widget_show_all (cat_dlg); - if (!GTK_WINDOW(cat_dlg)->modal) - gtk_window_set_modal (GTK_WINDOW(cat_dlg), TRUE); + gtk_window_set_modal (GTK_WINDOW(cat_dlg), TRUE); gtk_widget_grab_focus (cat_entry); + window_show (cat_dlg, manage_dlg); gtk_main(); return cat_edited; } -static void edit_cb (GtkWidget* widget, gpointer data) { - - GtkTreeView *tree = GTK_TREE_VIEW (mm_tree); - GtkTreeSelection *sel; - GtkTreeIter iter; - - sel = gtk_tree_view_get_selection (tree); +static void edit_cb (GtkWidget* widget, gpointer data) +{ + GtkTreeIter iter; - if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { - GValue v; + if (gtk_tree_selection_get_selected (sel, NULL, &iter)) + { + GValue v = {0}; play_item_t *play_item; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); @@ -382,12 +373,11 @@ 1, play_item->mrl, 2, play_item, -1); } } else { - GValue v; + GValue v = {0}; char *name; memcpy (&cat_iter, &iter, sizeof (cat_iter)); - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), &iter, 0, &v); name = (char *) g_value_peek_pointer (&v); @@ -402,22 +392,15 @@ } } -static void delete_cb (GtkWidget* widget, gpointer data) { - - GtkTreeView *tree = GTK_TREE_VIEW (mm_tree); - GtkTreeSelection *sel; - GtkTreeIter iter; - - sel = gtk_tree_view_get_selection (tree); - +static void delete_cb (GtkWidget* widget, gpointer data) +{ + GtkTreeIter iter; if (gtk_tree_selection_get_selected (sel, NULL, &iter)) gtk_tree_store_remove (mm_store, &iter); } -static void new_category_cb (GtkWidget* widget, gpointer data) { - - GtkTreeView *tree = GTK_TREE_VIEW (mm_tree); - GtkTreeSelection *sel; +static void new_category_cb (GtkWidget* widget, gpointer data) +{ GtkTreeIter iter, parent; gboolean in_root = TRUE; @@ -425,17 +408,14 @@ * find out where to create the new section */ - sel = gtk_tree_view_get_selection (tree); - if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { - GValue v; + GValue v = {0}; play_item_t *play_item; /* * is this a section or a play item ? */ - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); @@ -446,7 +426,7 @@ GtkTreePath *path; path = gtk_tree_model_get_path (GTK_TREE_MODEL (mm_store), &iter); - if (gtk_tree_view_row_expanded (tree, path)) { + if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (mm_tree), path)) { in_root = 0; memcpy (&parent, &iter, sizeof (iter)); } else { @@ -474,9 +454,9 @@ } } -static void tree_changed_cb (GtkTreeModel *treemodel, - GtkTreePath *arg1, - gpointer user_data) { +static void tree_changed_cb (GtkTreeModel *treemodel, GtkTreePath *arg1, + gpointer user_data) +{ update_menu (); } @@ -575,34 +555,30 @@ } } -static void save_items (FILE *f, int depth, GtkTreeIter *iter) { - - do { - - GValue v; +static void save_items (FILE *f, int depth, GtkTreeIter *iter) +{ + do + { + GValue v = {0}; play_item_t *play_item; char *id; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 0, &v); id = g_value_peek_pointer (&v); - if (id) { - - GValue vi; + if (id) + { + GValue vi = {0}; - memset (&vi, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (mm_store), iter, 2, &vi); play_item = g_value_peek_pointer (&vi); - if (play_item) { - + if (play_item) play_item_save (play_item, f, depth); - - } else { - + else + { GtkTreeIter children; print_depth (f, depth); @@ -613,7 +589,6 @@ print_depth (f, depth); fprintf (f, "</SUB>\n"); - } g_value_unset (&vi); @@ -709,39 +684,44 @@ } } -void mediamarks_init (void) { +static const GtkActionEntry buttons_data[] = { + { "new", GTK_STOCK_NEW, NULL, NULL, N_("Add an MRL"), mm_add_show }, + { "newcat", GTK_STOCK_DIRECTORY, NULL, "<Control>F", N_("Add a category folder"), new_category_cb }, + { "edit", GTK_STOCK_EDIT, NULL, "<Control>E", N_("Edit the selected item"), edit_cb }, + { "delete", GTK_STOCK_DELETE, NULL, "Delete", N_("Delete the selected item"), delete_cb }, +}; + +static const char buttons_structure[] = + "<ui>\n" + "<toolbar>\n" + "<toolitem action='new' />\n" + "<toolitem action='newcat' />\n" + "<toolitem action='edit' />\n" + "<toolitem action='delete' />\n" + "</toolbar>\n" + "</ui>"; + +static void sel_changed_cb (GtkTreeSelection *sel, gpointer data) +{ + static const char *const items[] = { "edit", "delete", NULL }; + ui_mark_active (mm_ui, items, + gtk_tree_selection_get_selected (sel, NULL, NULL)); +} +void mediamarks_init (void) +{ GtkWidget *tree, *b, *scrolled_window, *hbox, *label; + GtkBox *vbox; gchar *fname; GtkCellRenderer *cell; GtkTreeViewColumn *column; + GError *error; /* * init tree store */ mm_store = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - - /* - * now parse the mediamarks file - */ - - fname = g_strconcat(g_get_home_dir(), "/.gxine/mediamarks", NULL); - - if (!load_mediamarks (fname)) { - /* load sample mediamarks */ - g_free (fname); - fname = g_strconcat (miscdir, "/mediamarks", NULL); - //load_mediamarks (fname); - if (!load_mediamarks (fname)) - { - asreprintf (&fname, "%s.gz", fname); - load_mediamarks (fname); - } - } - - g_free(fname); - g_signal_connect (G_OBJECT (mm_store), "row-changed", G_CALLBACK (tree_changed_cb), NULL); g_signal_connect (G_OBJECT (mm_store), "row-deleted", @@ -753,8 +733,6 @@ g_signal_connect (G_OBJECT (mm_store), "rows-reordered", G_CALLBACK (tree_changed_cb), NULL); - update_menu (); - /* * create (for now invisible) mm_manage dialog */ @@ -768,11 +746,31 @@ G_CALLBACK(mm_response_cb), NULL); hide_on_delete (manage_dlg, &is_visible); - /* add a nice tree view widget here */ + vbox = GTK_BOX (GTK_DIALOG (manage_dlg)->vbox); + + /* add a nice toolbar and tree view widget here */ mm_tree = tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(mm_store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree), TRUE); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)); + g_signal_connect (G_OBJECT (sel), "changed", + G_CALLBACK (sel_changed_cb), NULL); + + /* buttons */ + + mm_ui = ui_create_manager ("mm", manage_dlg); + gtk_action_group_add_actions (ui_get_action_group (mm_ui), buttons_data, + G_N_ELEMENTS (buttons_data), tree); + gtk_ui_manager_add_ui_from_string (mm_ui, buttons_structure, -1, &error); + gtk_box_pack_start (vbox, gtk_ui_manager_get_widget (mm_ui, "/toolbar"), + FALSE, FALSE, 0); + gtk_action_group_connect_accelerators (ui_get_action_group (mm_ui)); + + sel_changed_cb (sel, NULL); + + /* fill in and insert the tree view widget */ + cell = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT(cell), "ellipsize", 2, "width_chars", 16, NULL); /* foo...bar */ @@ -803,32 +801,31 @@ g_signal_connect (G_OBJECT (tree), "row-activated", G_CALLBACK (edit_cb), NULL); - /* add edit button bar */ - hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (vbox, scrolled_window, TRUE, TRUE, 2); + + is_visible = FALSE; + + /* + * now parse the mediamarks file + */ - b = gtk_button_new_from_stock (GTK_STOCK_NEW); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", G_CALLBACK(mm_add_show), NULL); - - b = ui_button_new_stock_mnemonic (GTK_STOCK_DIRECTORY, _("New _category")); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", G_CALLBACK(new_category_cb), tree); - - b = gtk_button_new_from_stock (GTK_STOCK_EDIT); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", G_CALLBACK(edit_cb), NULL); - - b = gtk_button_new_from_stock (GTK_STOCK_DELETE); - gtk_box_pack_start (GTK_BOX(hbox), b, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT(b), "clicked", G_CALLBACK(delete_cb), NULL); + fname = g_strconcat(g_get_home_dir(), "/.gxine/mediamarks", NULL); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(manage_dlg)->vbox), hbox, - FALSE, FALSE, 2); + if (!load_mediamarks (fname)) { + /* load sample mediamarks */ + g_free (fname); + fname = g_strconcat (miscdir, "/mediamarks", NULL); + //load_mediamarks (fname); + if (!load_mediamarks (fname)) + { + asreprintf (&fname, "%s.gz", fname); + load_mediamarks (fname); + } + } - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(manage_dlg)->vbox), scrolled_window, - TRUE, TRUE, 2); + g_free(fname); - is_visible = FALSE; + update_menu (); /* * create (for now invisible) category name entry dialog @@ -877,4 +874,3 @@ se_defuns (gse, NULL, defs); } } - Index: playlist.c =================================================================== RCS file: /cvsroot/xine/gnome-xine/src/playlist.c,v retrieving revision 1.134 retrieving revision 1.135 diff -u -r1.134 -r1.135 --- playlist.c 12 Jul 2005 18:41:40 -0000 1.134 +++ playlist.c 13 Jul 2005 23:10:08 -0000 1.135 @@ -59,8 +59,10 @@ */ static int is_visible; +static GtkUIManager *pl_ui; static GtkListStore *pl_store; static GtkWidget *dlg, *tree_view; +static GtkTreeSelection *sel; static GtkWidget *repeat_button, *random_button; static char logo_mrl[1024]; static int logo_mode; @@ -78,6 +80,7 @@ static void set_mark_play_item (gboolean state); static void play_next (void); static int playlist_clip (int); +static void check_list_empty (void); static inline void remove_trailing_cr (char *str) { @@ -100,9 +103,8 @@ static int item_marked_current (GtkTreeIter *iter) { const char *p; - GValue v; + GValue v = {0}; int ret; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), iter, 3, &v); p = g_value_peek_pointer (&v); ret = p && *p; @@ -122,6 +124,7 @@ if (!logo_mode) se_eval (gse, "stop()", NULL, NULL, NULL, NULL); gtk_list_store_clear (pl_store); + check_list_empty (); } static void clear_cb (GtkWidget* widget, gpointer data) { @@ -137,21 +140,16 @@ if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { - GValue v; - memset (&v, 0, sizeof (GValue)); + GValue v = {0}; gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &v); mm_add (play_item_copy (g_value_peek_pointer (&v))); g_value_unset (&v); } } -static void del_cb (GtkWidget* widget, gpointer data) { - - GtkTreeView *tree = (GtkTreeView *) data; - GtkTreeSelection *sel; - GtkTreeIter iter; - - sel = gtk_tree_view_get_selection (tree); +static void del_cb (GtkWidget* widget, gpointer data) +{ + GtkTreeIter iter; if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { @@ -172,6 +170,7 @@ gtk_tree_selection_select_path (sel, path); gtk_tree_path_free (path); + check_list_empty (); } } @@ -203,16 +202,13 @@ static void edit_cb (GtkWidget* widget, gpointer data) { - GtkTreeView *tree = (GtkTreeView *) data; - GtkTreeSelection *sel = gtk_tree_view_get_selection (tree); - GtkTreeIter iter; + GtkTreeIter iter; if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { - GValue v; + GValue v = {0}; play_item_t *play_item, *item_copy; const char *title; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); @@ -321,11 +317,13 @@ if (defaultfile) free (fname); + check_list_empty (); return 1; ret0: if (defaultfile) free (fname); + check_list_empty (); return 0; } @@ -350,8 +348,7 @@ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (pl_store), &iter)) { do { - GValue vi; - memset (&vi, 0, sizeof (GValue)); + GValue vi = {0}; gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &vi); play_item_save (g_value_peek_pointer (&vi), f, 1); @@ -414,10 +411,9 @@ && gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pl_store), &iter, NULL, pos))) { - GValue v; + GValue v = {0}; play_item_t *play_item; - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); @@ -629,6 +625,7 @@ ret = indices[0]; gtk_tree_path_free (path); + check_list_empty (); return ret; } @@ -1148,10 +1145,8 @@ static gboolean row_activated_lcb (GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { - GtkTreeSelection *sel; GtkTreeIter iter; - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree_view)); if (gtk_tree_selection_get_selected (sel, NULL, &iter)) playlist_play (gtk_tree_path_get_indices (path)[0]); @@ -1280,9 +1275,21 @@ { play_item_t *item = play_item_new (NULL, ref->mrl, 0); gdk_threads_enter (); + if (ref_list_pos == -1) - ref_list_pos = playlist_get_list_pos (); - playlist_add (item, ++ref_list_pos); + { + GtkTreeIter iter; + ref_list_pos = cur_list_pos + 1; + playlist_add (item, ref_list_pos); + /* remove the item which triggered this reference event */ + gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pl_store), &iter, + NULL, cur_list_pos--); + gtk_list_store_remove (pl_store, &iter); + } + else + playlist_add (item, ++ref_list_pos); + + check_list_empty (); gdk_threads_leave (); } } @@ -1361,12 +1368,11 @@ { GtkTreeIter iter; play_item_t *play_item; - GValue v; + GValue v = {0}; gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pl_store), &iter, NULL, cur_list_pos); - memset (&v, 0, sizeof (GValue)); gtk_tree_model_get_value (GTK_TREE_MODEL (pl_store), &iter, 2, &v); play_item = g_value_peek_pointer (&v); @@ -1582,11 +1588,58 @@ mark_play_item (); } -void playlist_init (void) { +static const GtkActionEntry buttons_data[] = { + { "open", GTK_STOCK_OPEN, NULL, NULL, N_("Open a playlist file"), open_cb }, + { "saveas", GTK_STOCK_SAVE_AS, NULL, NULL, N_("Save the playlist file"), save_as_cb }, + { "clear", GTK_STOCK_CLEAR, NULL, NULL, N_("Clear the playlist"), clear_cb }, + { "fromfile", GTK_STOCK_NEW, NULL, NULL, N_("Add files to the playlist"), add_cb }, + { "edit", GTK_STOCK_EDIT, NULL, "<Control>E", N_("Edit the selected item"), edit_cb }, + { "delete", GTK_STOCK_DELETE, NULL, "Delete", N_("Delete the selected item"), del_cb }, + { "mm", GXINE_MEDIA_MARK, N_("Add to _media marks"), "<Control>M",N_("Add the selected item to the media marks list"), make_mediamark_cb }, + { "prev", GTK_STOCK_MEDIA_PREVIOUS, NULL, NULL, N_("Play previous item"), playlist_prev_cb }, + { "next", GTK_STOCK_MEDIA_NEXT, NULL, NULL, N_("Play next item"), playlist_next_cb }, +}; + +static const char buttons_structure[] = + "<ui>\n" + "<toolbar>\n" + "<toolitem action='open' />\n" + "<toolitem action='saveas' />\n" + "<toolitem action='clear' />\n" + "<separator />\n" + "<toolitem action='fromfile' />\n" + "<toolitem action='edit' />\n" + "<toolitem action='delete' />\n" + "<toolitem action='mm' />\n" + "<separator />\n" + "<toolitem action='prev' />\n" + "<toolitem action='next' />\n" + "</toolbar>\n" + "</ui>"; + +static void sel_changed_cb (GtkTreeSelection *sel, gpointer data) +{ + static const char *const items[] = { "edit", "delete", "mm", NULL }; + ui_mark_active (pl_ui, items, gtk_tree_selection_get_selected (sel, NULL, NULL)); +} + +static void check_list_empty (void) +{ + static const char *const items[] = { + "saveas", "clear", "prev", "next", NULL + }; + ui_mark_active (pl_ui, items, + gtk_tree_model_iter_n_children (GTK_TREE_MODEL (pl_store), + NULL)); +} - GtkWidget *hbox, *button, *scrolled_window; +void playlist_init (void) +{ + GtkWidget *hbox, *scrolled_window; + GtkBox *vbox; GtkCellRenderer *cell; GtkTreeViewColumn *column; + GError *error; is_visible = 0; cur_list_pos = -3; /* this will be clipped to 0 when Play is pressed */ @@ -1606,49 +1659,42 @@ g_signal_connect (G_OBJECT (dlg), "response", G_CALLBACK(close_cb), NULL); - /* - * top button bar (load/save/clear) - */ - - hbox = gtk_hbox_new (0, 2); - - button = gtk_button_new_from_stock (GTK_STOCK_OPEN); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(open_cb), tree_view); - gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 2); - button = gtk_button_new_from_stock (GTK_STOCK_SAVE_AS); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(save_as_cb), tree_view); - gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 2); - button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(clear_cb), tree_view); - gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 2); - button = ui_button_new_stock_mnemonic (GTK_STOCK_ADD, - _("Add to _media marks")); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(make_mediamark_cb), tree_view); - gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 2); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, - FALSE, FALSE, 2); + vbox = GTK_BOX (GTK_DIALOG (dlg)->vbox); /* - * init tree store + * init tree store & view */ - + pl_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING); - /* - * tree view widget to display playlist - */ - tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(pl_store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); g_signal_connect (G_OBJECT(tree_view), "row-activated", G_CALLBACK(row_activated_lcb), NULL); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + g_signal_connect (G_OBJECT (sel), "changed", + G_CALLBACK (sel_changed_cb), NULL); + + /* + * buttons + */ + + pl_ui = ui_create_manager ("file", dlg); + gtk_action_group_add_actions (ui_get_action_group (pl_ui), buttons_data, + G_N_ELEMENTS (buttons_data), tree_view); + gtk_ui_manager_add_ui_from_string (pl_ui, buttons_structure, -1, &error); + gtk_box_pack_start (vbox, gtk_ui_manager_get_widget (pl_ui, "/toolbar"), + FALSE, FALSE, 0); + gtk_action_group_connect_accelerators (ui_get_action_group (pl_ui)); + + sel_changed_cb (sel, NULL); + + /* + * install tree view + */ + cell = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (" ", cell, "text", 3, NULL); @@ -1684,8 +1730,7 @@ GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG (dlg)->vbox), scrolled_window, - TRUE, TRUE, 2); + gtk_box_pack_start (vbox, scrolled_window, TRUE, TRUE, 2); /* * checkboxes (repeat, random) @@ -1699,41 +1744,7 @@ random_button = gtk_check_button_new_with_mnemonic (_("_Random")); gtk_box_pack_start (GTK_BOX (hbox), random_button, FALSE, FALSE, 2); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, - FALSE, FALSE, 2); - - /* - * button bar - */ - - hbox = gtk_hbox_new (1, 2); - gtk_box_set_homogeneous (GTK_BOX(hbox), FALSE); - - button = gtk_button_new_from_stock (GTK_STOCK_ADD); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(add_cb), tree_view); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 2); - button = gtk_button_new_from_stock (GTK_STOCK_EDIT); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(edit_cb), tree_view); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 2); - button = gtk_button_new_from_stock (GTK_STOCK_DELETE); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(del_cb), tree_view); - gtk_box_pack_start (GTK_BOX(hbox), button, TRUE, TRUE, 2); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, - FALSE, FALSE, 2); - - /* icon only */ - button = ui_button_new_stock (GTK_STOCK_MEDIA_NEXT); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(playlist_next_cb), tree_view); - gtk_box_pack_end (GTK_BOX(hbox), button, FALSE, FALSE, 2); - button = ui_button_new_stock (GTK_STOCK_MEDIA_PREVIOUS); - g_signal_connect (G_OBJECT(button), "clicked", - G_CALLBACK(playlist_prev_cb), tree_view); - gtk_box_pack_end (GTK_BOX(hbox), button, FALSE, FALSE, 2); + gtk_box_pack_start (vbox, hbox, FALSE, FALSE, 2); sprintf (logo_mrl, "%s/logo.mpv", logodir); logo_mode = 1; @@ -1743,13 +1754,8 @@ /* * event handling */ - { - xine_event_queue_t *queue; - - queue = xine_event_new_queue (stream); - - xine_event_create_listener_thread (queue, xine_event_cb, NULL); - } + xine_event_create_listener_thread (xine_event_new_queue (stream), + xine_event_cb, NULL); { static const se_f_def_t defs[] = { |