Re: gtk_text_buffer_delete ?
> - Original Message - >> From: "Stefan Salewski" >> Sent: Wednesday, October 7, 2015 7:36:05 PM > >> On Wed, 2015-10-07 at 13:14 +0200, Pierre Wieser wrote: >>> I so connected to the 'changed' signal of the GtkTextBuffer, >> >> Maybe try connecting to insert-text signal -- changed signal may be >> emitted again when you delete. See >> >> http://stackoverflow.com/questions/2791035/how-do-i-set-buffer-limit-for >> -gtk-text-view-in-c > > Humm.. I've seen this thread too, but didn't understand the proposed behavior. Oop's. Sorry ! I've clicked on the bad button !! Please, do not consider this mail, as I have to worked a bit more on it.. Thanks Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_text_buffer_delete ?
On Wed, 2015-10-07 at 15:05 +0200, Stefan Salewski wrote: > On Wed, 2015-10-07 at 13:14 +0200, Pierre Wieser wrote: >> Hello, >> >> On the application I'm currently working on [1], I want limit the size >> of the >> text entered in a GtkTextBuffer to those saved in the DBMS, so 4096 >> chars. > > Seen that: > > http://www.gtkforums.com/viewtopic.php?t=1012 > > Very similar to your solution, but I think that was GTK2, and your is > GTK3. Hi Stefan, Thanks for your interest, but the thread you point to is actually the one on which I based my own code. I do not think that GTK2 vs GTK3 is a point in this matter, do you ? > No other idea, sorry. And Google has not been my friend further... ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_text_buffer_delete ?
> On the application I'm currently working on [1], I want limit the size of the > [...] I omit the application link, for reference ;) [1] https://github.com/trychlos/openbook/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk_text_buffer_delete ?
Hello, On the application I'm currently working on [1], I want limit the size of the text entered in a GtkTextBuffer to those saved in the DBMS, so 4096 chars. I so connected to the 'changed' signal of the GtkTextBuffer, and the handler is : static void on_notes_changed( GtkTextBuffer *buffer, void *empty ) { static const gchar *thisfn = "my_utils_on_notes_changed"; static const gint MAX_LENGTH = 4096; static gboolean in = FALSE; gint count; GtkTextIter start, end; /* prevent an infinite recursion */ if( !in ){ count = gtk_text_buffer_get_char_count( buffer ); if( count >= MAX_LENGTH ){ /* * this code works, but emit the following Gtk-Warning: * * Invalid text buffer iterator: either the iterator is * uninitialized, or the characters/pixbufs/widgets in the * buffer have been modified since the iterator was created. * You must use marks, character numbers, or line numbers to * preserve a position across buffer modifications. * You can apply tags and insert marks without invalidating * your iterators, but any mutation that affects 'indexable' * buffer contents (contents that can be referred to by character * offset) will invalidate all outstanding iterators */ gtk_text_buffer_get_iter_at_offset( buffer, &start, MAX_LENGTH-1 ); /*gtk_text_iter_backward_char( &start );*/ /*gtk_text_buffer_get_iter_at_offset( buffer, &end, count );*/ gtk_text_buffer_get_end_iter( buffer, &end ); /*gtk_text_iter_backward_char( &end );*/ in = TRUE; g_debug( "%s: count=%d, start=%d, end=%d", thisfn, count, gtk_text_iter_get_offset( &start ), gtk_text_iter_get_offset( &end )); gtk_text_buffer_delete( buffer, &start, &end ); in = FALSE; } } } As stated in the comment, the code works (the size if actually limited to 4095 chars), but each execution of gtk_text_buffer_delete() triggers the well-known warning "Invalid text buffer iterator". I am a bit stucked here, because I do not understand why this happens, as the buffer is not modified between taking the iters and deleting the content... Can anyone help me in this matter ? Thanks in advance. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Modifying the border color of a GtkEntry
Hi all, In the Gtk3 application I am writing, I'd wish show to the user the erroneous fields by setting the border color of the GtkEntry widgets to a specific (e.g. red) color. What I've done: - allocate a new CSSProvider, loads my .css file and try to apply it: void my_utils_entry_set_valid( GtkEntry *entry, gboolean valid ) { static const gchar *thisfn = "my_utils_entry_set_valid"; static GtkCssProvider *css_provider = NULL; GError *error; GtkStyleContext *style; if( !css_provider ){ css_provider = gtk_css_provider_new(); error = NULL; if( !gtk_css_provider_load_from_path( css_provider, PKGUIDIR "/ofa.css", &error )){ g_warning( "%s: %s", thisfn, error->message ); g_error_free( error ); g_clear_object( &css_provider ); } } if( css_provider ){ style = gtk_widget_get_style_context( GTK_WIDGET( entry )); if( valid ){ gtk_style_context_remove_class( style, "ofaInvalid" ); gtk_style_context_add_class( style, "ofaValid" ); } else { gtk_style_context_remove_class( style, "ofaValid" ); gtk_style_context_add_class( style, "ofaInvalid" ); } gtk_style_context_add_provider( style, GTK_STYLE_PROVIDER( css_provider ), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION ); } } And I wrote a small .css file: .ofaInvalid { border-color: red; color: red; } What I see is that only the font color is changed to red, not the border color, whatever be the state of the widget (active, focus, normal or so). So the code seems to be correct, but I do not understand why the border color is not changed ? (because the font color is obviously only useful when the field is not empty). So my questions are: - why my stylesheet doesn't modify the border color of the Gtkentry ? - how to modify the border color ? Thanks in advance for your help. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkApplicationWindow and its menubar
> Test you stuff in python first, then move it to c/c++ if need be. This > allows for rapid testing of what you really need to do. Whatever you > are trying to do, it is possible, for complete menubar, menus, menuitems > on any platform. Windowing APIs for windows, linux, mac all can handle > this. Thanks for your help, David, but I was not searching how to build a menubar in a Gtk application. I've already done this in Nautilus-Actions whose I am the maintainer. What I am searching for is an explanation on how to use the new Gtk3 API, and how it can suit my needs, which are rather simple here: change all the menubar depending of the context of the application.. So the question stays opened. I'd be very pleased if someone could explains the rationale with this API.. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkApplicationWindow and its menubar
Hi all, I am starting with a small app which will handle documents. I want this app has two different menubars : - a first one when there is no document - another one when the document is opened. I have tried to use gtk_application_set_menubar with two different GMenuModel, but no luck: the GtkApplicationWindow menubar never changes. After having searched in the sources, I found that the GtkWidget menubar is automatically rebuilt from a GMenu menubar_section. But the menubar_section itself is initially built in real_realize, thenonly rebuilt when some gtk-shell settings changes (notify::gtk-shell-shows-menubar exactly, but this not relevant here). So it appears to me that it is just impossible to replace the menubar. Am I right ? Is it the expected behavior ? As a side effect, I do not understand the rationale behind gtk_application_set_menubar: why are we allowed to change the GMenuModel if the visible GtkWidget is not updated ? Thanks for some explanations.. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkAssistant : bug or feature ?
Hi all, When working with GtkAssistant, I used to find the widgets of the pages as children of the GtkAssistant by doing a recursive search starting from the GtkAssistant container. But, as of Gtk+ 3.2 (at least), I have found that GtkAssistant is now an empty container, and widgets are to be searched for as children of the pages. I think this behavior (or is it a bug ?) is less intuitive that the previous one: as widgets are described as children of the GtkAssistant in the GtkBuilder definition, it appears logical to me to search for these widgets inside of the GtkAssistant at runtime. And I did not find any reference to this in the developer manuals. Or is this a better, more "standard" way of getting a widget inside of a GtkAssistant ? Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Select root folder in GtkfileChooser
- "Ardhan Madras" wrote: > Hi, > I got similar issues when running your codes, also i was trying to > produce this 'error' by selecting 'Choose Download Folder:' in Mozilla > Firefox's preferences. My system version: > > [think...@thinkpad gtk+]$ pkg-config --modversion gtk+-2.0 glib-2.0 > 2.18.9 > 2.22.5 > > If you try more than a slash like '//' or '///' it's works, it's > perfectly legal for naming '///' as root dir. ;p > > Ardhan > > --- pwie...@trychlos.org wrote: > > From: Pierre Wieser > To: gtk-app-devel-list > Subject: Select root folder in GtkfileChooser > Date: Fri, 9 Apr 2010 00:41:52 +0200 (CEST) > > Hi > > In Nautilus-Actions, I need to let my users select folders, including > root folder ('/'). > > In a GtkFileChooserDialog, there is obviously no way to select the > root > folder by clicking on it, because it has no parent. > > But when I enter "/" in the location entry, and click on Open button, > I get the message: > "The folder could not be created > Error creating directory: File exists." > > Sample code to reproduce this is below: > > GtkWidget *dialog; > gchar *path; > > dialog = gtk_file_chooser_dialog_new( _( "Select a folder" ), > NULL, > GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, > GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, > GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, > NULL ); > > gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), "/" ); > > if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){ > path = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog > )); > g_debug( "nact_ifolders_tab_on_add_folder_clicked: path=%s", > path > ); > g_free( path ); > } > > gtk_widget_destroy( dialog ); > > Is this a bug (and so I should open it Bugzilla) ? > Or is there something missing in my code ? > Well, one cannot really wait for the user enter '//' or even '///' when he just wants '/'. I must admit that I hoped that my code was not right... I am going to wait one or two days to see if one of Gtk maintainers has an opinion about this issue. And I'll open this in Bugzilla. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Select root folder in GtkfileChooser
Hi In Nautilus-Actions, I need to let my users select folders, including root folder ('/'). In a GtkFileChooserDialog, there is obviously no way to select the root folder by clicking on it, because it has no parent. But when I enter "/" in the location entry, and click on Open button, I get the message: "The folder could not be created Error creating directory: File exists." Sample code to reproduce this is below: GtkWidget *dialog; gchar *path; dialog = gtk_file_chooser_dialog_new( _( "Select a folder" ), NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL ); gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), "/" ); if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){ path = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog )); g_debug( "nact_ifolders_tab_on_add_folder_clicked: path=%s", path ); g_free( path ); } gtk_widget_destroy( dialog ); Is this a bug (and so I should open it Bugzilla) ? Or is there something missing in my code ? Thanks in advance for your help. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Gtk+: multi-threaded or not ?
Hi all, Reading this list, I see some questions which talk about "threads": main thread, event thread, and so on. I was not conscious Gtk+ was multithreaded. I'm conscious of asynchronous code with the mail loop and idle function (which are rather in Glib, I believe ?), but really not of multithread. So is Gtk multithreaded, or not ? Because if it is, I will have to deal with mutex, semaphores and all the usual soup!! Thanks in advance Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Read-only controls
Hi, Is there a standard Gtk way of defining controls as read-only at runtime ? In my user interface, I have entries, radio and toggle buttons, and a combo list ; I would set them as read-only when the current item cannot be updated for a reason or another. For now, I set all these controls as insensitive, but there is a real semantic difference between "a field is not available - doesn't make sense here" and "a field cannot be modified", and I'd wish my UI reflects this difference. What should I do for that ? Thanks in advance. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkTreeStore and row deletion
- "David Nečas" a écrit : > On Wed, Sep 02, 2009 at 02:56:12PM +0200, pwie...@trychlos.org wrote: > > - "Kristian Rietveld" a écrit : > > > > > I don't fully get the problem you are describing. If I understand > it > > > correctly, you have a tree model where each node points to a > GObject. > > > Isn't it the case that when a row is destroyed that contains a > > > G_TYPE_OBJECT column, this will unref the value in that column? > > > > Are you affirmative about that ? > > Definitely. > > > It would be great in this case, but appears as undocumented. Or, is > it ? > > However, in the previous version, when I unreffed the object from > my > > GSList, I don't have observed that same object be (silently) > unreffed > > a second time when the row was deleted. I think Gtk would have > warned > > me in this case... > > Maybe you forgot to release new references from gtk_tree_model_get() > (it > produces copies, i.e. if you get an object you get a new reference; > similarly, if you get a string you get a newly allocated copy). > > Yeti Oop's! From gtk_tree_store_set(): "The value will be copied or referenced by the store if appropriate". I may have missed this ! I will check this this evening, by counting instance_init() and instance_dispose() respective occurences. Thanks a lot for your explanations. Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GnomeVFS migration
- "Johannes Schmid" a écrit : > Hi! > > > > In the process of migrating from GnomeVFS to GVFS, I've to replace > gnome_vfs_uri_get_host_name() and gnome_vfs_uri_get_user_name() > functions. > > g_get_host_name() and g_get_user_name() are your friends. Please > don't > ask such questions on desktop-devel-list as it's mainly for general > desktop plan and discussion. Use gtk-app-devel-list or something like > that instead. > > Thanks, > Johannes oop's, sorry for the mistake about the lists. About the functions, I may have missed something, but g_get_host_name() and g_get_user_name() returns current host and user. gnome_vfs_uri_get_host_name() and gnome_vfs_uri_get_user_name() are functions which extract some part of a given uri - not really the same thing... Do you have another idea, please ? Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkAssistant vs. GtkFileChooserWidget
> Date: Sun, 12 Jul 2009 13:56:57 +0200 (CEST) > From: Pierre Wieser > Subject: GtkAssistant vs. GtkFileChooserWidget > To: gtk-app-devel-list@gnome.org > > Hi all, > > I'm building a GtkAssistant which embeds a GtkFileChooserWidget > in one of the content pages. > > My problem is when I run the assistant for the second times, the > GtkfileChooserWidget doesn't display at all. Below the sample code > which reproduces the problem : > > enum { > ASSIST_PAGE_INTRO = 0, > ASSIST_PAGE_FILES_SELECTION, > ASSIST_PAGE_DONE > }; > > static void > on_cancel( GtkAssistant *assistant, gpointer user_data ) > { > gtk_widget_hide_all( GTK_WIDGET( assistant )); > gtk_main_quit(); > } > > /** > * Run the assistant. > */ > void > nact_assist_import_run( void ) > { > static GtkBuilder *xml = NULL; > if( !xml ){ > xml = gtk_builder_new(); > gtk_builder_add_from_file( xml, GLADEDIR > "/nautilus-actions-config.ui", NULL ); > } > GtkAssistant *assistant = GTK_ASSISTANT( gtk_builder_get_object( xml, > "ImportAssistant" )); > > GtkWidget *intro = gtk_assistant_get_nth_page( assistant, > ASSIST_PAGE_INTRO ); > gtk_assistant_set_page_complete( assistant, intro, TRUE ); > > GtkWidget *selector = gtk_assistant_get_nth_page( assistant, > ASSIST_PAGE_INTRO ); > gtk_assistant_set_page_complete( assistant, selector, TRUE ); > > g_signal_connect( G_OBJECT( assistant ), "cancel", G_CALLBACK( > on_cancel ), NULL ); > gtk_widget_show_all( GTK_WIDGET( assistant )); > gtk_main(); > } > > Note that if I initialize a new GtkBuilder _each time_ I run the > assistant, then all works fine. But I feel this work-around as a > waste of resources... > > Note also that embedding other widgets (combobox or so) is fine, > and doesn't show the same problem. > > Could someone be kind enough to explain me what is wrong in the code > ? > Or what is wrong in embedding a GtkFileChooserWidget in a GtkAssistant > ? > > Thanks in advance > Regards > Pierre > > -- I have just filled up a bugzilla report : http://bugzilla.gnome.org/show_bug.cgi?id=589746 Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkAssistant flow question
> Date: Sun, 12 Jul 2009 13:25:48 +0200 (CEST) > From: pwie...@trychlos.org > Subject: GtkAssistant flow question > To: gtk-app-devel-list@gnome.org > > Hi, > > I have a simple GtkAssistant with : > - one intro page > - two content pages > - one confirm page > - one summary page. > > All works fine : the confirm page has 'Cancel' and 'Apply' buttons, > and the summary page has only a 'Close' button. > > Of course (or is it only obvious for me ?), I'd wish display on the > summary page the result of the work done when the user has clicked on > the Apply button. > > But it appears that the next page is computed, and so the 'prepare' > message is sent, _before_ the 'apply' message is itself emitted. > > So, when I handle the prepare message for the summary page, I don't > know what is the result of the operations, as they have not be done > yet. > > As a work-around, I have to do the work at the very beginning of the > prepare handler. > > And so handling the apply message becomes useless. > > IMHO, the usual programmer does want 'apply' its operations before > 'preparing' the display of the summary page. > > As the GtkAssistant cannot be considered as new (appeared in 2.9 or > so), > it is surely not a bug. But I don't understand the rationale behind > this. > Could someone explain it to me ? Why this order has it be choosen ? > And how do we should handle the apply message ? > > Thanks in advance. > Regards > Pierre I have just filled up a report in bugzilla, and joined a patch. See http://bugzilla.gnome.org/show_bug.cgi?id=589745 Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkAssistant vs. GtkFileChooserWidget
Hi all, I'm building a GtkAssistant which embeds a GtkFileChooserWidget in one of the content pages. My problem is when I run the assistant for the second times, the GtkfileChooserWidget doesn't display at all. Below the sample code which reproduces the problem : enum { ASSIST_PAGE_INTRO = 0, ASSIST_PAGE_FILES_SELECTION, ASSIST_PAGE_DONE }; static void on_cancel( GtkAssistant *assistant, gpointer user_data ) { gtk_widget_hide_all( GTK_WIDGET( assistant )); gtk_main_quit(); } /** * Run the assistant. */ void nact_assist_import_run( void ) { static GtkBuilder *xml = NULL; if( !xml ){ xml = gtk_builder_new(); gtk_builder_add_from_file( xml, GLADEDIR "/nautilus-actions-config.ui", NULL ); } GtkAssistant *assistant = GTK_ASSISTANT( gtk_builder_get_object( xml, "ImportAssistant" )); GtkWidget *intro = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_INTRO ); gtk_assistant_set_page_complete( assistant, intro, TRUE ); GtkWidget *selector = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_INTRO ); gtk_assistant_set_page_complete( assistant, selector, TRUE ); g_signal_connect( G_OBJECT( assistant ), "cancel", G_CALLBACK( on_cancel ), NULL ); gtk_widget_show_all( GTK_WIDGET( assistant )); gtk_main(); } Note that if I initialize a new GtkBuilder _each time_ I run the assistant, then all works fine. But I feel this work-around as a waste of resources... Note also that embedding other widgets (combobox or so) is fine, and doesn't show the same problem. Could someone be kind enough to explain me what is wrong in the code ? Or what is wrong in embedding a GtkFileChooserWidget in a GtkAssistant ? Thanks in advance Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list