I am writing a simple form in GTK+3, using C.
The form has a text entry called txtPrompt, and a submit button btnSend, created in Glade.
I am trying to access the text in textview upon button press and to do so, am using the following callback handler:
GtkBuilder *builder;
void onSubmit(GtkWidget * widget, GdkEvent * event, gpointer data) {
GObject * textView = gtk_builder_get_object(GTK_BUILDER(builder), "txtPrompt");
gchar * input = gtk_entry_get_text(GTK_ENTRY(textView));
g_print(input);
g_print("Submit clicked\n");
}
However it does not work and yields this:
(client:12905): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `GtkBuilder'
(client:12905): Gtk-CRITICAL **: gtk_builder_get_object: assertion `GTK_IS_BUILDER (builder)' failed
(client:12905): Gtk-CRITICAL **: gtk_entry_get_text: assertion `GTK_IS_ENTRY (entry)' failed
(client:12905): GLib-CRITICAL **: g_print: assertion `format != NULL' failed
Submit clicked
Help?
After much searching, I uncommented this line from the main() code:
g_object_unref(G_OBJECT (builder));
According to a forum post, this REMOVES the reference to builder entirely!
One can then call stuff on builder within a signal handler, as per normal.
Related
This is my .gresource.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/readaratus/decoder">
<file alias="app_icon">icon192.png</file>
</gresource>
</gresources>
I wrote this code to set the icon:
gtk_window_set_icon_from_file(GTK_WINDOW(ui.main_window),
"resource:///org/readaratus/decoder/app_icon",
NULL);
Which fails with the following warning:
Gtk-WARNING **: Error loading icon from file 'resource:///org/readaratus/decoder/app_icon':
Failed to open file 'resource:///org/readaratus/decoder/app_icon': No such file or directory
But if I query the resources bundle, it reports an object with 3631 bytes:
gsize size;
if(g_resources_get_info("/org/readaratus/decoder/app_icon",
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, NULL, NULL))
{
g_print("app_icon size: %ld\n", size);
}
What is wrong with my code and how do I load an icon from the resource?
GResource is not a file, but a binary resource bundled with your application/library. You should access it only with g_resource_*() methods or special methods which lookup data in resources, like gtk_image_new_from_resource, gtk_builder_new_from_resource, gdk_pixbuf_new_from_resource.
In your case you should have loaded Gdkpixbuf and set it as icon separately.
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_resource ("/org/readaratus/decoder/app_icon", NULL);
gtk_window_set_icon (window, pixbuf);
Side note: if you have your icon hand-drawn in multiple sizes, use gtk_window_set_icon_list(). Then the best size will be used.
I keep getting the following message with some of my applications:
Pango-CRITICAL **: pango_color_parse: assertion 'spec != NULL' failed
I am using this in Fedora 22. Can I track down the source of the error. FWIW, the application "works" fine, with the exception of rendering the transparency.
Thanks for any suggestions!
I'm building an application that uses an app-indicator. The menu should be updated dynamically. Adding items works great using gtk_menu_shell_append, however for removing I can't find a gtk_menu_shell_* function. I've found gtk_container_remove and calling it with the gtkmenuitem and it's parent results in the following warnings:
GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkWidget'
Gtk-CRITICAL **: gtk_widget_get_parent: assertion `GTK_IS_WIDGET (widget)' failed
Gtk-CRITICAL **: gtk_container_remove: assertion `GTK_IS_CONTAINER (container)' failed
I've also tried calling gtk_widget_destory and get errors like this:
GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkWidget'
Gtk-CRITICAL **: gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)' failed
Note that both methods actually remove the menu item from the menu.
What is the correct way to remove a GtkMenuItem from a GtkMenu without generating these errors/warnings?
Apparently the widget was wrong somehow (don't understand why this would still work though).
I'm try to run TapKu iOS demo project downloaded from:
https://github.com/devinross/tapkulibrary/branches
I build without errors but when it comes to be installed on the simulator, I get this error message:
[AppDelegate_iPhone window]: unrecognized selector sent to instance 0x9b7ad90
2012-12-03 17:05:13.478 unviersaldemo[94132:13d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate_iPhone window]: unrecognized selector sent to instance 0x9b7ad90'
*** First throw call stack:
(0x1a44012 0x1429e7e 0x1acf4bd 0x143d7ea 0x1a33cf9 0x1a3394e 0x3da78 0x2bcc 0x4807b7 0x480da7 0x481fab 0x493315 0x49424b 0x485cf8 0x237fdf9 0x237fad0 0x19b9bf5 0x19b9962 0x19eabb6 0x19e9f44 0x19e9e1b 0x4817da 0x48365c 0x2b36 0x2925 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Any idea?
I just added:
#interface AppDelegate_iPhone : TKAppDelegate <UIApplicationDelegate> {
UIWindow *window;
}
#property (nonatomic, retain) UIWindow *window;
in the AppDelegate_iPhone.h file
and
#synthesize window;
in the AppDelegate_iPhone.m file.
Works for me.
I execute my application in Debian 6 OS. From time to time there is an exception:
ERROR:../../mono/io-layer/handles-private.h:362:_wapi_handle_share_release:
assertion failed: (info->handle_refs > 0) Stacktrace:
at (wrapper managed-to-native) System.IO.MonoIO.Close
(intptr,System.IO.MonoIOError&) <0x00004> at (wrapper
managed-to-native) System.IO.MonoIO.Close
(intptr,System.IO.MonoIOError&) <0x00004> at
System.IO.FileStream.Dispose (bool) <0x00094> at
System.IO.Stream.Close () <0x0001b> at System.IO.Stream.Dispose ()
<0x00019> at (wrapper remoting-invoke-with-check)
System.IO.Stream.Dispose () <0x00053> at
Sarum.Logger.Log.WriteToFile (Sarum.Logger.SLogMessage,bool) <0x0077d>
at Sarum.Logger.Log.WriteLineAsync () <0x00212> at (wrapper
runtime-invoke) object.runtime_invoke_void_this_
(object,intptr,intptr,intptr) <0x00040>
Native stacktrace:
/usr/bin/cli() [0x80d5b19] [0xdf6600] /lib/libc.so.6(abort+0x182)
[0x13d962] /lib/libglib-2.0.so.0(g_assertion_message+0x13f)
[0xc9232f] /lib/libglib-2.0.so.0(+0x6198d) [0xc9298d] /usr/bin/cli()
[0x81df0da] /usr/bin/cli() [0x81e2d22] /usr/bin/cli() [0x81e2eb6]
/usr/bin/cli() [0x8161dc0] [0xa1c6f8] [0xa1c625] [0xa1c584]
[0xa1c752] [0x5711ec] [0x2c59ce] [0x2c41b3] [0x2832b1]
/usr/bin/cli() [0x8064428] /usr/bin/cli(mono_runtime_invoke+0x40)
[0x812d4e0] /usr/bin/cli(mono_runtime_delegate_invoke+0x34)
[0x812d764] /usr/bin/cli() [0x81284bf] /usr/bin/cli() [0x81f5e3e]
/usr/bin/cli() [0x82089a5] /lib/libpthread.so.0(+0x57b0) [0x9857b0]
/lib/libc.so.6(clone+0x5e) [0x1dc0be]
Debug info from gdb:
=================================================================
Got a SIGABRT while executing native code. This usually indicates a fatal
error in the mono runtime or one of the native libraries used by your
application.
=================================================================
** (/usr/local/bin/cserver/WadJet.CentralServer.exe:8141): WARNING **: process_set_termination_details: error looking up process handle 0x403
Why is this and how this can be combated?
There seems to be a lot of people who have reported similar errors that have plagued older versions of Mono. You might first want to try out updating the Mono as suggested here.