Re: Atk focus change capture fail. Why?



That code (although I didn't test it), seems fine, and should work if you are using a recent gtk version. If not, that will only work if accessibility is enabled.

Anyway, FWIW, we plan to deprecate those methods at some moment of the future:
https://bugzilla.gnome.org/show_bug.cgi?id=649575#c4

If you want to track when the focus change, you can also add a global event, and filter state-change:focus events.

BR

On 10/04/2012 12:42 AM, Tal Hadad wrote:
I tried to make my first steps in ATK, but I can't understand what I'm doing wrong.
Here is my Vala code:
using GLib;
using Atk;
using Gtk;

void _my_focus_tracker (Atk.Object object) {
    stdout.printf ("Tracked!\n");
}

int main (string[] args) {
    Gtk.init (ref args);
    Util.add_focus_tracker (_my_focus_tracker);
   
    Gtk.Window window1 = new Gtk.Window ();   
    window1.show ();
   
    Gtk.Window window2 = new Gtk.Window ();   
    window2.show ();
   
    Gtk.main ();
   
    return 0;
}

add_docus_tracker doesn't call _my_focus_tracker when focus get changed.
I know that most of you may not know Vala, so here is part of
the C generated/equated code:
void _my_focus_tracker (AtkObject* object) {
    FILE* _tmp0_;
    g_return_if_fail (object != NULL);
    _tmp0_ = stdout;
    fprintf (_tmp0_, "Tracked!\n");
}

gint _vala_main (gchar** args, int args_length1) {
    gint result = 0;
    GtkWindow* _tmp0_;
    GtkWindow* _tmp1_;
    GtkWindow* window1;
    GtkWindow* _tmp2_;
    GtkWindow* _tmp3_;
    GtkWindow* window2;
    gtk_init (&args_length1, &args);
    atk_add_focus_tracker (_my_focus_tracker_atk_event_listener);
    _tmp0_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
    _tmp1_ = g_object_ref_sink (_tmp0_);
    window1 = _tmp1_;
    gtk_widget_show ((GtkWidget*) window1);
    _tmp2_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
    _tmp3_ = g_object_ref_sink (_tmp2_);
    window2 = _tmp3_;
    gtk_widget_show ((GtkWidget*) window2);
    gtk_main ();
    result = 0;
    _g_object_unref0 (window2);
    _g_object_unref0 (window1);
    return result;
}

int main (int argc, char ** argv) {
    g_type_init ();
    return _vala_main (argv, argc);
}

For some reason, even when GLib main loop is running, no focus change detection between the two windows.
Have I miss something? I think I haven't initialize something or forgot to active watcher...

Hope for your reply
Tal


_______________________________________________
gnome-accessibility-list mailing list
gnome-accessibility-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-accessibility-list


-- 
Alejandro Piñeiro Iglesias


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]