Merge lp:~cimi/overlay-scrollbar/peek-gtk-widget-class into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 158
Proposed branch: lp:~cimi/overlay-scrollbar/peek-gtk-widget-class
Merge into: lp:overlay-scrollbar
Diff against target: 94 lines (+23/-14)
1 file modified
os/os-scrollbar.c (+23/-14)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/peek-gtk-widget-class
Reviewer Review Type Date Requested Status
David Barth (community) Needs Fixing
Javier Jardón Approve
Review via email: mp+53628@code.launchpad.net

Description of the change

By calling directly gtk widget's class functions I could skip the creation of the useless (for us) event_window.
Will probably need to hook up for more vfunc events and add empty functions (button_release is the only remaining function in gtkrange that is asking for the event window, though afaics it can't be called because there's no area where the mouse could click).
I am overriding size_allocate because the size_allocate function in gtk_range is playing with the event window without checking if it's NULL or not, so we will have some errors.

To post a comment you must log in.
159. By Andrea Cimitan

use directly gtkwidget's class

Revision history for this message
Javier Jardón (jjardon) wrote :

Maybe the proper way for this is to modify gtkrange and/or gtkscrollbar, but this works for us for now.

review: Approve
Revision history for this message
David Barth (dbarth) wrote :

What will happen if g_type_class_peek_parent returns NULL?

review: Needs Fixing
Revision history for this message
Javier Jardón (jjardon) wrote :

@David:

From the documentation:

"Since derived classes hold a reference count on their parent classes as long as they are instantiated, the returned class will always exist"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'os/os-scrollbar.c'
2--- os/os-scrollbar.c 2011-03-15 15:43:22 +0000
3+++ os/os-scrollbar.c 2011-03-16 15:07:27 +0000
4@@ -76,6 +76,7 @@
5 static void os_scrollbar_parent_set (GtkWidget *widget, GtkWidget *old_parent);
6 static void os_scrollbar_realize (GtkWidget *widget);
7 static void os_scrollbar_show (GtkWidget *widget);
8+static void os_scrollbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
9 static void os_scrollbar_unmap (GtkWidget *widget);
10 static void os_scrollbar_unrealize (GtkWidget *widget);
11 static void os_scrollbar_dispose (GObject *object);
12@@ -1262,14 +1263,15 @@
13 gobject_class = G_OBJECT_CLASS (class);
14 widget_class = GTK_WIDGET_CLASS (class);
15
16- widget_class->expose_event = os_scrollbar_expose_event;
17- widget_class->hide = os_scrollbar_hide;
18- widget_class->map = os_scrollbar_map;
19- widget_class->realize = os_scrollbar_realize;
20- widget_class->parent_set = os_scrollbar_parent_set;
21- widget_class->show = os_scrollbar_show;
22- widget_class->unmap = os_scrollbar_unmap;
23- widget_class->unrealize = os_scrollbar_unrealize;
24+ widget_class->expose_event = os_scrollbar_expose_event;
25+ widget_class->hide = os_scrollbar_hide;
26+ widget_class->map = os_scrollbar_map;
27+ widget_class->realize = os_scrollbar_realize;
28+ widget_class->parent_set = os_scrollbar_parent_set;
29+ widget_class->show = os_scrollbar_show;
30+ widget_class->size_allocate = os_scrollbar_size_allocate;
31+ widget_class->unmap = os_scrollbar_unmap;
32+ widget_class->unrealize = os_scrollbar_unrealize;
33
34 gobject_class->dispose = os_scrollbar_dispose;
35 gobject_class->finalize = os_scrollbar_finalize;
36@@ -1340,7 +1342,7 @@
37 static void
38 os_scrollbar_hide (GtkWidget *widget)
39 {
40- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->hide (widget);
41+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->hide (widget);
42 }
43
44 static void
45@@ -1352,7 +1354,7 @@
46 scrollbar = OS_SCROLLBAR (widget);
47 priv = scrollbar->priv;
48
49- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->map (widget);
50+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->map (widget);
51
52 priv->proximity = TRUE;
53
54@@ -1427,13 +1429,20 @@
55 static void
56 os_scrollbar_realize (GtkWidget *widget)
57 {
58- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->realize (widget);
59+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->realize (widget);
60 }
61
62 static void
63 os_scrollbar_show (GtkWidget *widget)
64 {
65- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->show (widget);
66+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget);
67+}
68+
69+static void
70+os_scrollbar_size_allocate (GtkWidget *widget,
71+ GtkAllocation *allocation)
72+{
73+ widget->allocation = *allocation;
74 }
75
76 static void
77@@ -1445,7 +1454,7 @@
78 scrollbar = OS_SCROLLBAR (widget);
79 priv = scrollbar->priv;
80
81- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->unmap (widget);
82+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unmap (widget);
83
84 priv->proximity = FALSE;
85
86@@ -1461,7 +1470,7 @@
87 static void
88 os_scrollbar_unrealize (GtkWidget *widget)
89 {
90- GTK_WIDGET_CLASS (os_scrollbar_parent_class)->unrealize (widget);
91+ GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unrealize (widget);
92 }
93
94 /* Public functions. */

Subscribers

People subscribed via source and target branches