[gtk+osx] window is visible but does not accept focus

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gtk+osx] window is visible but does not accept focus

KieSoft
Hi!

I'm trying to port my Linux app on MAC OS X. I can compile the code and
window is visible but does not accept focus, nor is it movable. I thought
that's my problem and wrote a small GTK app. I get the same result with that
test app too: window does not accept focus. Can you help me to solve the
problem?

Here are my code:

----------------------------------------------------------------------------
--------------
gtktest.mak:

CXXFLAGS=-g -Wno-long-double -Werror -D_FILE_OFFSET_BITS=64 -I/gtk-osx-0.6 -
I/gtk-osx-0.6/glib-1.2.10 -I/gtk-osx-0.6/gdk
OBJS=gtktest.o

gtktest : $(OBJS) ; \
    gcc -o gtktest $(OBJS) -lpthread -ldl -lstdc++
`/gtk-osx-0.6/gtk-config/gtk-config --libs`;

----------------------------------------------------------------------------
--------------
gtktest.cpp:

#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include <time.h>
#include <locale.h>
#include <assert.h>
#include <ctype.h>
#include <gtk/gtk.h>

static gint close_app_event(GtkWidget *widget, GdkEvent *event, gpointer
data)
{
gtk_main_quit();
return FALSE;
}


int main(int argc, char* argv[])
{
gchar buffer[64];
srand (time (NULL));

gtk_set_locale ();
gtk_init (&argc, &argv);
gdk_rgb_init();

GtkBindingSet *binding_set = gtk_binding_set_by_class (gtk_type_class
(GTK_TYPE_WIDGET));
gtk_binding_entry_add_signal(binding_set, '9', GDK_CONTROL_MASK |
GDK_RELEASE_MASK, "debug_msg", 1, GTK_TYPE_STRING, "GtkWidgetClass
<ctrl><release>9 test");

GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, FALSE);
gtk_widget_set_name (window, "main window");
gtk_widget_set_usize (window, 200, 400);
gtk_widget_set_uposition (window, 20, 20);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit),  NULL);
gtk_signal_connect (GTK_OBJECT (window), "delete-event", GTK_SIGNAL_FUNC
(gtk_false), NULL);

GtkWidget *box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);

if (gtk_micro_version > 0)  sprintf (buffer, "Gtk+ v%d.%d.%d",
gtk_major_version, gtk_minor_version, gtk_micro_version);
else sprintf (buffer, "Gtk+ v%d.%d", gtk_major_version, gtk_minor_version);

GtkWidget *label = gtk_label_new (buffer);
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);

GtkWidget *button = gtk_button_new_with_label ("close");
gtk_signal_connect(GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC
(close_app_event), window);
gtk_box_pack_start(GTK_BOX (box1), button, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);

gtk_widget_show_all (window);
gtk_main ();
return 0;
}


----------------------------------------------------------------------------
--------------

I took the code from gtk-osx-0.6 demo app.

Looking forward to hearing from you soon,

Best regards,
Igor




-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Gtk-osx-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gtk-osx-developer
Reply | Threaded
Open this post in threaded view
|

Re: [gtk+osx] window is visible but does not accept focus

David Burnett
KieSoft wrote:
> Hi!
>
> I'm trying to port my Linux app on MAC OS X. I can compile the code and
> window is visible but does not accept focus, nor is it movable. I thought
> that's my problem and wrote a small GTK app. I get the same result with that
> test app too: window does not accept focus. Can you help me to solve the
> problem?

Its an old issue.For some reason Apple have made it awkward to make
command line programs
have a GUI. There's a number of way's around this, the easiest is to
wrap the executable in a bundle.

There is also a way to add a resource, I'm not to clear about it but the
FLTK GUI tool set has
a program that can do it, although IIRC it's just a script and a
resource file.


Dave


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Gtk-osx-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gtk-osx-developer
Reply | Threaded
Open this post in threaded view
|

Re: [gtk+osx] window is visible but does not accept focus

Michael Moore-2
David Burnett wrote:

> KieSoft wrote:
>
>> Hi!
>>
>> I'm trying to port my Linux app on MAC OS X. I can compile the code and
>> window is visible but does not accept focus, nor is it movable. I thought
>> that's my problem and wrote a small GTK app. I get the same result
>> with that
>> test app too: window does not accept focus. Can you help me to solve the
>> problem?
>
>
> Its an old issue.For some reason Apple have made it awkward to make
> command line programs
> have a GUI. There's a number of way's around this, the easiest is to
> wrap the executable in a bundle.
>
> There is also a way to add a resource, I'm not to clear about it but the
> FLTK GUI tool set has
> a program that can do it, although IIRC it's just a script and a
> resource file.
>
>
> Dave

If you can use a script of some sort to launch your program, I'd
recommend Platypus ( http://sveinbjorn.sytes.net/platypus ). I've used
it for several programs and it works great. The program that uses it
that you've most likely used is Gimp.app (the GiMP packaged for OSX).

Michael Moore


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Gtk-osx-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gtk-osx-developer