~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to gnome-panel/panel-frame.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Sebastien Bacher, Jeremy Bicha
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.13.10 upstream) (2.2.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110530110449-hinl17kxkcefjw6x
Tags: 1:3.0.2-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in:
  - the new libgweather version is in oneiric, use it
  - drop the python and python-gconf depends, 
    they were added for gnome-panel-add which is still using gconf and buggy
* debian/gnome-panel-data.install:
  - don't install the apport hook, it's only getting gconf datas which 
    doesn't work since gnome-panel uses gsettings
* debian/patches/90_build_fixes.patch:
  - restore build fix from git not applied in the new serie
* debian/patches/01_panel_submenus.patch:
  - don't take that Debian diff, the .menus use the upstream naming in Ubuntu
* debian/patches/06_no_resize_grip.patch:
  - dropped, the issue is fixed in the new version
* debian/patches/50_fix-potfiles.patch:
  - dropped, the issue is fixed in the new version
* debian/watch:
  - track unstable series as well

Drop those delta, since gnome-panel is not the default Ubuntu session now we
can go back to an experience closer to the upstream one: 
* debian/control.in:
  - drop the indicators recommends, unity-2d is the ubuntu fallback session
    so we can get back to use an upstream config for gnome-panel and reduce
    the delta we carry
* debian/patches/04_default_panel_config.patch:
  - don't modify the upstream layout
* debian/patches/05_no_session_delay.patch:
  - no need to tweak the upstream session to optimize it
* debian/patches/16_compiz_workspace_switcher.patch:
  - go back to the upstream switcher behaviour    
* debian/patches/25_dynamic_fusa_detection.patch:
  - not needed since we use the upstream layout, could be ported if someone
    is wanting to do the work though
* debian/patches/30_disable-initial-animation.patch, debian/rules:
  - drop the --disable-initial-animation, that was some login optimization
    but since it's not the default desktop you should go back to the 
    upstream behaviour

[ Jeremy Bicha ]   
* New upstream version
* Merge from Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Recommends gnome-settings-daemon which has the timezone polkit service
* debian/rules:
  - Update translations template.
* debian/gnome-panel-data.install:
  - Install apport hook
  - Install the "About Ubuntu" menu item.
* debian/patches/01_layout.patch:
  - Disabled, Help & About Ubuntu don't fit as well in Gnome Panel 3
* debian/patches/01_panel_submenus.patch.
  - Dropped
* debian/patches/03_dnd_places_link.patch:
  - Disabled, when using Drag'n'Drop from Places menu, install a link launcher
    (.desktop file) instead of copying the entire directory.
* debian/patches/17_about-ubuntu-translation.patch:
  - List ubuntu-about.desktop for translation.
* debian/patches/40_unset_menuproxy.patch:
  - Make sure gnome-panel and the applets don't pick up menu proxies.
* debian/patches/50_fix-potfiles.patch
  - Fix i18n
* debian/patches/85_disable_shutdown_on_ltsp.patch:
  - Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/71_change_bookmark_submenu_limit_value.patch
  - Dropped, picked up by Debian
* debian/patches/18_lockdown_lock_editor.patch:
* debian/patches/90_git_wnck_show_realize.patch:
* debian/patches/90_fix_linking_DSO_link.patch:
* debian/patches/91_gir_annotations.patch
* debian/patches/92_git_calendar_day.patch
* debian/patches/92_git_fix_applets_in_multiscreen.patch:
  - Dropped, applied upstream
* debian/watch:
  - watch unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
};
37
37
 
38
38
static void
39
 
panel_frame_size_request (GtkWidget      *widget,
40
 
                          GtkRequisition *requisition)
41
 
{
42
 
        PanelFrame *frame = (PanelFrame *) widget;
43
 
        GtkBin     *bin   = (GtkBin *) widget;
44
 
        GtkStyle   *style;
45
 
        GtkWidget  *child;
46
 
        int         border_width;
47
 
 
48
 
        style = gtk_widget_get_style (widget);
49
 
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
50
 
 
51
 
        requisition->width = 1;
52
 
        requisition->height = 1;
53
 
 
54
 
        child = gtk_bin_get_child (bin);
55
 
        if (child && gtk_widget_get_visible (child))
56
 
                gtk_widget_size_request (child, requisition);
57
 
 
58
 
        requisition->width  += border_width;
59
 
        requisition->height += border_width;
60
 
 
61
 
        if (frame->edges & PANEL_EDGE_TOP)
62
 
                requisition->height += style->xthickness;
63
 
        if (frame->edges & PANEL_EDGE_BOTTOM)
64
 
                requisition->height += style->xthickness;
65
 
        if (frame->edges & PANEL_EDGE_LEFT)
66
 
                requisition->width += style->ythickness;
67
 
        if (frame->edges & PANEL_EDGE_RIGHT)
68
 
                requisition->width += style->ythickness;
 
39
panel_frame_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width)
 
40
{
 
41
        PanelFrame      *frame = (PanelFrame *) widget;
 
42
        GtkBin          *bin   = (GtkBin *) widget;
 
43
        GtkStyleContext *context;
 
44
        GtkWidget       *child;
 
45
        GtkBorder        padding;
 
46
        int              border_width;
 
47
 
 
48
        context = gtk_widget_get_style_context (widget);
 
49
        gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
 
50
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
51
 
 
52
        *minimal_width = 1;
 
53
        *natural_width = 1;
 
54
 
 
55
        child = gtk_bin_get_child (bin);
 
56
        if (child && gtk_widget_get_visible (child))
 
57
                gtk_widget_get_preferred_width (child, minimal_width, natural_width);
 
58
 
 
59
        *minimal_width += border_width;
 
60
        *natural_width += border_width;
 
61
 
 
62
        if (frame->edges & PANEL_EDGE_LEFT) {
 
63
                *minimal_width += padding.left;
 
64
                *natural_width += padding.left;
 
65
        }
 
66
 
 
67
        if (frame->edges & PANEL_EDGE_RIGHT) {
 
68
                *minimal_width += padding.right;
 
69
                *natural_width += padding.right;
 
70
        }
 
71
}
 
72
 
 
73
static void
 
74
panel_frame_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height)
 
75
{
 
76
        PanelFrame      *frame = (PanelFrame *) widget;
 
77
        GtkBin          *bin   = (GtkBin *) widget;
 
78
        GtkStyleContext *context;
 
79
        GtkWidget       *child;
 
80
        GtkBorder        padding;
 
81
        int              border_width;
 
82
 
 
83
        context = gtk_widget_get_style_context (widget);
 
84
        gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
 
85
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
86
 
 
87
        *minimal_height = 1;
 
88
        *natural_height = 1;
 
89
 
 
90
        child = gtk_bin_get_child (bin);
 
91
        if (child && gtk_widget_get_visible (child))
 
92
                gtk_widget_get_preferred_height (child, minimal_height, natural_height);
 
93
 
 
94
        *minimal_height += border_width;
 
95
        *natural_height += border_width;
 
96
 
 
97
        if (frame->edges & PANEL_EDGE_TOP) {
 
98
                *minimal_height += padding.top;
 
99
                *natural_height += padding.top;
 
100
        }
 
101
 
 
102
        if (frame->edges & PANEL_EDGE_BOTTOM) {
 
103
                *minimal_height += padding.bottom;
 
104
                *natural_height += padding.bottom;
 
105
        }
69
106
}
70
107
 
71
108
static void
72
109
panel_frame_size_allocate (GtkWidget     *widget,
73
110
                           GtkAllocation *allocation)
74
111
{
75
 
        PanelFrame    *frame = (PanelFrame *) widget;
76
 
        GtkBin        *bin   = (GtkBin *) widget;
77
 
        GtkStyle      *style;
78
 
        GtkAllocation  child_allocation;
79
 
        GtkAllocation  child_allocation_current;
80
 
        GtkWidget     *child;
81
 
        int            border_width;
 
112
        PanelFrame      *frame = (PanelFrame *) widget;
 
113
        GtkBin          *bin   = (GtkBin *) widget;
 
114
        GtkStyleContext *context;
 
115
        GtkAllocation    child_allocation;
 
116
        GtkAllocation    child_allocation_current;
 
117
        GtkWidget       *child;
 
118
        GtkBorder        padding;
 
119
        int              border_width;
82
120
 
83
121
        gtk_widget_set_allocation (widget, allocation);
84
122
 
85
 
        style = gtk_widget_get_style (widget);
 
123
        context = gtk_widget_get_style_context (widget);
 
124
        gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding);
86
125
        border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
87
126
 
88
127
        child_allocation.x      = allocation->x + border_width;
91
130
        child_allocation.height = allocation->height - 2 * border_width;
92
131
 
93
132
        if (frame->edges & PANEL_EDGE_LEFT) {
94
 
                child_allocation.x     += style->xthickness;
95
 
                child_allocation.width -= style->xthickness;
 
133
                child_allocation.x     += padding.left;
 
134
                child_allocation.width -= padding.left;
96
135
        }
97
136
 
98
137
        if (frame->edges & PANEL_EDGE_TOP) {
99
 
                child_allocation.y      += style->ythickness;
100
 
                child_allocation.height -= style->ythickness;
 
138
                child_allocation.y      += padding.top;
 
139
                child_allocation.height -= padding.top;
101
140
        }
102
141
 
103
142
        if (frame->edges & PANEL_EDGE_RIGHT)
104
 
                child_allocation.width -= style->xthickness;
 
143
                child_allocation.width -= padding.right;
105
144
 
106
145
        if (frame->edges & PANEL_EDGE_BOTTOM)
107
 
                child_allocation.height -= style->ythickness;
 
146
                child_allocation.height -= padding.bottom;
108
147
 
109
148
        child = gtk_bin_get_child (bin);
110
149
        gtk_widget_get_allocation (child, &child_allocation_current);
121
160
}
122
161
 
123
162
void
124
 
panel_frame_draw (GtkWidget      *widget,
125
 
                  PanelFrameEdge  edges)
 
163
panel_frame_draw (GtkWidget     *widget,
 
164
                  cairo_t       *cr,
 
165
                  PanelFrameEdge edges)
126
166
{
127
 
        GdkWindow     *window;
128
 
        GtkStyle      *style;
129
 
        GtkStateType   state;
130
 
        GtkAllocation  allocation;
131
 
        GdkGC         *dark, *light, *black;
132
 
        int            x, y, width, height;
133
 
        int            xthickness, ythickness;
 
167
        PanelFrame       *frame = (PanelFrame *) widget;
 
168
        GdkWindow        *window;
 
169
        GtkStyleContext  *context;
 
170
        GtkStateFlags     state;
 
171
        GdkRGBA           bg, dark, light;
 
172
        GtkSymbolicColor *c1, *c2;
 
173
        int               x, y, width, height;
 
174
        GtkBorder         padding;
134
175
 
135
176
        if (edges == PANEL_EDGE_NONE)
136
177
                return;
137
178
 
138
179
        window = gtk_widget_get_window (widget);
139
 
        style = gtk_widget_get_style (widget);
140
 
        state = gtk_widget_get_state (widget);
141
 
        gtk_widget_get_allocation (widget, &allocation);
142
 
 
143
 
        dark  = style->dark_gc [state];
144
 
        light = style->light_gc [state];
145
 
        black = style->black_gc;
146
 
 
147
 
        xthickness = style->xthickness;
148
 
        ythickness = style->ythickness;
149
 
 
150
 
        x      = allocation.x;
151
 
        y      = allocation.y;
152
 
        width  = allocation.width;
153
 
        height = allocation.height;
 
180
        context = gtk_widget_get_style_context (widget);
 
181
        state = gtk_widget_get_state_flags (widget);
 
182
        width = gtk_widget_get_allocated_width (widget);
 
183
        height = gtk_widget_get_allocated_height (widget);
 
184
 
 
185
        gtk_style_context_get_background_color (context, state, &bg);
 
186
 
 
187
        c1 = gtk_symbolic_color_new_literal (&bg);
 
188
 
 
189
        c2 = gtk_symbolic_color_new_shade (c1, 0.7);
 
190
        gtk_symbolic_color_resolve (c2, NULL, &dark);
 
191
        gtk_symbolic_color_unref (c2);
 
192
 
 
193
        c2 = gtk_symbolic_color_new_shade (c1, 1.3);
 
194
        gtk_symbolic_color_resolve (c2, NULL, &light);
 
195
        gtk_symbolic_color_unref (c2);
 
196
 
 
197
        gtk_symbolic_color_unref (c1);
 
198
 
 
199
        gtk_style_context_get_padding (context, state, &padding);
154
200
 
155
201
        /* Copied from gtk_default_draw_shadow() */
156
202
 
157
 
        if (edges & PANEL_EDGE_BOTTOM && ythickness > 0) {
158
 
                if (ythickness > 1) {
159
 
                        gdk_draw_line (window, dark,
160
 
                                       x, y + height - 2,
161
 
                                       x + width - 1, y + height - 2);
162
 
                        gdk_draw_line (window, black,
163
 
                                       x, y + height - 1,
164
 
                                       x + width - 1, y + height - 1);
165
 
                } else
166
 
                        gdk_draw_line (window, dark,
167
 
                                       x, y + height - 1,
168
 
                                       x + width - 1, y + height - 1);
169
 
        }
170
 
 
171
 
        if (edges & PANEL_EDGE_RIGHT && xthickness > 0) {
172
 
                if (xthickness > 1) {
173
 
                        gdk_draw_line (window, dark,
174
 
                                       x + width - 2, y,
175
 
                                       x + width - 2, y + height - 1);
176
 
 
177
 
                        gdk_draw_line (window, black,
178
 
                                       x + width - 1, y,
179
 
                                       x + width - 1, y + height - 1);
180
 
                } else
181
 
                        gdk_draw_line (window, dark,
182
 
                                       x + width - 1, y,
183
 
                                       x + width - 1, y + height - 1);
184
 
        }
185
 
 
186
 
        if (edges & PANEL_EDGE_TOP && ythickness > 0) {
187
 
                gdk_draw_line (window, light,
188
 
                               x, y, x + width - 1, y);
189
 
 
190
 
                if (ythickness > 1)
191
 
                        gdk_draw_line (window,
192
 
                                       style->bg_gc [state],
193
 
                                       x, y + 1, x + width - 1, y + 1);
194
 
        }
195
 
 
196
 
        if (edges & PANEL_EDGE_LEFT && xthickness > 0) {
197
 
                gdk_draw_line (window, light,
198
 
                               x, y, x, y + height - 1);
199
 
 
200
 
                if (xthickness > 1)
201
 
                        gdk_draw_line (window,
202
 
                                       style->bg_gc [state],
203
 
                                       x + 1, y, x + 1, y + height - 1);
 
203
        x = y = 0;
 
204
 
 
205
        cairo_set_line_width (cr, 1);
 
206
 
 
207
        if (frame->edges & PANEL_EDGE_BOTTOM && padding.bottom > 0) {
 
208
                if (padding.bottom > 1) {
 
209
                        gdk_cairo_set_source_rgba (cr, &dark);
 
210
                        cairo_move_to (cr, x + .5, y + height - 2 + .5);
 
211
                        cairo_line_to (cr, x + width - 1 - .5, y + height - 2 + .5);
 
212
                        cairo_stroke (cr);
 
213
 
 
214
                        cairo_set_source_rgb (cr, 0., 0., 0.);
 
215
                        cairo_move_to (cr, x + .5, y + height - 1 - .5);
 
216
                        cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
 
217
                        cairo_stroke (cr);
 
218
                } else {
 
219
                        gdk_cairo_set_source_rgba (cr, &dark);
 
220
                        cairo_move_to (cr, x + .5, y + height - 1 - .5);
 
221
                        cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
 
222
                        cairo_stroke (cr);
 
223
                }
 
224
        }
 
225
 
 
226
        if (frame->edges & PANEL_EDGE_RIGHT && padding.right > 0) {
 
227
                if (padding.right > 1) {
 
228
                        gdk_cairo_set_source_rgba (cr, &dark);
 
229
                        cairo_move_to (cr, x + width - 2 - .5, y + .5);
 
230
                        cairo_line_to (cr, x + width - 2 - .5, y + height - 1 - .5);
 
231
                        cairo_stroke (cr);
 
232
 
 
233
                        cairo_set_source_rgb (cr, 0., 0., 0.);
 
234
                        cairo_move_to (cr, x + width - 1 - .5, y + .5);
 
235
                        cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
 
236
                        cairo_stroke (cr);
 
237
                } else {
 
238
                        gdk_cairo_set_source_rgba (cr, &dark);
 
239
                        cairo_move_to (cr, x + width - 1 - .5, y + .5);
 
240
                        cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5);
 
241
                        cairo_stroke (cr);
 
242
                }
 
243
        }
 
244
 
 
245
        if (frame->edges & PANEL_EDGE_TOP && padding.top > 0) {
 
246
                gdk_cairo_set_source_rgba (cr, &light);
 
247
                cairo_move_to (cr, x + .5, y + .5);
 
248
                cairo_line_to (cr, x + width - 1 - .5, y + .5);
 
249
                cairo_stroke (cr);
 
250
 
 
251
                if (padding.right > 1) {
 
252
                        gdk_cairo_set_source_rgba (cr, &bg);
 
253
                        cairo_move_to (cr, x + .5, y + 1 + .5);
 
254
                        cairo_line_to (cr, x + width - 1 - .5, y + 1 + .5);
 
255
                        cairo_stroke (cr);
 
256
                }
 
257
        }
 
258
 
 
259
        if (frame->edges & PANEL_EDGE_LEFT && padding.left > 0) {
 
260
                gdk_cairo_set_source_rgba (cr, &light);
 
261
                cairo_move_to (cr, x + .5, y + .5);
 
262
                cairo_line_to (cr, x + .5, y + height - 1 - .5);
 
263
                cairo_stroke (cr);
 
264
 
 
265
                if (padding.left > 1) {
 
266
                      gdk_cairo_set_source_rgba (cr, &bg);
 
267
                      cairo_move_to (cr, x + 1 + .5, y + .5);
 
268
                      cairo_line_to (cr, x + 1 + .5, y + height - 1 - .5);
 
269
                      cairo_stroke (cr);
 
270
                }
204
271
        }
205
272
}
206
273
 
207
274
static gboolean
208
 
panel_frame_expose (GtkWidget      *widget,
209
 
                    GdkEventExpose *event)
 
275
panel_frame_real_draw (GtkWidget *widget,
 
276
                       cairo_t *cr)
210
277
{
211
 
        PanelFrame *frame = (PanelFrame *) widget;
212
 
        gboolean    retval = FALSE;
213
 
 
214
 
        if (!gtk_widget_is_drawable (widget))
215
 
                return retval;
216
 
 
217
 
        if (GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event)
218
 
                retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event (widget, event);
219
 
 
220
 
        panel_frame_draw (widget, frame->edges);
221
 
 
222
 
        return retval;
 
278
        gboolean    retval = FALSE;
 
279
 
 
280
        if (GTK_WIDGET_CLASS (panel_frame_parent_class)->draw)
 
281
                retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->draw (widget, cr);
 
282
 
 
283
        panel_frame_draw (widget, cr, PANEL_FRAME (widget)->edges);
 
284
 
 
285
        return retval;
223
286
}
224
287
 
225
288
static void
275
338
        gobject_class->set_property = panel_frame_set_property;
276
339
        gobject_class->get_property = panel_frame_get_property;
277
340
 
278
 
        widget_class->size_request  = panel_frame_size_request;
279
 
        widget_class->size_allocate = panel_frame_size_allocate;
280
 
        widget_class->expose_event  = panel_frame_expose;
 
341
        widget_class->get_preferred_width  = panel_frame_get_preferred_width;
 
342
        widget_class->get_preferred_height = panel_frame_get_preferred_height;
 
343
        widget_class->size_allocate        = panel_frame_size_allocate;
 
344
        widget_class->draw                 = panel_frame_real_draw;
281
345
 
282
346
        g_object_class_install_property (
283
347
                gobject_class,