Re: gtk_tree_view/store, best way to select all nodes of a branch
My current simple solution is as follows: I use the gtk_tree_model_foreach() function and pass some user data with the current major number of the tree-path. Inside the foreach-function I use gtk_tree_path_to_string, where I check if the first number is identical to the user data. This works, but I have to use a lot of string functions. Is there a smarter way to do that with less overhead? regards Arne ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_tree_view/store, best way to select all nodes of a branch
On Wed, Sep 12, 2012 at 10:40:11AM +0200, Arne Pagel wrote: My current simple solution is as follows: I use the gtk_tree_model_foreach() function and pass some user data with the current major number of the tree-path. Inside the foreach-function I use gtk_tree_path_to_string, where I check if the first number is identical to the user data. This works, but I have to use a lot of string functions. Is there a smarter way to do that with less overhead? Use gtk_tree_selection_select_range(). You already have the start path, so, how to get the end path? Use gtk_tree_model_iter_n_children() and gtk_tree_model_iter_nth_child() recursively to always move to the last child in the branch. If your tree is only two-level (as it seems to be) you do not even need to recurse. Regards, Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
populate gtk tree view from outside
Dear friends, I have defined a treeview model as follows: enum { COL_FIRST_NAME = 0, COL_LAST_NAME, COL_YEAR_BORN, NUM_COLS } ; static GtkTreeModel * create_and_fill_model (void) { GtkTreeStore *treestore; GtkTreeItertoplevel, child; treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); int i; FILE *fauth; char alst[10][500], buffer[500]; fauth=fopen(fauth.dat,r); if(!fauth){ printf(fauth failed\n); } while(fgets(buffer,500,fauth)){ strcpy(alst[i],buffer); i++; } fclose(fauth); for (i = 0; i 10; i++){ gtk_tree_store_append(treestore, toplevel, NULL); gtk_tree_store_set(treestore, toplevel, COL_FIRST_NAME, alst[i], COL_LAST_NAME, Average, COL_YEAR_BORN, (guint) 1962, -1); } return GTK_TREE_MODEL(treestore); } static GtkWidget * create_view_and_model (void) { GtkTreeViewColumn *col; GtkCellRenderer *renderer; GtkWidget *view; GtkTreeModel*model; view = gtk_tree_view_new(); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, First Name); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, text, COL_FIRST_NAME); gtk_tree_view_column_pack_start(col, renderer, TRUE); model = create_and_fill_model(); gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); g_object_unref(model); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), GTK_SELECTION_NONE); return view; } //For brevity, I have cut out the 2nd and 3rd column In a different function, I have strAuth = gtk_entry_get_text(GTK_ENTRY(e-entryAuth)); strEditor = gtk_entry_get_text(GTK_ENTRY(e-entryEditor)); Is it possible to add these strAuth, strEditor in those treeview's 1st and 2nd column? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: populate gtk tree view from outside
On 09/12/2012 12:21 PM, Rudra Banerjee wrote: [..] strAuth = gtk_entry_get_text(GTK_ENTRY(e-entryAuth)); strEditor = gtk_entry_get_text(GTK_ENTRY(e-entryEditor)); Is it possible to add these strAuth, strEditor in those treeview's 1st and 2nd column? just acquire an iterator at the right position, and set the columns, for example gtk_tree_model_get_iter_first(GTK_TREE_MODEL(treestore), iter); gtk_tree_store_set(treestore, iter, COL_FIRST_NAME, strAuth, COL_LAST_NAME, strEditor, -1); regards, Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: populate gtk tree view from outside
On 09/12/2012 06:30 PM, Rudra Banerjee wrote: Oliver, Thanks for your reply. The problem basically is to pass on the function argument from one to other. you need to create a header file (main.h) that has the enum, and extern GtkListStore *treestore; in main.c define GtkListStore *treestore; somewhere in the top of fthe file, *not* inside a function. then include this both in main.c and in otherfile.c like #include main.h Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: populate gtk tree view from outside
Oliver, Thanks a lot. Its working properly. Only change that I have made is using gtk_tree_store_append in place of gtk_tree_model_get_iter_first. Thanks a lot again. Regards, On Wed, 2012-09-12 at 21:31 +0200, Olivier Sessink wrote: On 09/12/2012 06:30 PM, Rudra Banerjee wrote: Oliver, Thanks for your reply. The problem basically is to pass on the function argument from one to other. you need to create a header file (main.h) that has the enum, and extern GtkListStore *treestore; in main.c define GtkListStore *treestore; somewhere in the top of fthe file, *not* inside a function. then include this both in main.c and in otherfile.c like #include main.h Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Gtk.DrawingArea: Port to python3/gtk3
Hi, How should I convert this gtk3? self.area = Gtk.DrawingArea() #Paints the piano roll (Where the notes are) def paint_widget(self): if self.area.window == None: return colormap = self.area.get_colormap() if self.gc_background == None: color_background = colormap.alloc_color('#FF', True, True) self.gc_background = self.area.window.new_gc() self.gc_background.set_foreground(color_background) -- Patrick Shirkey Boost Hardware Ltd ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list