Re: gtk_text_buffer_delete ?
> - Original Message - >> From: "Stefan Salewski" <m...@ssalewski.de> >> 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
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, , MAX_LENGTH-1 ); /*gtk_text_iter_backward_char( );*/ /*gtk_text_buffer_get_iter_at_offset( buffer, , count );*/ gtk_text_buffer_get_end_iter( buffer, ); /*gtk_text_iter_backward_char( );*/ in = TRUE; g_debug( "%s: count=%d, start=%d, end=%d", thisfn, count, gtk_text_iter_get_offset( ), gtk_text_iter_get_offset( )); gtk_text_buffer_delete( buffer, , ); 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
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
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: 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
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
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
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: GnomeVFS migration
- Johannes Schmid j...@jsschmid.de 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 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