Article 5CX2E GTK Custom widget doesn't scroll

GTK Custom widget doesn't scroll

by
gt73
from LinuxQuestions.org on (#5CX2E)
Hi,

I made a custom widget by subclassing GtkLayout. From the documentation I read this widget has native scrolling abilities so it doesn't need a Gtkviewport. The problem is my custom widget doesn't scroll when I use the mouse wheel on it. I guess it's an allocation problem but what shall I modify to have it to scroll? The widget extends itself up to 00:04:59. Please screenshot here:

https://discourse.gnome.org/t/gtk-cu...nt-scroll/5356

This is the main.c:
Code:#include <gtk/gtk.h>
#include img_timeline.h"
#include <stdlib.h>

static gboolean img_timeline_scroll( ImgTimeline *widget, GdkEventScroll *event, GtkWidget *scrolledwindow);
static gboolean img_timeline_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer data);

static gint zoom = 1;

int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);

GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), Imagination timeline widget");
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 800, 200);
g_signal_connect(window, destroy", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *timeline = img_timeline_new();
g_object_set(timeline, total_time", 300, NULL);
g_object_set(timeline, video_background", #0084ff", NULL);
g_object_set(timeline, audio_background", #0084ff", NULL);

gtk_widget_add_events( timeline, GDK_BUTTON1_MOTION_MASK
| GDK_POINTER_MOTION_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_SCROLL_MASK
| GDK_KEY_PRESS_MASK );

GtkWidget *scrolledwindow1 = gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
gtk_container_add (GTK_CONTAINER(scrolledwindow1), timeline);
gtk_container_add (GTK_CONTAINER (window), scrolledwindow1);
g_signal_connect( G_OBJECT(timeline), scroll-event", G_CALLBACK(img_timeline_scroll), scrolledwindow1);
g_signal_connect( G_OBJECT(timeline), motion-notify-event", G_CALLBACK( img_timeline_motion_notify ), NULL );
gtk_widget_show_all(window);

gtk_main();
return 0;
}Timeline is the custom widget which subclass Gtk_layout. I can provide the .c and .h files if it's needed.

Thanks for your help. :)latest?d=yIl2AUoC8zA latest?i=Sai4Qc_EWaI:ztqSNKcpzeM:F7zBnMy latest?i=Sai4Qc_EWaI:ztqSNKcpzeM:V_sGLiP latest?d=qj6IDK7rITs latest?i=Sai4Qc_EWaI:ztqSNKcpzeM:gIN9vFwSai4Qc_EWaI
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments