GtkHScale: Jump-to-position by left-click instead of middle-click?
Hello everybody, I am new to GTK. I am trying to develop a small music player using GTK GStreamer. I use GtkHScale for the progress bar, which is responsible for updating the track progress allow user to move to different time position in the track. Everything works fine until now, except that I can not use left-click button to snap (or jump) to random position in the GtkHScale. Instead, I have to either drag or right-mouse-click. I have tried to solve this problem for several days and still can not figure out how to use left-click to jump to different position in the GtkHScale. I have searched through the GTK+ mail archive reference but found no place talking about this. Does anybody here know how to implement this functionality for GtkHScale? If so I hope you can give me a hint. Thank you and have a good day! -- Phong V. Cao phn...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkHScale: Jump-to-position by left-click instead of middle-click?
Hello everybody, I am new to GTK. I am trying to develop a small music player using GTK GStreamer. I use GtkHScale for the progress bar, which is responsible for updating the track progress allow user to move to different time position in the track. Everything works fine until now, except that I can not use left-click button to snap (or jump) to random position in the GtkHScale. Instead, I have to either drag or right-mouse-click. I have tried to solve this problem for several days and still can not figure out how to use left-click to jump to different position in the GtkHScale. I have searched through the GTK+ mail archive reference but found no place talking about this. Does anybody here know how to implement this functionality for GtkHScale? If so I hope you can give me a hint. Thank you and have a good day! -- Phong V. Cao phn...@gmail.com ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkHScale: Jump-to-position by left-click instead of middle-click?
Thank you David for your response. I am just a Gtk newbie so this question is a tough one for me. Sorry for cross-posting I won't do it again next time. Thank you and have a good day. On Saturday, November 19, 2011, David Nečas y...@physics.muni.cz wrote: Was it really necessary to cross-post this question to *four* mailing lists? On Sat, Nov 19, 2011 at 07:55:59AM -0500, Phong Cao wrote: I use GtkHScale for the progress bar, which is responsible for updating the track progress allow user to move to different time position in the track. Everything works fine until now, except that I can not use left-click button to snap (or jump) to random position in the GtkHScale. Instead, I have to either drag or right-mouse-click. The following is a kluge, but I suppose if you want the first button to invoke the same response as the middle button it should be all right (written in Python for brevity): from gi.repository import Gtk def button1to2(scale, event): if event.button == 1: event.button = 2 return False adj = Gtk.Adjustment.new(0.0, 0.0, 1.0, 0.001, 0.01, 0) scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj) scale.set_round_digits(3) scale.connect(button-press-event, button1to2) scale.connect(button-release-event, button1to2) window = Gtk.Window() window.add(scale) window.set_default_size(400, -1) window.show_all() window.connect(destroy, Gtk.main_quit) Gtk.main() Yeti -- Phong V. Cao phn...@gmail.com ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Insert different children into the same parent in GtkTreeStore?
Hello everybody, I am trying to write a music manager software that import the files according to artist and album. Each artist can have many album and each album can have many songs. Therefore, I decided to use GtkTreeStore to nest all the same-album songs into one parent (the album) and all the same-artist albums into one parent (the artist). Here is the screenshot of the software: Screenshot.pnghttp://www.dotphoto.com/Go.asp?l=42khamthienP=35183166AID=6391002IID=250817449 The problem here is, as you can see, I could not insert the albums with the same artist under that artist, and songs with the same album under that album. I wonder how can I achieve this? I tried to create a GtkTreeIter to iterate through the tree and compare the name of artist/album in the TreeStore with the artist/album I got from the stream but that did not help. Can anyone suggest any better way? Thank you for reading my message! I hope you guys have a good weekend! Best regards, Phong Cao, ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Insert different children into the same parent in GtkTreeStore?
Hello everybody, I am trying to write a music manager software that import the files according to artist and album. Each artist can have many album and each album can have many songs. Therefore, I decided to use GtkTreeStore to nest all the same-album songs into one parent (the album) and all the same-artist albums into one parent (the artist). Here is the screenshot of the software: Screenshot.pnghttp://www.dotphoto.com/Go.asp?l=42khamthienP=35183166AID=6391002IID=250817449 The problem here is, as you can see, I could not insert the albums with the same artist under that artist, and songs with the same album under that album. I wonder how can I achieve this? I tried to create a GtkTreeIter to iterate through the tree and compare the name of artist/album in the TreeStore with the artist/album I got from the stream but that did not help. Can anyone suggest any better way? Thank you for reading my message! I hope you guys have a good weekend! Best regards, Phong Cao, ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
How to show song's information into GtkTreeView?
Hello everybody, I am trying to develop a small music manager using GTK+ and GStreamer. However, I am currently unable to display the stream information (like artist, title, album, etc...) on the GtkTreeView. I do not know if anyone here has any experience developing software like this. But the idea behind this software is that when you click File - Open and then choosing a file from the GtkFileChooser, that music file will be imported into the GtkListStore. Attached with this email is the source code of the program. I think the problem relates to either GstTagList I used or GtkListStore. Thank you for helping me with this problem. I hope you guys have a good day! Best regards, Phong Cao ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
How to show song's information into GtkTreeView?
Hello everybody, I am trying to develop a small music manager using GTK+ and GStreamer. However, I am currently unable to display the stream information (like artist, title, album, etc...) on the GtkTreeView. I do not know if anyone here has any experience developing software like this. But the idea behind this software is that when you click File - Open and then choosing a file from the GtkFileChooser, that music file will be imported into the GtkListStore. Attached with this email is the source code of the program. I think the problem relates to either GstTagList I used or GtkListStore. Thank you for helping me with this problem. I hope you guys have a good day! Best regards, Phong Cao #include gtk/gtk.h #include gst/gst.h GtkTreeModel *rmodel; GtkListStore *rliststore; GtkWidget *rtreeview; GtkTreeIter iter; void print_one_tag(const GstTagList *list, const gchar *tag, gpointer user_data) { /* Import the song info (artist, title, album, etc...) into a GtkListStore called rliststore */ gint i, num; num = gst_tag_list_get_tag_size(list, tag); for (i = 0; i num; ++i) { const GValue *val; val = gst_tag_list_get_value_index(list, tag, i); if (tag == title) { gtk_list_store_set(rliststore, iter, 1, g_value_get_string(val), -1); } else if (tag == artist) { gtk_list_store_set(rliststore, iter, 2, g_value_get_string(val), -1); } else if (tag == album) { gtk_list_store_set(rliststore, iter, 3, g_value_get_string(val), -1); } } } void import_media_activated(GtkMenuItem *item, GtkListStore *rliststore) { /* This is the call-back function for the File - Open GtkMenuItem. It shows the user a GtkFileChooser to choose a music file and then import that file into the GtkListStore called rliststore using the print_one_tag function defined above */ GtkWidget *dialog; GSList *fileuris; GstElement *play; GstTagList *tags = NULL; GstMessage *msg; const gchar *tag; dialog = gtk_file_chooser_dialog_new(Import File(s)..., NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); gint result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_OK) { fileuris = gtk_file_chooser_get_uris(GTK_FILE_CHOOSER(dialog)); } while (fileuris != NULL) { play = gst_element_factory_make(playbin, play); g_object_set(G_OBJECT(play), uri, fileuris-data, NULL); gst_element_set_state(play, GST_STATE_PAUSED); msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS(play), GST_CLOCK_TIME_NONE, GST_MESSAGE_TAG); gst_message_parse_tag(msg, tags); /* gst_tag_list_foreach(tags, print_one_tag, liststore); */ gtk_list_store_append(rliststore, iter); gst_tag_list_foreach(tags, print_one_tag, NULL); fileuris = fileuris-next; gst_message_unref(msg); } gtk_widget_destroy(dialog); gst_element_set_state(play, GST_STATE_NULL); gst_object_unref(play); } int main(int argc, char *argv[]) { /* This is the main program */ gtk_init(argc, argv); gst_init(argc, argv); /* Create (mainwindow) */ GtkWidget *mainwindow; mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(mainwindow), Dingo Music Player); /* Create the top menubar */ GtkWidget *file, *edit, *view, *playback, *help, *separator; GtkWidget *menubar, *filemenu, *editmenu, *viewmenu, *playmenu, *helpmenu; GtkWidget *importmedia, *importplaylist, *close, *quit; GtkWidget *selectall, *selectnone, *remove, *deldrive, *containfolder, *properties, *preferences; GtkWidget *showbrowser, *fullscreen, *showvideo, *showsub; GtkWidget *play, *stop, *next, *previous, *repeat, *repsingle, *repall, *repmenu, *repoff; GtkWidget *about; GtkAccelGroup *group; group = gtk_accel_group_new(); menubar = gtk_menu_bar_new(); file = gtk_menu_item_new_with_label(File); edit = gtk_menu_item_new_with_label(Edit); view = gtk_menu_item_new_with_label(View); playback = gtk_menu_item_new_with_label(Play); help = gtk_menu_item_new_with_label(Help); filemenu = gtk_menu_new(); editmenu = gtk_menu_new(); viewmenu = gtk_menu_new(); playmenu = gtk_menu_new(); helpmenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit), editmenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), viewmenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(playback), playmenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), helpmenu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), edit); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), view); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), playback); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), help); /* -- Create File
Re: gtk-list Digest, Vol 86, Issue 9
Thank you Victor! I have written a recursive function to read all the directories and files. #include gtk/gtk.h void read_all_files(const gchar* file) { GDir *dir = g_dir_open(file, 0, NULL); while ((file = g_dir_read_name(dir))) { if (!g_file_test(file, G_FILE_TEST_IS_DIR)) { g_print(%s was opened\n, file); } else { read_all_files(file); } } } However, it seems that this function still only reads the 1st level of subdirectory and print out all the files there and not reading any file at 2nd, 3rd, 4th, etc... levels. Do you have any suggestion on how to improve this function so that it will import every single file and all subfolders nested deeply inside the main folder? On Mon, Jun 6, 2011 at 8:00 AM, gtk-list-requ...@gnome.org wrote: Send gtk-list mailing list submissions to gtk-list@gnome.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.gnome.org/mailman/listinfo/gtk-list or, via email, send a message with subject or body 'help' to gtk-list-requ...@gnome.org You can reach the person managing the list at gtk-list-ow...@gnome.org When replying, please edit your Subject line so it is more specific than Re: Contents of gtk-list digest... Today's Topics: 1. GtkFileChooser: How to get names of files that are inside subfolders? (Phong Cao) 2. Re: GtkFileChooser: How to get names of files that are inside subfolders? (Victor Ananjevsky) -- Message: 1 Date: Mon, 6 Jun 2011 01:29:17 -0400 From: Phong Cao phn...@gmail.com To: gtk-list@gnome.org, gtk-app-devel-l...@gnome.org Subject: GtkFileChooser: How to get names of files that are inside subfolders? Message-ID: banlktim1zzanob9zg7tnfoz95qpbd3a...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hello everybody, I am trying to develop a music manager that lets the users import all audio files from a folder. That folder may contain many subfolders, and each subfolder may contain many files. I know that I need to create a GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled so that the user can choose folders instead of files. However, I do not know how to make this GtkFileChooser selects/imports all the files available in that directory (not only the files that are shown in the GtkFileChooser but the files that are deeply contained inside subfolders). Thank you for reading my questions! I hope you guys have a good day! -- next part -- An HTML attachment was scrubbed... URL: http://mail.gnome.org/archives/gtk-list/attachments/20110606/73db2c97/attachment.html -- Message: 2 Date: Mon, 6 Jun 2011 08:47:02 +0300 From: Victor Ananjevsky anana...@gmail.com To: gtk-list@gnome.org Subject: Re: GtkFileChooser: How to get names of files that are inside subfolders? Message-ID: 20110606084702.54e445cf.anana...@gmail.com Content-Type: text/plain; charset=US-ASCII On Mon, 6 Jun 2011 01:29:17 -0400 Phong Cao phn...@gmail.com wrote: Hello everybody, I am trying to develop a music manager that lets the users import all audio files from a folder. That folder may contain many subfolders, and each subfolder may contain many files. I know that I need to create a GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled so that the user can choose folders instead of files. However, I do not know how to make this GtkFileChooser selects/imports all the files available in that directory (not only the files that are shown in the GtkFileChooser but the files that are deeply contained inside subfolders). g_dir_open()/g_dir_read_name()/g_dir_close() + recursion Thank you for reading my questions! I hope you guys have a good day! -- Victor Ananjevsky anana...@gmail.com -- ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list End of gtk-list Digest, Vol 86, Issue 9 *** ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
GtkFileChooser: How to get names of files that are inside subfolders?
Hello everybody, I am trying to develop a music manager that lets the users import all audio files from a folder. That folder may contain many subfolders, and each subfolder may contain many files. I know that I need to create a GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled so that the user can choose folders instead of files. However, I do not know how to make this GtkFileChooser selects/imports all the files available in that directory (not only the files that are shown in the GtkFileChooser but the files that are deeply contained inside subfolders). Thank you for reading my questions! I hope you guys have a good day! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkFileChooser: How to get names of files that are inside subfolders?
Hello everybody, I am trying to develop a music manager that lets the users import all audio files from a folder. That folder may contain many subfolders, and each subfolder may contain many files. I know that I need to create a GtkFileChooser Dialog with GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER enabled so that the user can choose folders instead of files. However, I do not know how to make this GtkFileChooser selects/imports all the files available in that directory (not only the files that are shown in the GtkFileChooser but the files that are deeply contained inside subfolders). Thank you for reading my questions! I hope you guys have a good day! ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
GTK+ Warning: Can't set a parent on widget which has a parent!!
Hello everybody, I am trying to write the interface for my music manager using GTK+. The program was compiled successfully. However, when I executed it, the machine returned errors: (dingo_draft:6462): Gtk-WARNING **: Can't set a parent on widget which has a parent(dingo_draft:6462): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed**Gtk:ERROR:/build/buildd/gtk+2.0-2.20.1/gtk/gtkwidget.c:8760:gtk_widget_real_map: assertion failed: (gtk_widget_get_realized (widget))Aborted Attached with this email is the source code of the program. Please note that this is *just the interface written in GTK+*. I did not add any signals in yet. I think there might be some problems with the GTK+ functions, but I could not locate where the errors occured. Thank you for helping me with this problem!! Hope you guys have a good weekend! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GTK+ Warning: Can't set a parent on widget which has a parent
Hello everybody, I am trying to write the interface for my music manager using GTK+. The program was compiled successfully. However, when I executed it, the machine returned errors: (dingo_draft:6462): Gtk-WARNING **: Can't set a parent on widget which has a parent(dingo_draft:6462): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed**Gtk:ERROR:/build/buildd/gtk+2.0-2.20.1/gtk/gtkwidget.c:8760:gtk_widget_real_map: assertion failed: (gtk_widget_get_realized (widget))Aborted Attached with this email is the source code of the program. Please note that this is *just the interface written in GTK+*. I did not add any signals in yet. I think there might be some problems with the GTK+ functions, but I could not locate where the errors occured. Thank you for helping me with this problem!! Hope you guys have a good weekend! /* This is the interface design draft for the media player /* This does not include the signals for widgets. Just a plain draft */ #include gtk/gtk.h int main(int argc, char *argv[]) { /* Initialize gtk+ gstreamer */ gtk_init(argc, argv); /* Create mainwindow (mainwindow) */ GtkWidget *mainwindow; mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(mainwindow), Music Manager); /* Create the vbox containing searchbox song list (treevbox) */ GtkWidget *searchbox, *treesong, *scrollsong, *treevbox; GtkCellRenderer *namerender, *timerender; treesong = gtk_tree_view_new(); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treesong), FALSE); namerender = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treesong), -1, Songs, namerender, text, 0, NULL); timerender = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treesong), -1, Time, timerender, text, 1, NULL); /* some problem here */ scrollsong = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollsong), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollsong), treesong); searchbox = gtk_entry_new(); treevbox = gtk_vbox_new(TRUE, 0); gtk_box_pack_start_defaults(GTK_BOX(treevbox), searchbox); gtk_box_pack_start_defaults(GTK_BOX(treevbox), scrollsong); /* Create the song info section (infohbox) */ GtkWidget *songname, *songinfo, *coverart; GtkWidget *infohbox, *imagevbox; coverart = gtk_image_new_from_file(music-notes.png); songname = gtk_label_new(iSong Name/i); songinfo = gtk_label_new(bArtist:/b \n bTrack/b \n bAlbum/b \n bYear/b \n bGenre/b \n bRating/b); infohbox = gtk_hbox_new(TRUE, 0); imagevbox = gtk_vbox_new(TRUE, 0); gtk_box_pack_start_defaults(GTK_BOX(imagevbox), coverart); gtk_box_pack_start_defaults(GTK_BOX(imagevbox), songname); gtk_box_pack_start_defaults(GTK_BOX(infohbox), imagevbox); gtk_box_pack_start_defaults(GTK_BOX(infohbox), songinfo); /* Create drawing area for video display (previewarea) */ GtkWidget *previewarea; previewarea = gtk_drawing_area_new(); gtk_widget_set_size_request(previewarea, 300, 200); /* Create actions tree view (ltreeview) */ enum { COL_ICON = 0, COL_ACTION, NUM_COLS }; GtkCellRenderer *lrenderer; GtkTreeModel *lmodel; GtkWidget *ltreeview; GtkListStore *lliststore; GtkTreeIter liter; ltreeview = gtk_tree_view_new(); lrenderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ltreeview), -1, Icon, lrenderer, pixbuf, COL_ICON, NULL); lrenderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ltreeview), -1, Actions, lrenderer, text, COL_ACTION, NULL); lliststore = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING); gtk_list_store_append(lliststore, liter); gtk_list_store_set(lliststore, liter, COL_ICON, gdk_pixbuf_new_from_file(now-playing.png, NULL), COL_ACTION, Now Playing, -1); gtk_list_store_append(lliststore, liter); gtk_list_store_set(lliststore, liter, COL_ICON, gdk_pixbuf_new_from_file(music.png, NULL), COL_ACTION, Music, -1); gtk_list_store_append(lliststore, liter); gtk_list_store_set(lliststore, liter, COL_ICON, gdk_pixbuf_new_from_file(video.png, NULL), COL_ACTION, Videos, -1); gtk_list_store_append(lliststore, liter); gtk_list_store_set(lliststore, liter, COL_ICON, gdk_pixbuf_new_from_file(playlist.png, NULL), COL_ACTION, Playlists, -1); lmodel = GTK_TREE_MODEL(lliststore); gtk_tree_view_set_model(GTK_TREE_VIEW(ltreeview), lmodel); /* g_object_unref(lmodel); */ /* Create the top control bar (controlhbox) */ GtkWidget *prevbutton, *nextbutton, *hscale, *cursong; GtkWidget *curpos, *duration, *volumebutton, *playbutton; GtkAdjustment *progress, *volumeadj; GtkWidget *buttonhbox, *proghbox, *infovbox,
Re: GTK+ Warning: Can't set a parent on widget which has a parent
Thank you Nicola. I finally got it fixed! Yeah I did not pay attention to the parents of songinfo... On Fri, Jun 3, 2011 at 6:08 AM, Nicola Fontana n...@entidi.it wrote: Il giorno Fri, 3 Jun 2011 04:08:22 -0400 Phong Cao phn...@gmail.com ha scritto: Hello everybody, I am trying to write the interface for my music manager using GTK+. The program was compiled successfully. However, when I executed it, the machine returned errors: (dingo_draft:6462): Gtk-WARNING **: Can't set a parent on widget which has a parent Hi Phong, you are adding songinfo to infohbox and to vpaned. Choose a single container or duplicate the widget. Ciao. -- Nicola ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list