Ejemplo n.º 1
0
void redraw_labels (GtkWidget *widget, GtkStyle *previous_style)
{
        GtkScrollbox *self = GTK_SCROLLBOX(widget);
        int i;
        
        if (self->labels->len < 1)
                return; 

        stop_callback(self);

        gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0);
        self->draw_middle = 0;
        self->draw_maxmiddle = 0;

        for (i = 0; i < self->labels->len; i++)
        {
                GdkPixmap *newpixmap;
                struct label *lbl = (struct label*)g_ptr_array_index(self->labels, i);

                if (!lbl->msg)
                        continue;

                newpixmap = make_pixmap(self, lbl->msg);

                if (lbl->pixmap)
                        g_free(lbl->pixmap);

                lbl->pixmap = newpixmap;
        }

        start_callback(self);

}
Ejemplo n.º 2
0
void start_callback(GtkScrollbox *self)
{
        if (self->draw_timeout)
                stop_callback(self);

        start_draw_up(self);
}
Ejemplo n.º 3
0
void start_draw_up(GtkScrollbox *self) 
{
        gint width, height;
        struct label *lbl;
        static int i = 0;
        GtkWidget *widget = (GtkWidget *)self;

        XFCE_PANEL_LOCK();

        if (self->labels->len == 0)
	{
                XFCE_PANEL_UNLOCK();
                return;
	}

        if (i >= self->labels->len)
                i = 0;

        lbl = (struct label*)g_ptr_array_index(self->labels, i);
        self->pixmap = lbl->pixmap;

	/* If we failed to create a proper pixmap, try again now */
	if (!lbl->pixmap)
	{
                lbl->pixmap = make_pixmap(self, lbl->msg);
		if (!lbl->pixmap)
		{
			/* Still no pixmap. We need to restart the timer */
			if (self->draw_timeout)
				stop_callback(self);
        		self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)start_draw_up, self);
                	XFCE_PANEL_UNLOCK();
			return;
		}
	}

        if (self->labels->len == 1) 
        {
                GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width,
                        GTK_WIDGET(self)->allocation.height};

                self->pixmap = lbl->pixmap;
                self->draw_offset = 0;
                
                gtk_widget_draw(GTK_WIDGET(self), &update_rect);
		XFCE_PANEL_UNLOCK();
                return;
        }
        
        gdk_drawable_get_size(GDK_DRAWABLE(self->pixmap), &width, &height);
        self->draw_middle = self->draw_maxmiddle - width / 2;
        
        self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)draw_up, self);

        i++;

	XFCE_PANEL_UNLOCK();
}
Ejemplo n.º 4
0
void
tickety_task_stop(tickety_task *self)
{
    char elapsed[25];

    time(&(self->stop_time));
    tickety_format_elapsed_time(elapsed, self->start_time, self->stop_time);
    printf("stopping task: '%s' (completed in %s)\n", self->name, elapsed);
    stop_callback(self);
}
Ejemplo n.º 5
0
static void
gtk_scrollbox_set_property (GObject *object, guint property_id, const GValue *value,
                GParamSpec *pspec)
{
        GtkScrollbox *self = (GtkScrollbox *)object;

        switch (property_id) {
                case GTK_SCROLLBOX_ENABLECB: {
                              gboolean realvalue = g_value_get_boolean(value);
                              if (!realvalue && self->draw_timeout) {
                                      stop_callback(self);
                              } 
                              else if (realvalue && !self->draw_timeout) 
                                      start_callback(self);
                              break;
                                              }
                default:
                                         /* We don't have any other property... */
                                         g_assert (FALSE);
                                         break;
        }
}
Ejemplo n.º 6
0
void gtk_scrollbox_clear (GtkScrollbox *self)
{
        stop_callback(self);

        DEBUG_PRINT("coming in %d\n", self->labels->len);

        while(self->labels->len > 0)
        { 
                struct label *lbl = (struct label*)g_ptr_array_index(self->labels, 0);
                free_label(lbl);


                g_ptr_array_remove_index(self->labels, 0);
        }

        DEBUG_PRINT("going out %d\n", self->labels->len);

        self->pixmap = NULL;

        gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0);
        self->draw_middle = 0;
        self->draw_maxmiddle = 0;

}