Exemplo n.º 1
0
static gboolean
bytes_view_scroll(GtkWidget *widget, GdkEventScroll *event)
{
	BytesView *bv = BYTES_VIEW(widget);

	gdouble new_value;

	if (event->direction == GDK_SCROLL_UP) {	/* mouse wheel pageUp */
		bytes_view_ensure_vadj(bv);

		new_value = gtk_adjustment_get_value(bv->vadj) - (gtk_adjustment_get_page_increment(bv->vadj) / 10);
		if (new_value < gtk_adjustment_get_lower(bv->vadj))
			new_value = gtk_adjustment_get_lower(bv->vadj);
		gtk_adjustment_set_value(bv->vadj, new_value);

	} else if (event->direction == GDK_SCROLL_DOWN) {	/* mouse wheel pageDn */
		bytes_view_ensure_vadj(bv);

		new_value = gtk_adjustment_get_value(bv->vadj) + (gtk_adjustment_get_page_increment(bv->vadj) / 10);
		if (new_value > (gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj)))
			new_value = gtk_adjustment_get_upper(bv->vadj) - gtk_adjustment_get_page_size(bv->vadj);
		gtk_adjustment_set_value(bv->vadj, new_value);
	}
	return FALSE;
}
Exemplo n.º 2
0
static void
bytes_view_destroy_widget(GtkWidget *widget)
{
	bytes_view_destroy(BYTES_VIEW(widget));

	GTK_WIDGET_CLASS(parent_class)->destroy(widget);
}
Exemplo n.º 3
0
static void
bytes_view_destroy_object(GtkObject *object)
{
	bytes_view_destroy(BYTES_VIEW(object));

	if (GTK_OBJECT_CLASS(parent_class)->destroy)
		(*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
}
Exemplo n.º 4
0
static void
bytes_view_realize(GtkWidget *widget)
{
	BytesView *bv;
	GdkWindowAttr attributes;
	GtkAllocation allocation;
	GdkWindow *win;

#if GTK_CHECK_VERSION(3, 0, 0)
	GtkStyleContext *context;
#endif

	_gtk_widget_set_realized_true(widget);
	bv = BYTES_VIEW(widget);

	gtk_widget_get_allocation(widget, &allocation);

	attributes.window_type = GDK_WINDOW_CHILD;
	attributes.x = allocation.x;
	attributes.y = allocation.y;
	attributes.width = allocation.width;
	attributes.height = allocation.height;
	attributes.wclass = GDK_INPUT_OUTPUT;
	attributes.visual = gtk_widget_get_visual(widget);
	attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;

#if !GTK_CHECK_VERSION(3, 0, 0)
	attributes.colormap = gtk_widget_get_colormap(widget);

	win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);
#else
	win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL);
#endif

	gtk_widget_set_window(widget, win);

#if GTK_CHECK_VERSION(3, 8, 0)
	gtk_widget_register_window(widget, win);
#else
	gdk_window_set_user_data(win, widget);
#endif

#if !GTK_CHECK_VERSION(3, 0, 0)	/* XXX, check */
	gdk_window_set_back_pixmap(win, NULL, FALSE);
#endif

#if GTK_CHECK_VERSION(3, 0, 0)
	context = gtk_widget_get_style_context(widget);
	gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
	/* gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY); */

#elif GTK_CHECK_VERSION(2, 20, 0)
	gtk_widget_style_attach(widget);
#else
	widget->style = gtk_style_attach(widget->style, win);
#endif
	bytes_view_ensure_layout(bv);
}
Exemplo n.º 5
0
static void
bytes_view_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
	gtk_widget_set_allocation(widget, allocation);

	if (gtk_widget_get_realized(widget)) {
		BytesView *bv = BYTES_VIEW(widget);

		gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height);
		bytes_view_adjustment_set(bv);
	}
}
Exemplo n.º 6
0
static void
bytes_view_unrealize(GtkWidget *widget)
{
	BytesView *bv = BYTES_VIEW(widget);

	if (bv->context) {
		g_object_unref(bv->context);
		bv->context = NULL;
	}
	/* if there are still events in the queue, this'll avoid segfault */
	gdk_window_set_user_data(gtk_widget_get_window(widget), NULL);

	if (parent_class->unrealize)
		(*GTK_WIDGET_CLASS(parent_class)->unrealize)(widget);
}