Re: GnomeAnimator Question




You need to create a GtkEventBox for this. Try something like the
following example. You can check out gnome-ppp-applet under gnome-network
CVS also; it allows mouse events on a GnomeAnimator object.

   GtkWidget *animator;
   GtkWidget *evtbox;
   GtkWidget *tmpbox;

   animator = gnome_animator_new_with_size(22, 22);
   /* Setup your animator.. */

   /* Create an event box to trap mouse events. */
   evtbox = gtk_event_box_new();
   gtk_signal_connect(GTK_OBJECT(evtbox),
                      "button_press_event",
                      GTK_SIGNAL_FUNC(button_press_cb),
                      NULL);
   gtk_widget_set_events(evtbox, GDK_BUTTON_PRESS_MASK);
   tmpbox = gtk_hbox_new(TRUE, 0);
   gtk_container_add(GTK_CONTAINER(evtbox), tmpbox);
   gtk_box_pack_start(GTK_BOX(tmpbox), animator, FALSE, TRUE, 0);

Hope this helps,
   Cody

On Sat, 4 Dec 1999, Loban Amaan Rahman wrote:

> Hello all!
> 
> I'm using GnomeAnimator in a UI I'm writing, and ran into some problems.
> Apparently GnomeAnimator is refusing to emit any event signals. Here
> are the code snippets.
> 
> The animation starts up and looks great.
> 
> But, No matter what I do, I can never get the on_logo_button_press_event
> callback to be called. What did I do wrong?
> 
> 
> gboolean
> on_logo_button_press_event(GtkWidget * widget,
> 			   GdkEventButton * event, gpointer user_data)
> {
> 	GnomeAnimator *logo = NULL;
> g_warning("Logo Event");
> 	logo = GNOME_ANIMATOR(widget);
> 	if (gnome_animator_get_status(logo) == GNOME_ANIMATOR_STATUS_RUNNING)
> 	 	gnome_animator_stop(logo);
> 	else
> 		gnome_animator_start(logo);
> }
> 
> 
> void draw_logo(GtkWidget * widget)
> {
> 	GtkContainer *logo_container = NULL;
> 
> 	GnomeAnimator *logo = NULL;
> 
> 	logo = GNOME_ANIMATOR(gnome_animator_new_with_size(64, 64));
> 	gnome_animator_set_loop_type(logo, GNOME_ANIMATOR_LOOP_RESTART);
> 	gnome_animator_set_playback_speed(logo, 1.0/LOGO_ANIMATION_SPEED);
> 	gnome_animator_set_playback_direction(logo, -1);
> 
> 	if (!gnome_animator_append_frames_from_file
> 	    (logo, "pixmaps/logo-animation.png", 0, 0, 1, 64))
> 		g_warning("Couldn't find pixmap file: %s",
> 			  "logo-animation.png");
> 	gnome_animator_start(logo);
> 	gtk_widget_show(GTK_WIDGET(logo));
> 
> 	logo_container =
> 	    GTK_CONTAINER(lookup_widget(widget, "logo_container"));
> 	gtk_container_add(logo_container, GTK_WIDGET(logo));
> 
> 	gtk_signal_connect(GTK_OBJECT(logo), "button_press_event",
> 			   GTK_SIGNAL_FUNC(on_logo_button_press_event),
> 			   NULL);
> }
> 
> 
> -- 
>         FAQ: Frequently-Asked Questions at http://www.gnome.org/gnomefaq
>          To unsubscribe: mail gnome-list-request@gnome.org with 
>                        "unsubscribe" as the Subject.
> 



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