GTK3 porting problem (clipboard)
I resolved the majority of the the issues when porting my program from GTK 2.x to GTK 3.x. Unfortunately I still have one issue left: when compiling the program on Feodra 15 alpha (gcc 4.6, GTK3 v3.0.2) I get these errors: ./src/clipboard.cpp:442:38: error: invalid use of incomplete type 'GtkTargetList' /usr/include/gtk-3.0/gtk/gtkselection.h:48:16: error: forward declaration of 'GtkTargetList' ./src/clipboard.cpp:445:20: error: invalid use of incomplete type 'GtkTargetList' /usr/include/gtk-3.0/gtk/gtkselection.h:48:16: error: forward declaration of 'GtkTargetList' ./src/clipboard.cpp:447:3: error: 'GtkTargetPair' was not declared in this scope ./src/clipboard.cpp:447:18: error: 'pair' was not declared in this scope The relevant code is this: #include gtk/gtk.h GtkTargetList *list = gtk_target_list_new (NULL, 0); .. add text and other targets in the list // LINE 442: error: invalid use of incomplete type 'GtkTargetList' int nTargetCnt = g_list_length (list-list); //LINE 445: error: invalid use of incomplete type 'GtkTargetList' for (GList *l=list-list; l; l=l-next, i++) //LINE 447: error: 'GtkTargetPair' was not declared in this scope GtkTargetPair *pair = (GtkTargetPair *)l-data; This all works fine with GTK2.x. What is the correct way to work with this on GTK 3.x ? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK3 porting problem (clipboard)
I don't know the answer, but this is wrong: int nTargetCnt = g_list_length (list-list); g_list_length returns guint, not int. Although this is valid code (implicit typecast), it can cause bad things. On 03/10/2011 01:44 PM, Miroslav Rajcic wrote: I resolved the majority of the the issues when porting my program from GTK 2.x to GTK 3.x. Unfortunately I still have one issue left: when compiling the program on Feodra 15 alpha (gcc 4.6, GTK3 v3.0.2) I get these errors: ./src/clipboard.cpp:442:38: error: invalid use of incomplete type 'GtkTargetList' /usr/include/gtk-3.0/gtk/gtkselection.h:48:16: error: forward declaration of 'GtkTargetList' ./src/clipboard.cpp:445:20: error: invalid use of incomplete type 'GtkTargetList' /usr/include/gtk-3.0/gtk/gtkselection.h:48:16: error: forward declaration of 'GtkTargetList' ./src/clipboard.cpp:447:3: error: 'GtkTargetPair' was not declared in this scope ./src/clipboard.cpp:447:18: error: 'pair' was not declared in this scope The relevant code is this: #include gtk/gtk.h GtkTargetList *list = gtk_target_list_new (NULL, 0); .. add text and other targets in the list // LINE 442: error: invalid use of incomplete type 'GtkTargetList' int nTargetCnt = g_list_length (list-list); //LINE 445: error: invalid use of incomplete type 'GtkTargetList' for (GList *l=list-list; l; l=l-next, i++) //LINE 447: error: 'GtkTargetPair' was not declared in this scope GtkTargetPair *pair = (GtkTargetPair *)l-data; This all works fine with GTK2.x. What is the correct way to work with this on GTK 3.x ? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk+3 and the user's homedir .gtkrc-3.0
The gtk3 reference on resource files, gtk+-3.0.2/docs/reference/gtk/html/gtk3-Resource-Files.html,states that, although deprecated, certain files will be read at the end of gtk_init(). Unless modified, the files looked for will be SYSCONFDIR/gtk-2.0/gtkrc and .gtkrc-3.0 in the users home directory. My experience with the ~/.gtkrc-3.0 file when running my application compiled against gtk+-3.0.2is that it has no effect at all. Specifically, I have a file named both gtkrc-2.0 and gtkrc-3.0 (both hard-linked to same content which I show below) When I compile my app against gtk-2 and run it, I see the expected result,with the HighContrast theme applied to borders etc and the text of my GtkEntry entryBox in Binner Gothic font. When I compile the same app against gtk-3 and run it in the same way (without any XDG_CONFIG_HOME or any use of any new gtk-3 settings features such as a settings.ini, css styles etc,i.e. trying to simulate a simple migration with only re-bulding the app),I see plain old Raleigh and the Sans 10 font for the text in the entrybox. Am I doing something wrong or is this a bug ? (in the documentation or in the code?) By the way, yes, I did verify that my gtk3 build is in effect in my gtk3 scenario -I set up a settings.ini and css stylesheet as another variation, and triedwith a new-to-gtk3 widget (lightswitch) and then get my settings applied and thelight-switch works as expected. (BTW-1 - I tried to search the mailing list for hits on .gtkrc-3.0 and got Oops! This link appears to be broken.The requested URL /mailman/search was not found on this server BTW-2 I hope this is the correct list for this question - if not please advise) Cheers John Lumby content of ~/.gtkrc-2.0 and ~/.gtkrc-3.0 # When turned on, this option causes gtk to select the contents of an entry field when it becomes focused.gtk-entry-select-on-focus = 1 # Controls the keybindings that gtk uses for text entry/editing/etc# The emacs theme turns on things like:# ctrl-a == move to beginning of line, ctrl-e == move to end of line, etc.gtk-key-theme-name = Emacsgtk-theme-name = HighContrast # The following section allows you to change the style of the entry boxstyle garish{ font_name = Binner Gothic bg[NORMAL] = #FF0B0B fg[NORMAL] = #00CDFF bg[ACTIVE] = #00FF0B fg[ACTIVE] = #CD00FF bg[PRELIGHT] = #FF0B0B fg[PRELIGHT] = #11 bg[SELECTED] = #FF0B0B fg[SELECTED] = #11F2F2}# Set the widget style for the conversation entry boxwidget *entrybox style garishwidget_class GtkEntry style garishclass GtkEntry style garish ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: gtk+3 and the user's homedir .gtkrc-3.0
Apologies for the awful formatting of that posting - let me try again : The gtk3 reference on resource files, gtk+-3.0.2/docs/reference/gtk/html/gtk3-Resource-Files.html, states that, although deprecated, certain files will be read at the end of gtk_init(). Unless modified, the files looked for will be SYSCONFDIR/gtk-2.0/gtkrc and .gtkrc-3.0 in the users home directory. My experience with the ~/.gtkrc-3.0 file when running my application compiled against gtk+-3.0.2 is that it has no effect at all. Specifically, I have a file named both gtkrc-2.0 and gtkrc-3.0 (both hard-linked to same content which I show below) When I compile my app against gtk-2 and run it, I see the expected result, with the HighContrast theme applied to borders etc and the text of my GtkEntry entryBox in Binner Gothic font. When I compile the same app against gtk-3 and run it in the same way (without any XDG_CONFIG_HOME or any use of any new gtk-3 settings features such as a settings.ini, css styles etc, i.e. trying to simulate a simple migration with only re-bulding the app), I see plain old Raleigh and the Sans 10 font for the text in the entrybox. Am I doing something wrong or is this a bug ? (in the documentation or in the code?) By the way, yes, I did verify that my gtk3 build is in effect in my gtk3 scenario - I set up a settings.ini and css stylesheet as another variation, and tried with a new-to-gtk3 widget (lightswitch) and then get my settings applied and the light-switch works as expected. (BTW-1 - I tried to search the mailing list for hits on .gtkrc-3.0 and got Oops! This link appears to be broken. The requested URL /mailman/search was not found on this server BTW-2 I hope this is the correct list for this question - if not please advise) Cheers John Lumby content of ~/.gtkrc-2.0 and ~/.gtkrc-3.0 # When turned on, this option causes gtk to select the contents of an entry field when it becomes focused. gtk-entry-select-on-focus = 1 # Controls the keybindings that gtk uses for text entry/editing/etc # The emacs theme turns on things like: # ctrl-a == move to beginning of line, ctrl-e == move to end of line, etc. gtk-key-theme-name = Emacs gtk-theme-name = HighContrast # The following section allows you to change the style of the entry box style garish { font_name = Binner Gothic bg[NORMAL] = #FF0B0B fg[NORMAL] = #00CDFF bg[ACTIVE] = #00FF0B fg[ACTIVE] = #CD00FF bg[PRELIGHT] = #FF0B0B fg[PRELIGHT] = #11 bg[SELECTED] = #FF0B0B fg[SELECTED] = #11F2F2 } # Set the widget style for the conversation entry box widget *entrybox style garish widget_class GtkEntry style garish class GtkEntry style garish ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Strange dead lock with g_threads_enter
I attached a full trace off the the program running, can anyone check it out for me? 2011/3/5 Chris Vine ch...@cvine.freeserve.co.uk On Sat, 5 Mar 2011 11:58:23 +0800 Wei-Ning Huang aitjc...@gmail.com wrote: [snip] From what I can see, the program is stuck because the main thread locked a mutex in #3. But from the backtrace, the mutex seems to be locked by gtk_main_loop_run() which is something I can't control, and somehow it locked the same mutex as gdk_threads_enter()? any ideas? If it isn't recursion then somewhere in your '' you probably have out-of-order locking. I should start by making the gdk global lock 'Lock 1' and work from there. In other words, don't call gdk_threads_enter() when you are holding a lock of your own. Also, don't call gdk_threads_enter() in a GTK+ signal handler because it will already be locked there. (But that is not true of ordinary glib main loop events.) Best of all, don't use the global lock at all but instead invoke callbacks in the main loop with g_idle_add(). This is a cleaner design and also has the benefit of making your program portable to windows and other non-X11 platforms. Chris -- AZ Huang http://berelent.blogspot.com/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
How to avoid POINTER_MOTION events for not active windows?
I am working on a simple linux/gnome/gtk/cairo/ruby application similar to http://www.ssalewski.de/PetEd-Demo.html.en I want to get POINTER_MOTION events when mouse pointer is in my GTK drawing area. When I call add_events() for my drawing area with flag Gdk::Event::POINTER_MOTION_MASK I get motion events whenever the mouse pointer is over/in my drawing area, even when the window containing that drawing area is not active. This was surprising for me. I want events only when the window is the active one. What is the correct method to achieve that behavior? Thanks, Stefan Salewski ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK3 porting problem (clipboard)
On Fri, 11 Mar 2011, [windows-1252] Jaroslav ^Jm�d wrote: From GTK documentation: --- A GtkTargetList structure is a reference counted list of GtkTargetPair. It is used to represent the same information as a table of GtkTargetEntry, but in an efficient form. This structure should be treated as opaque. --- Important to read is This structure should be treated as opaque. You shouldn't access members of this structure directly. In GTK2, structure definition was available in GTK headers, in GTK3, it is not. Info: http://library.gnome.org/devel/gtk3/stable/gtk3-Selections.html#GtkTargetList-struct You're right, but this seems odd. In the GTK3 version of the documentation the basic structures GtkTargetEntry and GtkTargetPair are still exposed in the API, and although GtkTargetList is said to be opaque (a) it's unclear why this should be so (it seems to be a trivial composite) and (b) the functionality that was previously available via the struct itself is not replicated via accessor functions. For example, there's no gtk_target_list_get_n_targets() to replace the original poster's GTK2 idiom: int nTargetCnt = g_list_length (list-list); Allin Cottrell ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK3 porting problem (clipboard)
You're right, but this seems odd. In the GTK3 version of the documentation the basic structures GtkTargetEntry and GtkTargetPair are still exposed in the API, and although GtkTargetList is said to be opaque (a) it's unclear why this should be so (it seems to be a trivial composite) and (b) the functionality that was previously available via the struct itself is not replicated via accessor functions. For example, there's no gtk_target_list_get_n_targets() to replace the original poster's GTK2 idiom: int nTargetCnt = g_list_length (list-list); Perhaps someone knows any workaround for what I am trying to do in my code or a way to implement this differently? The code does the following: //create a target list with text and HTML formats GtkTargetList *list = gtk_target_list_new (NULL, 0); gtk_target_list_add(list, atomTextHtml, 0, 0); gtk_target_list_add_text_targets(list, 0); //now I need to convert the target list to an array of the GtkTargetEntry structures as needed by gtk_clipboard_set_with_data int nTargetCnt = g_list_length (list-list); GtkTargetEntry *targets = g_new0 (GtkTargetEntry, nTargetCnt); int i=0; for (GList *l=list-list; l; l=l-next, i++) { GtkTargetPair *pair = (GtkTargetPair *)l-data; targets[i].target = gdk_atom_name (pair-target); } //set the clipboard with target formats gboolean bOK = gtk_clipboard_set_with_data(clipboard, targets, nTargetCnt, MyGtkClipboardGetFunc, NULL, 0); Basically the big problem is that gtk_clipboard_set_with_data API does not use GtktargetList directly. Regards, Miroslav ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list