Re: Focus weirdness

2008-11-10 Thread David Munger
Alright I've finally solved it. I had to pass the focus manually from the
GtkDrawingArea to the embedded xterm using XSetInputFocus(). Can somebody
suggest a cleaner or a more GTK-ish way of doing this?

I've tried with GtkSocket and gtk_socket_steal() but I still had to pass the
focus manually.

The minimal working example follows.

David


-
FILE: minex.c
-

// gcc -o minex -Wall `pkg-config --cflags --libs gtk+-2.0` minex.c &&
./minex

#include 
#include 
#include 
#include 

static XID
get_child_xid(GtkWidget *widget) {
Window win = GDK_WINDOW_XID(gtk_widget_get_window(widget));
Window root_win, parent_win, *children;
unsigned int nchildren;
XID child;

if (!XQueryTree(GDK_DISPLAY(), win, &root_win, &parent_win, &children,
&nchildren))
return 0;
child = (nchildren > 0) ? children[0] : 0;
XFree((char *) children);
return child;
}

static void
destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}

static void
realize(GtkWidget *xterm_area, gpointer data)
{
char cmd[256];
g_sprintf(cmd, "xterm -into %lu",
GDK_WINDOW_XID(gtk_widget_get_window(xterm_area)));
g_spawn_command_line_async(cmd, NULL);
}

static gboolean
focus_in_event(GtkWidget *xterm_area, GdkEventFocus *event, gpointer data)
{
XID child = get_child_xid(xterm_area);
if (child) {
XSetInputFocus(GDK_DISPLAY(), child, RevertToParent,
GDK_CURRENT_TIME);
}
return TRUE;
}

int
main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *xterm_area;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy),
NULL);

xterm_area = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(window), xterm_area);

gtk_widget_set_size_request(GTK_WIDGET(xterm_area), 484, 316);
gtk_widget_show(xterm_area);

GTK_WIDGET_SET_FLAGS(xterm_area, GTK_CAN_FOCUS);

g_signal_connect(G_OBJECT(xterm_area), "realize", G_CALLBACK(realize),
NULL);
g_signal_connect(G_OBJECT(xterm_area), "focus-in-event",
G_CALLBACK(focus_in_event), NULL);

gtk_widget_show(window);
gtk_main();

return 0;
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


removing element from GHashTable returns FALSE

2008-11-10 Thread Luka Napotnik
Hello.

I'm using a GHashTable to store some structures. The keys are unsigned
integers. I create my hash table with:

g_hash_table_new(g_direct_hash, NULL);

Then I store same values with keys with:

g_hash_table_insert(my_hash_table, GUINT_TO_POINTER(3), mystruct);

But when I try to remove the value from the hash table I get FALSE from
g_hash_table_remove():

g_hash_table_remove(my_hash_table, GUINT_TO_POINTER(3));

The funny part is that I lookup for that same key just a few lines
before and it is found.

Any ideas what could be wrong?

Greets,
Luka
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Glade signal connect data and full

2008-11-10 Thread Mike Massonnet
Hi, and really quickly,

Le Mon, 10 Nov 2008 08:38:53 -0500,
dhk <[EMAIL PROTECTED]> a écrit :

> All,
> 
> Could some explain how to use glade_xml_signal_connect_data() and
> glade_xml_signal_connect_full()?  Some good examples would be helpful
> also.

http://www.google.com/codesearch?q=lang%3Ac+glade_xml_signal_connect_full

> Thanks,
> 
> dave

HTH
Mike
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Glade signal connect data and full

2008-11-10 Thread dhk
All,

Could some explain how to use glade_xml_signal_connect_data() and
glade_xml_signal_connect_full()?  Some good examples would be helpful also.

I don't think I know the difference between the signal handler name and
the signal handler function that is used as parameters.

In my GTK program I want to pass different values for user_data for a
button click depending upon notebook tab that has focus.

Also is there a way to disconnect a signal made with
glade_xml_signal_connect_data() from an object?

Thanks,

dave
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list