1 diff -urN aa/gnome-panel-2.6.0/gnome-panel/Makefile.am gnome-panel-2.6.0/gnome-panel/Makefile.am
2 --- aa/gnome-panel-2.6.0/gnome-panel/Makefile.am 2004-02-06 17:04:50.000000000 +0100
3 +++ gnome-panel-2.6.0/gnome-panel/Makefile.am 2004-03-27 00:29:00.520061944 +0100
13 diff -urN aa/gnome-panel-2.6.0/gnome-panel/menu.c gnome-panel-2.6.0/gnome-panel/menu.c
14 --- aa/gnome-panel-2.6.0/gnome-panel/menu.c 2004-03-09 11:08:47.000000000 +0100
15 +++ gnome-panel-2.6.0/gnome-panel/menu.c 2004-03-27 00:29:00.522061640 +0100
17 #include "menu-fentry.h"
18 #include "menu-util.h"
19 #include "menu-ditem.h"
20 +#include "panel-menu.h"
21 #include "panel-util.h"
22 #include "panel-gconf.h"
25 #include "panel-lockdown.h"
28 +#define MENU_SNAP_LENGTH 10
30 static char *gnome_folder = NULL;
33 if (repo->orig_func != NULL) {
34 repo->orig_func (menu, x, y, push_in, repo->orig_data);
36 + if (*x < MENU_SNAP_LENGTH)
39 if (menu->parent_menu_item != NULL) {
40 /* This is a submenu so behave submenuish */
41 if (*x < monitor_basex ||
43 reload_image_menu_items ();
47 -panel_create_menu (void)
49 +panel_create_menu_of_type (GType menu_type)
52 static gboolean registered_icon_theme_changer = FALSE;
54 G_CALLBACK (icon_theme_changed), NULL);
57 - retval = gtk_menu_new ();
59 + retval = g_object_new (menu_type, NULL);
60 panel_gconf_notify_add_while_alive ("/desktop/gnome/interface/menus_have_icons",
61 (GConfClientNotifyFunc) menus_have_icons_changed,
68 +panel_create_menu (void)
70 + return panel_create_menu_of_type (gtk_menu_get_type());
75 +menu_new_of_type (GType menu_type)
79 - retval = panel_create_menu ();
80 + retval = panel_create_menu_of_type (menu_type);
83 retval, "show", G_CALLBACK (setup_menu_panel), NULL);
91 + return menu_new_of_type (gtk_menu_get_type ());
96 icon_to_load_free (IconToLoad *icon)
102 - root_menu = menu_new ();
103 + root_menu = menu_new_of_type (panel_menu_get_type ());
105 g_object_set_data (G_OBJECT (root_menu), "menu_panel", panel);
107 diff -urN aa/gnome-panel-2.6.0/gnome-panel/panel-config-global.c gnome-panel-2.6.0/gnome-panel/panel-config-global.c
108 --- aa/gnome-panel-2.6.0/gnome-panel/panel-config-global.c 2004-01-18 15:35:47.000000000 +0100
109 +++ gnome-panel-2.6.0/gnome-panel/panel-config-global.c 2004-03-27 00:29:00.523061488 +0100
111 guint drawer_auto_close : 1;
112 guint confirm_panel_remove : 1;
113 guint highlight_when_over : 1;
114 + guint menu_stripe : 1;
117 static GlobalConfig global_config = { 0, };
120 return global_config.confirm_panel_remove;
123 +panel_global_config_get_menu_stripe (void)
125 + g_assert (global_config_initialised == TRUE);
127 + return global_config.menu_stripe;
131 panel_global_config_set_entry (GConfEntry *entry)
133 else if (strcmp (key, "highlight_launchers_on_mouseover") == 0)
134 global_config.highlight_when_over =
135 gconf_value_get_bool (value);
137 + else if (strcmp (key, "show_menu_stripe") == 0)
138 + global_config.menu_stripe =
139 + gconf_value_get_bool (value);
144 diff -urN aa/gnome-panel-2.6.0/gnome-panel/panel-config-global.h gnome-panel-2.6.0/gnome-panel/panel-config-global.h
145 --- aa/gnome-panel-2.6.0/gnome-panel/panel-config-global.h 2004-01-18 15:32:28.000000000 +0100
146 +++ gnome-panel-2.6.0/gnome-panel/panel-config-global.h 2004-03-27 00:29:00.523061488 +0100
148 gboolean panel_global_config_get_drawer_auto_close (void);
149 gboolean panel_global_config_get_tooltips_enabled (void);
150 gboolean panel_global_config_get_confirm_panel_remove (void);
151 +gboolean panel_global_config_get_menu_stripe (void);
155 diff -urN aa/gnome-panel-2.6.0/gnome-panel/panel-global.schemas.in gnome-panel-2.6.0/gnome-panel/panel-global.schemas.in
156 --- aa/gnome-panel-2.6.0/gnome-panel/panel-global.schemas.in 2004-01-18 16:10:23.000000000 +0100
157 +++ gnome-panel-2.6.0/gnome-panel/panel-global.schemas.in 2004-03-27 00:29:00.588051608 +0100
162 + <key>/schemas/apps/panel/global/show_menu_stripe</key>
163 + <applyto>/apps/panel/global/show_menu_stripe</applyto>
164 + <owner>panel</owner>
166 + <default>true</default>
174 <key>/schemas/apps/panel/global/enable_key_bindings</key>
175 <applyto>/apps/panel/global/enable_key_bindings</applyto>
177 diff -urN aa/gnome-panel-2.6.0/gnome-panel/panel-menu.c gnome-panel-2.6.0/gnome-panel/panel-menu.c
178 --- aa/gnome-panel-2.6.0/gnome-panel/panel-menu.c 1970-01-01 01:00:00.000000000 +0100
179 +++ gnome-panel-2.6.0/gnome-panel/panel-menu.c 2004-03-27 00:49:47.929426896 +0100
182 + * To set this up insert something like this in your ~/.gtkrc-2.0
184 + * Copyright (C) 2002 Ximian, Inc.
185 + * Copyright (C) 2001 Havoc Pennington
186 + * Copyright (C) 1997-2000 Dan Pascu and Alfredo Kojima
187 + * Copyright (C) 2003 Marcin Krzy¿anowski
191 + * PanelMenu::default_side_image = "/tmp/stripelogo.png"
192 + * PanelMenu::gradient_bg = true
194 + * class "PanelMenu" style "default"
197 + * Thomas, Michael Meeks
198 + * GtkMenu code by the GTK+ team
199 + * Gradient code from WindowMaker by Dan Pascu and Alfredo Kojima,
200 + * by way of metacity by Havoc Pennington.
201 + * Marcin Krzy¿anowski
205 +#include <libgnome/gnome-macros.h>
206 +#include <libgnome/gnome-program.h>
207 +#include <libgnome/gnome-i18n.h>
208 +#include <gtk/gtkgc.h>
209 +#include <gtk/gtkimagemenuitem.h>
210 +#include <gtk/gtkseparatormenuitem.h>
211 +#include <gtk/gtkmenu.h>
212 +#include <gtk/gtkwidget.h>
213 +#include <gtk/gtkwindow.h>
214 +#include <gtk/gtkmain.h>
215 +#include <gdk/gdkwindow.h>
216 +#include <panel-menu.h>
218 +#include "panel-config-global.h"
220 +#define dprintf(a) g_warning a
221 +/*#define dprintf(a) G_STMT_START { (void) 0; } G_STMT_END*/
223 +GNOME_CLASS_BOILERPLATE (PanelMenu, panel_menu,
224 + GtkMenu, GTK_TYPE_MENU)
229 +panel_menu_size_request (GtkWidget *widget,
230 + GtkRequisition *requisition)
232 + PanelMenu *pm = PANEL_MENU (widget);
234 + GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
236 + if (panel_global_config_get_menu_stripe () && pm->side_image != NULL)
237 + requisition->width += gdk_pixbuf_get_width (pm->side_image)
238 + + gtk_widget_get_style (widget)->xthickness;
242 +get_light_stripe_color (PanelMenu *pm)
246 + gtk_widget_style_get (GTK_WIDGET (pm),
247 + "stripe-color-light", &color,
251 + color = gdk_color_copy (>K_WIDGET (pm)->style->bg[GTK_STATE_NORMAL]);
258 +get_stripe_color (PanelMenu *pm)
262 + gtk_widget_style_get (GTK_WIDGET (pm),
263 + "stripe-color", &color,
267 + color = gdk_color_copy (>K_WIDGET (pm)->style->bg[GTK_STATE_SELECTED]);
274 +get_stripe_gc (PanelMenu *pm)
276 + GdkGCValues gc_values;
277 + GdkGCValuesMask gc_values_mask;
280 + color = get_stripe_color (pm);
281 + gc_values.foreground = *color;
282 + gdk_color_free (color);
283 + gc_values_mask = GDK_GC_FOREGROUND;
285 + gdk_rgb_find_color (GTK_WIDGET (pm)->style->colormap, &gc_values.foreground);
287 + return gtk_gc_get (GTK_WIDGET (pm)->style->depth,
288 + GTK_WIDGET (pm)->style->colormap,
289 + &gc_values, gc_values_mask);
293 +panel_menu_expose_event (GtkWidget *widget,
294 + GdkEventExpose *event)
296 + GdkRectangle exposed;
297 + GdkRectangle position;
301 + PanelMenu *pm = PANEL_MENU (widget);
303 + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
305 + if (!panel_global_config_get_menu_stripe () || !pm->side_image) {
308 + window = GTK_MENU (widget)->bin_window;
310 + stripe_gc = get_stripe_gc (pm);
312 + gdk_gc_set_clip_rectangle (stripe_gc, &event->area);
313 + gdk_draw_rectangle (window,
316 + widget->allocation.x,
317 + widget->allocation.y,
318 + gdk_pixbuf_get_width (pm->side_image),
319 + widget->allocation.height);
320 + gdk_gc_set_clip_rectangle (stripe_gc, NULL);
322 + bin_height = widget->allocation.height - 2 * (GTK_CONTAINER (widget)->border_width + widget->style->ythickness);
324 + position = widget->allocation;
325 + position.y += bin_height - gdk_pixbuf_get_height (pm->side_image);
326 + position.width = gdk_pixbuf_get_width (pm->side_image);
327 + position.height = gdk_pixbuf_get_height (pm->side_image);
329 + if (widget->allocation.height >= gdk_pixbuf_get_height (pm->side_image)) {
330 + if (gdk_rectangle_intersect (&event->area,
333 + gdk_pixbuf_render_to_drawable (
334 + pm->side_image, window,
335 + widget->style->black_gc,
336 + exposed.x - position.x,
337 + exposed.y - position.y,
338 + exposed.x, exposed.y,
339 + exposed.width, exposed.height,
340 + GDK_RGB_DITHER_NORMAL,
341 + exposed.x, exposed.y);
345 + position = widget->allocation;
346 + if (position.height != gdk_pixbuf_get_height (pm->side_image)) {
347 + position.width = gdk_pixbuf_get_width (pm->side_image);
348 + if (position.height > gdk_pixbuf_get_height (pm->side_image)) {
349 + position.height = bin_height - gdk_pixbuf_get_height (pm->side_image);
351 + position.height = bin_height;
354 + if (pm->scaled_image && gdk_rectangle_intersect (&event->area,
358 + gdk_pixbuf_render_to_drawable (
359 + pm->scaled_image, window,
360 + widget->style->black_gc,
361 + exposed.x - position.x,
362 + exposed.y - position.y,
363 + exposed.x, exposed.y,
364 + exposed.width, exposed.height,
365 + GDK_RGB_DITHER_NORMAL,
366 + exposed.x, exposed.y);
373 +/* begin metacity cut and paste */
375 +free_buffer (guchar *pixels, gpointer data)
381 +blank_pixbuf (int width, int height, gboolean no_padding)
386 + g_return_val_if_fail (width > 0, NULL);
387 + g_return_val_if_fail (height > 0, NULL);
390 + rowstride = width * 3;
392 + /* Always align rows to 32-bit boundaries */
393 + rowstride = 4 * ((3 * width + 3) / 4);
395 + buf = g_try_malloc (height * rowstride);
399 + return gdk_pixbuf_new_from_data (buf, GDK_COLORSPACE_RGB,
401 + width, height, rowstride,
402 + free_buffer, NULL);
406 +meta_gradient_create_vertical (int width, int height,
407 + const GdkColor *from,
408 + const GdkColor *to)
411 + long r, g, b, dr, dg, db;
413 + unsigned char *ptr;
414 + unsigned char rr, gg, bb;
418 + unsigned char *pixels;
420 + pixbuf = blank_pixbuf (width, height, FALSE);
421 + if (pixbuf == NULL)
424 + pixels = gdk_pixbuf_get_pixels (pixbuf);
425 + rowstride = gdk_pixbuf_get_rowstride (pixbuf);
427 + r0 = (guchar) (from->red / 256.0);
428 + g0 = (guchar) (from->green / 256.0);
429 + b0 = (guchar) (from->blue / 256.0);
430 + rf = (guchar) (to->red / 256.0);
431 + gf = (guchar) (to->green / 256.0);
432 + bf = (guchar) (to->blue / 256.0);
438 + dr = ((rf-r0)<<16)/(int)height;
439 + dg = ((gf-g0)<<16)/(int)height;
440 + db = ((bf-b0)<<16)/(int)height;
442 + for (i=0; i<height; i++)
444 + ptr = pixels + i * rowstride;
449 + for (j=0; j<width/8; j++)
451 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
452 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
453 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
454 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
455 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
456 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
457 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
458 + *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
462 + case 7: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
463 + case 6: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
464 + case 5: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
465 + case 4: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
466 + case 3: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
467 + case 2: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
468 + case 1: *(ptr++) = rr; *(ptr++) = gg; *(ptr++) = bb;
477 +/* end metacity cut and paste */
479 +/* begin gtkmenu.c cut and paste */
480 +#define MENU_SCROLL_STEP1 8
481 +#define MENU_SCROLL_STEP2 15
482 +#define MENU_SCROLL_ARROW_HEIGHT 16
483 +#define MENU_SCROLL_FAST_ZONE 8
484 +#define MENU_SCROLL_TIMEOUT1 50
485 +#define MENU_SCROLL_TIMEOUT2 50
487 +#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
489 +typedef struct _GtkMenuAttachData GtkMenuAttachData;
490 +typedef struct _GtkMenuPrivate GtkMenuPrivate;
492 +struct _GtkMenuAttachData
494 + GtkWidget *attach_widget;
495 + GtkMenuDetachFunc detacher;
498 +struct _GtkMenuPrivate
500 + gboolean have_position;
504 + /* info used for the table */
506 + gint heights_length;
510 + /* Cached layout information */
511 + gboolean have_layout;
521 + gint bottom_attach;
522 + gint effective_left_attach;
523 + gint effective_right_attach;
524 + gint effective_top_attach;
525 + gint effective_bottom_attach;
529 +gtk_menu_free_private (gpointer data)
531 + GtkMenuPrivate *priv = (GtkMenuPrivate *)data;
533 + g_free (priv->heights);
538 +static GtkMenuPrivate *
539 +gtk_menu_get_private (GtkMenu *menu)
541 + GtkMenuPrivate *private;
542 + static GQuark private_quark = 0;
544 + if (!private_quark)
545 + private_quark = g_quark_from_static_string ("gtk-menu-private");
547 + private = g_object_get_qdata (G_OBJECT (menu), private_quark);
551 + private = g_new0 (GtkMenuPrivate, 1);
552 + private->have_position = FALSE;
554 + g_object_set_qdata_full (G_OBJECT (menu), private_quark,
555 + private, gtk_menu_free_private);
562 +gtk_menu_remove_scroll_timeout (GtkMenu *menu)
564 + if (menu->timeout_id)
566 + g_source_remove (menu->timeout_id);
567 + menu->timeout_id = 0;
572 +gtk_menu_stop_scrolling (GtkMenu *menu)
574 + gtk_menu_remove_scroll_timeout (menu);
576 + menu->upper_arrow_prelight = FALSE;
577 + menu->lower_arrow_prelight = FALSE;
581 +gtk_menu_scroll_to (GtkMenu *menu,
586 + gint view_width, view_height;
588 + gboolean last_visible;
590 + guint vertical_padding;
592 + widget = GTK_WIDGET (menu);
594 + if (menu->tearoff_active &&
595 + menu->tearoff_adjustment &&
596 + (menu->tearoff_adjustment->value != offset))
598 + menu->tearoff_adjustment->value =
600 + 0, menu->tearoff_adjustment->upper - menu->tearoff_adjustment->page_size);
601 + gtk_adjustment_value_changed (menu->tearoff_adjustment);
604 + /* Move/resize the viewport according to arrows: */
605 + view_width = widget->allocation.width;
606 + view_height = widget->allocation.height;
608 + gtk_widget_style_get (GTK_WIDGET (menu),
609 + "vertical-padding", &vertical_padding,
612 + border_width = GTK_CONTAINER (menu)->border_width;
613 + view_width -= (border_width + widget->style->xthickness) * 2;
614 + view_height -= (border_width + widget->style->ythickness + vertical_padding) * 2;
615 + menu_height = widget->requisition.height -
616 + (border_width + widget->style->ythickness + vertical_padding) * 2;
618 + x = border_width + widget->style->xthickness;
619 + y = border_width + widget->style->ythickness + vertical_padding;
621 + if (!menu->tearoff_active)
623 + last_visible = menu->upper_arrow_visible;
624 + menu->upper_arrow_visible = offset > 0;
626 + if (menu->upper_arrow_visible)
627 + view_height -= MENU_SCROLL_ARROW_HEIGHT;
629 + if ( (last_visible != menu->upper_arrow_visible) &&
630 + !menu->upper_arrow_visible)
632 + menu->upper_arrow_prelight = FALSE;
634 + /* If we hid the upper arrow, possibly remove timeout */
635 + if (menu->scroll_step < 0)
637 + gtk_menu_stop_scrolling (menu);
638 + gtk_widget_queue_draw (GTK_WIDGET (menu));
642 + last_visible = menu->lower_arrow_visible;
643 + menu->lower_arrow_visible = offset < menu_height - view_height;
645 + if (menu->lower_arrow_visible)
646 + view_height -= MENU_SCROLL_ARROW_HEIGHT;
648 + if ( (last_visible != menu->lower_arrow_visible) &&
649 + !menu->lower_arrow_visible)
651 + menu->lower_arrow_prelight = FALSE;
653 + /* If we hid the lower arrow, possibly remove timeout */
654 + if (menu->scroll_step > 0)
656 + gtk_menu_stop_scrolling (menu);
657 + gtk_widget_queue_draw (GTK_WIDGET (menu));
661 + if (menu->upper_arrow_visible)
662 + y += MENU_SCROLL_ARROW_HEIGHT;
665 + /* Scroll the menu: */
666 + if (GTK_WIDGET_REALIZED (menu))
667 + gdk_window_move (menu->bin_window, 0, -offset);
669 + if (GTK_WIDGET_REALIZED (menu))
670 + gdk_window_move_resize (menu->view_window,
676 + menu->scroll_offset = offset;
680 +get_attach_info (GtkWidget *child)
682 + GObject *object = G_OBJECT (child);
683 + AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
687 + ai = g_new0 (AttachInfo, 1);
688 + g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
695 +is_grid_attached (AttachInfo *ai)
697 + return (ai->left_attach >= 0 &&
698 + ai->right_attach >= 0 &&
699 + ai->top_attach >= 0 &&
700 + ai->bottom_attach >= 0);
704 +menu_ensure_layout (GtkMenu *menu)
706 + GtkMenuPrivate *priv = gtk_menu_get_private (menu);
708 + if (!priv->have_layout)
710 + GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
712 + gchar *row_occupied;
714 + gint max_right_attach;
715 + gint max_bottom_attach;
717 + /* Find extents of gridded portion */
718 + max_right_attach = 1;
719 + max_bottom_attach = 0;
721 + for (l = menu_shell->children; l; l = l->next)
723 + GtkWidget *child = l->data;
724 + AttachInfo *ai = get_attach_info (child);
726 + if (is_grid_attached (ai))
728 + max_bottom_attach = MAX (max_bottom_attach, ai->bottom_attach);
729 + max_right_attach = MAX (max_right_attach, ai->right_attach);
733 + /* Find empty rows */
734 + row_occupied = g_malloc0 (max_bottom_attach);
736 + for (l = menu_shell->children; l; l = l->next)
738 + GtkWidget *child = l->data;
739 + AttachInfo *ai = get_attach_info (child);
741 + if (is_grid_attached (ai))
745 + for (i = ai->top_attach; i < ai->bottom_attach; i++)
746 + row_occupied[i] = TRUE;
750 + /* Lay non-grid-items out in those rows */
752 + for (l = menu_shell->children; l; l = l->next)
754 + GtkWidget *child = l->data;
755 + AttachInfo *ai = get_attach_info (child);
757 + if (!is_grid_attached (ai))
759 + while (current_row < max_bottom_attach && row_occupied[current_row])
762 + ai->effective_left_attach = 0;
763 + ai->effective_right_attach = max_right_attach;
764 + ai->effective_top_attach = current_row;
765 + ai->effective_bottom_attach = current_row + 1;
771 + ai->effective_left_attach = ai->left_attach;
772 + ai->effective_right_attach = ai->right_attach;
773 + ai->effective_top_attach = ai->top_attach;
774 + ai->effective_bottom_attach = ai->bottom_attach;
778 + g_free (row_occupied);
780 + priv->n_rows = MAX (current_row, max_bottom_attach);
781 + priv->n_columns = max_right_attach;
782 + priv->have_layout = TRUE;
788 +gtk_menu_get_n_columns (GtkMenu *menu)
790 + GtkMenuPrivate *priv = gtk_menu_get_private (menu);
792 + menu_ensure_layout (menu);
794 + return priv->n_columns;
798 +gtk_menu_get_n_rows (GtkMenu *menu)
800 + GtkMenuPrivate *priv = gtk_menu_get_private (menu);
802 + menu_ensure_layout (menu);
804 + return priv->n_rows;
808 +get_effective_child_attach (GtkWidget *child,
814 + GtkMenu *menu = GTK_MENU (child->parent);
817 + menu_ensure_layout (menu);
819 + ai = get_attach_info (child);
822 + *l = ai->effective_left_attach;
824 + *r = ai->effective_right_attach;
826 + *t = ai->effective_top_attach;
828 + *b = ai->effective_bottom_attach;
833 +gtk_menu_set_tearoff_hints (GtkMenu *menu,
836 + GdkGeometry geometry_hints;
838 + if (!menu->tearoff_window)
841 + if (GTK_WIDGET_VISIBLE (menu->tearoff_scrollbar))
843 + gtk_widget_size_request (menu->tearoff_scrollbar, NULL);
844 + width += menu->tearoff_scrollbar->requisition.width;
847 + geometry_hints.min_width = width;
848 + geometry_hints.max_width = width;
850 + geometry_hints.min_height = 0;
851 + geometry_hints.max_height = GTK_WIDGET (menu)->requisition.height;
853 + gtk_window_set_geometry_hints (GTK_WINDOW (menu->tearoff_window),
856 + GDK_HINT_MAX_SIZE|GDK_HINT_MIN_SIZE);
860 +gtk_menu_size_allocate (GtkWidget *widget,
861 + GtkAllocation *allocation)
864 + GtkMenuShell *menu_shell;
866 + GtkAllocation child_allocation;
867 + GtkRequisition child_requisition;
868 + GtkMenuPrivate *priv;
871 + gint width, height;
872 + guint vertical_padding;
873 + guint menu_stripe_width;
875 + g_return_if_fail (GTK_IS_MENU (widget));
876 + g_return_if_fail (allocation != NULL);
878 + menu = GTK_MENU (widget);
879 + menu_shell = GTK_MENU_SHELL (widget);
880 + priv = gtk_menu_get_private (menu);
882 + widget->allocation = *allocation;
883 + gtk_widget_get_child_requisition (GTK_WIDGET (menu), &child_requisition);
885 + gtk_widget_style_get (GTK_WIDGET (menu),
886 + "vertical-padding", &vertical_padding,
889 + x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness;
890 + y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness + vertical_padding;
892 + width = MAX (1, allocation->width - x * 2);
893 + height = MAX (1, allocation->height - y * 2);
895 + child_requisition.width -= x * 2;
896 + child_requisition.height -= y * 2;
898 + if (menu_shell->active)
899 + gtk_menu_scroll_to (menu, menu->scroll_offset);
901 + if (menu->upper_arrow_visible && !menu->tearoff_active)
903 + y += MENU_SCROLL_ARROW_HEIGHT;
904 + height -= MENU_SCROLL_ARROW_HEIGHT;
907 + if (menu->lower_arrow_visible && !menu->tearoff_active)
908 + height -= MENU_SCROLL_ARROW_HEIGHT;
910 + if (GTK_WIDGET_REALIZED (widget))
912 + gdk_window_move_resize (widget->window,
913 + allocation->x, allocation->y,
914 + allocation->width, allocation->height);
916 + gdk_window_move_resize (menu->view_window,
923 +/* inserted for panel-menu.c */
924 + if (panel_global_config_get_menu_stripe () && PANEL_MENU (widget)->side_image) {
925 + menu_stripe_width = gdk_pixbuf_get_width (PANEL_MENU (widget)->side_image) + gtk_widget_get_style (widget)->xthickness;
927 + menu_stripe_width = 0;
929 +/* end panel-menu.c */
931 + if (menu_shell->children)
933 +/* inserted for panel-menu.c */
935 + gint base_width = width / gtk_menu_get_n_columns (menu);
937 + gint base_width = (width - menu_stripe_width) / gtk_menu_get_n_columns (menu);
939 +/* end panel-menu.c */
941 + children = menu_shell->children;
944 + child = children->data;
945 + children = children->next;
947 + if (GTK_WIDGET_VISIBLE (child))
952 + get_effective_child_attach (child, &l, &r, &t, &b);
954 + if (gtk_widget_get_direction (GTK_WIDGET (menu)) == GTK_TEXT_DIR_RTL)
957 + tmp = gtk_menu_get_n_columns (menu) - l;
958 + l = gtk_menu_get_n_columns (menu) - r;
962 + child_allocation.width = (r - l) * base_width;
963 + child_allocation.height = 0;
964 +/* inserted for panel-menu.c */
966 + child_allocation.x = l * base_width;
968 + child_allocation.x = l * base_width + menu_stripe_width;
970 + child_allocation.y = 0;
972 + for (i = 0; i < b; i++)
975 + child_allocation.y += priv->heights[i];
977 + child_allocation.height += priv->heights[i];
981 + gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
982 + menu->toggle_size);
984 + gtk_widget_size_allocate (child, &child_allocation);
988 +/* inserted for panel-menu.c */
989 + if (use_menu_stripe && g_type_is_a (G_OBJECT_TYPE (child), GTK_TYPE_SEPARATOR_MENU_ITEM))
991 + /* this is dumb, gtkmenuitem.c uses allocation.width as an absolute point */
992 + child_allocation.width += gdk_pixbuf_get_width (PANEL_MENU (widget)->side_image);
995 + gtk_widget_size_allocate (child, &child_allocation);
997 + if (use_menu_stripe && g_type_is_a (G_OBJECT_TYPE (child), GTK_TYPE_SEPARATOR_MENU_ITEM))
999 + child_allocation.width -= gdk_pixbuf_get_width (PANEL_MENU (widget)->side_image);
1003 + /* Hack to handle events on the stripe area */
1004 + if (GTK_WIDGET_REALIZED (child) && l == 0)
1006 + gdk_window_move_resize (GTK_MENU_ITEM (child)->event_window,
1007 + 0, child_allocation.y,
1008 + child_allocation.width + child_allocation.x,
1009 + child_allocation.height);
1011 +/* end panel-menu.c */
1013 + gtk_widget_queue_draw (child);
1017 + /* Resize the item window */
1018 + if (GTK_WIDGET_REALIZED (widget))
1021 + gint width, height;
1024 + for (i = 0; i < gtk_menu_get_n_rows (menu); i++)
1025 + height += priv->heights[i];
1027 +/* inserted for panel-menu.c */
1029 + width = gtk_menu_get_n_columns (menu) * base_width;
1031 + width = gtk_menu_get_n_columns (menu) * base_width + menu_stripe_width;
1033 +/* end panel-menu.c */
1035 + gdk_window_resize (menu->bin_window, width, height);
1038 + if (menu->tearoff_active)
1040 + if (allocation->height >= widget->requisition.height)
1042 + if (GTK_WIDGET_VISIBLE (menu->tearoff_scrollbar))
1044 + gtk_widget_hide (menu->tearoff_scrollbar);
1045 + gtk_menu_set_tearoff_hints (menu, allocation->width);
1047 + gtk_menu_scroll_to (menu, 0);
1052 + menu->tearoff_adjustment->upper = widget->requisition.height;
1053 + menu->tearoff_adjustment->page_size = allocation->height;
1055 + if (menu->tearoff_adjustment->value + menu->tearoff_adjustment->page_size >
1056 + menu->tearoff_adjustment->upper)
1059 + value = menu->tearoff_adjustment->upper - menu->tearoff_adjustment->page_size;
1062 + gtk_menu_scroll_to (menu, value);
1065 + gtk_adjustment_changed (menu->tearoff_adjustment);
1067 + if (!GTK_WIDGET_VISIBLE (menu->tearoff_scrollbar))
1069 + gtk_widget_show (menu->tearoff_scrollbar);
1070 + gtk_menu_set_tearoff_hints (menu, allocation->width);
1075 +/* inserted for panel-menu.c */
1078 + PanelMenu *pm = PANEL_MENU (widget);
1080 + gint scaled_height = height;
1082 + if (pm->side_image && widget->allocation.height > gdk_pixbuf_get_height (pm->side_image))
1084 + scaled_height -= gdk_pixbuf_get_height (pm->side_image);
1087 + if (pm->side_image && widget->allocation.height < gdk_pixbuf_get_height (pm->side_image))
1089 + gint scaled_width = ((scaled_height * gdk_pixbuf_get_width (pm->side_image)) / gdk_pixbuf_get_height (pm->side_image));
1091 + if (pm->scaled_image)
1092 + gdk_pixbuf_unref(pm->scaled_image);
1094 + pm->scaled_image = gdk_pixbuf_scale_simple (pm->side_image,
1097 + GDK_INTERP_BILINEAR); /* maybe HYPER ? */
1098 + gdk_pixbuf_unref(pm->side_image);
1099 + pm->side_image = pm->scaled_image;
1103 + gboolean draw_gradient;
1104 + gtk_widget_style_get (GTK_WIDGET (pm),
1105 + "gradient_bg", &draw_gradient,
1108 + if (pm->side_image && draw_gradient)
1110 + GdkColor *stripe_color;
1111 + GdkColor *light_color;
1113 + stripe_color = get_stripe_color (pm);
1114 + light_color = get_light_stripe_color (pm);
1115 + pm->scaled_image = meta_gradient_create_vertical
1116 + (gdk_pixbuf_get_width (pm->side_image),
1120 + gdk_color_free (light_color);
1121 + gdk_color_free (stripe_color);
1125 +/* end panel-menu.c */
1128 +/* end gtkmenu cut and paste */
1131 +unload_images (PanelMenu *pm)
1133 + if (pm->side_image) {
1134 + g_object_unref (pm->side_image);
1135 + pm->side_image = NULL;
1138 + if (pm->scaled_image) {
1139 + g_object_unref (pm->scaled_image);
1140 + pm->scaled_image = NULL;
1145 +get_stripe_image (PanelMenu *pm,
1147 + const char *default_filename)
1149 + GdkPixbuf *image = NULL;
1152 + gtk_widget_style_get (GTK_WIDGET (pm), name, &file_src, NULL);
1155 + file_src = gnome_program_locate_file (NULL,
1156 + GNOME_FILE_DOMAIN_PIXMAP,
1163 + image = gdk_pixbuf_new_from_file (file_src, NULL);
1165 + g_free (file_src);
1171 +load_images (PanelMenu *pm)
1175 + unload_images (pm);
1177 + pm->side_image = get_stripe_image (pm, "default_side_image",
1178 + "pld-desktop-stripe.png");
1182 +panel_menu_style_set (GtkWidget *widget,
1183 + GtkStyle *old_style)
1185 + load_images (PANEL_MENU (widget));
1186 + GNOME_CALL_PARENT (GTK_WIDGET_CLASS, style_set, (widget, old_style));
1190 +panel_menu_destroy (GtkObject *object)
1192 + PanelMenu *pm = PANEL_MENU (object);
1194 + unload_images (pm);
1196 + GNOME_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
1200 +panel_menu_finalize (GObject *object)
1202 + GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
1206 +panel_menu_class_init (PanelMenuClass *klass)
1208 + GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1209 + GtkObjectClass *gtk_object_class = (GtkObjectClass *)klass;
1210 + GObjectClass *object_class = (GObjectClass *) klass;
1212 + gtk_widget_class_install_style_property (
1214 + g_param_spec_string ("default_side_image",
1215 + _("Default Side Image"),
1216 + _("Filename of logo down the side of applications menu"),
1218 + G_PARAM_READWRITE));
1220 + gtk_widget_class_install_style_property (
1222 + g_param_spec_boolean ("gradient_bg",
1223 + _("Gradient Background"),
1224 + _("Draw a gradient in the menu stripe"),
1226 + G_PARAM_READWRITE));
1227 + gtk_widget_class_install_style_property (
1229 + g_param_spec_boxed ("stripe_color",
1230 + _("Stripe Color"),
1231 + _("Color of the panel menu stripe"),
1233 + G_PARAM_READABLE));
1235 + gtk_widget_class_install_style_property (
1237 + g_param_spec_boxed ("stripe_color_light",
1238 + _("Light Stripe Color"),
1239 + _("Light color of the panel menu stripe, for gradients"),
1241 + G_PARAM_READABLE));
1243 + object_class->finalize = panel_menu_finalize;
1244 + gtk_object_class->destroy = panel_menu_destroy;
1245 + widget_class->size_request = panel_menu_size_request;
1246 + widget_class->size_allocate = gtk_menu_size_allocate;
1247 + widget_class->expose_event = panel_menu_expose_event;
1248 + widget_class->style_set = panel_menu_style_set;
1252 +panel_menu_instance_init (PanelMenu *pm)
1254 + gtk_widget_ensure_style (GTK_WIDGET (pm));
1258 + gtk_widget_add_events (
1260 + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
1261 + GDK_POINTER_MOTION_MASK);
1263 diff -urN aa/gnome-panel-2.6.0/gnome-panel/panel-menu.h gnome-panel-2.6.0/gnome-panel/panel-menu.h
1264 --- aa/gnome-panel-2.6.0/gnome-panel/panel-menu.h 1970-01-01 01:00:00.000000000 +0100
1265 +++ gnome-panel-2.6.0/gnome-panel/panel-menu.h 2004-03-27 00:29:00.640043704 +0100
1267 +#include <gtk/gtkmenu.h>
1268 +#include <gtk/gtkimage.h>
1270 +typedef struct _PanelMenu PanelMenu;
1271 +typedef struct _PanelMenuClass PanelMenuClass;
1273 +#define PANEL_MENU(obj) \
1274 + GTK_CHECK_CAST (obj, panel_menu_get_type (), PanelMenu)
1275 +#define PANEL_MENU_CLASS(k) \
1276 + GTK_CHECK_CLASS_CAST (k, panel_menu_get_type (), PanelMenuClass)
1277 +#define PANEL_IS_MENU(obj) \
1278 + GTK_CHECK_TYPE (obj, panel_menu_get_type ())
1285 + GdkPixbuf *side_image;
1286 + GdkPixbuf *scaled_image;
1288 + GdkRegion *navigation_region;
1291 +struct _PanelMenuClass
1293 + GtkMenuClass parent_class;
1296 +GType panel_menu_get_type (void);
1297 +GtkWidget *panel_menu_evolve (void);