Re: [PATCH] Configurable shadow for GtkMenuBar



On Sat, 14 Nov 1998, Manish Singh wrote:

> The patch below adds a configurable shadow setting for GtkMenuBar, which makes
> some apps like Mozilla look nicer. It's patterned after GtkFrame.
> 
> It also changes other structures to use enum types instead of generic ones
> for better readibility and type checking.

hi yosh,
i've not applied your patch to my tree yet, but didn't hesitate to comment it
anyways ;)
besides the shadow_type addition to GtkMenuBar, it would be nice to
also be able to set the menu item reliefs, so we get even closer to the
original mozilla look.

> 
> If nobody objects to this, I'll commit it tomorrow.
> 
> -Yosh
> 
> Index: gtkarrow.h
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkarrow.h,v
> retrieving revision 1.3
> diff -u -r1.3 gtkarrow.h
> --- gtkarrow.h	1998/06/29 11:41:46	1.3
> +++ gtkarrow.h	1998/11/15 06:02:21
> @@ -43,8 +43,8 @@
>  {
>    GtkMisc misc;
>  
> -  gint16 arrow_type;
> -  gint16 shadow_type;
> +  GtkArrowType arrow_type;
> +  GtkShadowType shadow_type;

these two fields should stay gint16s so they get packed together (we
save one int per strcuture, which is 4 bytes on intel or 8 bytes on
alpha).

>  };
>  
>  struct _GtkArrowClass
> Index: gtkframe.h
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkframe.h,v
> retrieving revision 1.4
> diff -u -r1.4 gtkframe.h
> --- gtkframe.h	1998/10/07 04:20:33	1.4
> +++ gtkframe.h	1998/11/15 06:02:21
> @@ -44,7 +44,9 @@
>    GtkBin bin;
>    
>    gchar *label;
> -  gint16 shadow_type;
> +
> +  GtkShadowType shadow_type;
> +

s/GtkShadowType/gint16/ like above

>    gint16 label_width;
>    gint16 label_height;
>    gfloat label_xalign;
> Index: gtkmenubar.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkmenubar.c,v
> retrieving revision 1.12
> diff -u -r1.12 gtkmenubar.c
> --- gtkmenubar.c	1998/11/06 22:04:16	1.12
> +++ gtkmenubar.c	1998/11/15 06:02:21
> @@ -22,13 +22,24 @@
>  #include "gtkmenubar.h"
>  #include "gtkmenuitem.h"
>  
> +enum {
> +  ARG_0,
> +  ARG_SHADOW
> +};
>  
> +
>  #define BORDER_SPACING  2
>  #define CHILD_SPACING   3
>  
>  
>  static void gtk_menu_bar_class_init    (GtkMenuBarClass *klass);
>  static void gtk_menu_bar_init          (GtkMenuBar      *menu_bar);
> +static void gtk_menu_bar_set_arg       (GtkObject      *object,
> +					GtkArg         *arg,
> +					guint           arg_id);
> +static void gtk_menu_bar_get_arg       (GtkObject      *object,
> +					GtkArg         *arg,
> +					guint           arg_id);
>  static void gtk_menu_bar_size_request  (GtkWidget       *widget,
>  					GtkRequisition  *requisition);
>  static void gtk_menu_bar_size_allocate (GtkWidget       *widget,
> @@ -69,14 +80,21 @@
>  static void
>  gtk_menu_bar_class_init (GtkMenuBarClass *class)
>  {
> +  GtkObjectClass *object_class;
>    GtkWidgetClass *widget_class;
>    GtkMenuShellClass *menu_shell_class;
>  
>    GtkBindingSet *binding_set;
>  
> +  object_class = (GtkObjectClass*) class;
>    widget_class = (GtkWidgetClass*) class;
>    menu_shell_class = (GtkMenuShellClass*) class;
>  
> +  gtk_object_add_arg_type ("GtkMenuBar::shadow", GTK_TYPE_SHADOW_TYPE, GTK_ARG_READWRITE, ARG_SHADOW);
> +
> +  object_class->set_arg = gtk_menu_bar_set_arg;
> +  object_class->get_arg = gtk_menu_bar_get_arg;
> +
>    widget_class->draw = gtk_menu_bar_draw;
>    widget_class->size_request = gtk_menu_bar_size_request;
>    widget_class->size_allocate = gtk_menu_bar_size_allocate;
> @@ -110,8 +128,48 @@
>  static void
>  gtk_menu_bar_init (GtkMenuBar *menu_bar)
>  {
> +  menu_bar->shadow_type = GTK_SHADOW_OUT;
> +}
> +
> +static void
> +gtk_menu_bar_set_arg (GtkObject      *object,
> +		      GtkArg         *arg,
> +		      guint           arg_id)
> +{
> +  GtkMenuBar *menu_bar;
> +
> +  menu_bar = GTK_MENU_BAR (object);
> +
> +  switch (arg_id)
> +    {
> +    case ARG_SHADOW:
> +      gtk_menu_bar_set_shadow_type (menu_bar, GTK_VALUE_ENUM (*arg));
> +      break;
> +    default:
> +      break;
> +    }
>  }
>  
> +static void
> +gtk_menu_bar_get_arg (GtkObject      *object,
> +		      GtkArg         *arg,
> +		      guint           arg_id)
> +{
> +  GtkMenuBar *menu_bar;
> +
> +  menu_bar = GTK_MENU_BAR (object);
> +
> +  switch (arg_id)
> +    {
> +    case ARG_SHADOW:
> +      GTK_VALUE_ENUM (*arg) = menu_bar->shadow_type;
> +      break;
> +    default:
> +      arg->type = GTK_TYPE_INVALID;
> +      break;
> +    }
> +}
> + 
>  GtkWidget*
>  gtk_menu_bar_new (void)
>  {
> @@ -262,6 +320,25 @@
>      }
>  }
>  
> +void
> +gtk_menu_bar_set_shadow_type (GtkMenuBar    *menu_bar,
> +			      GtkShadowType  type)
> +{
> +  g_return_if_fail (menu_bar != NULL);
> +  g_return_if_fail (GTK_IS_MENU_BAR (menu_bar));
> +
> +  if ((GtkShadowType) menu_bar->shadow_type != type)
> +    {
> +      menu_bar->shadow_type = type;
> +
> +      if (GTK_WIDGET_DRAWABLE (menu_bar))
> +        {
> +          gtk_widget_queue_clear (GTK_WIDGET (menu_bar));
> +        }
> +      gtk_widget_queue_resize (GTK_WIDGET (menu_bar));
> +    }
> +}
> +
>  static void
>  gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
>  {
> @@ -273,7 +350,7 @@
>        gtk_paint_box (widget->style,
>  		     widget->window,
>  		     GTK_STATE_NORMAL,
> -		     GTK_SHADOW_OUT,
> +		     GTK_MENU_BAR (widget)->shadow_type,


>  		     area, widget, "menubar",
>  		     0, 0,
>  		     -1,-1);
> Index: gtkmenubar.h
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkmenubar.h,v
> retrieving revision 1.4
> diff -u -r1.4 gtkmenubar.h
> --- gtkmenubar.h	1998/10/07 04:20:44	1.4
> +++ gtkmenubar.h	1998/11/15 06:02:21
> @@ -41,6 +41,8 @@
>  struct _GtkMenuBar
>  {
>    GtkMenuShell menu_shell;
> +
> +  GtkShadowType shadow_type;
>  };
>  
>  struct _GtkMenuBarClass
> @@ -49,15 +51,17 @@
>  };
>  
>  
> -GtkType    gtk_menu_bar_get_type (void);
> -GtkWidget* gtk_menu_bar_new      (void);
> -void       gtk_menu_bar_append   (GtkMenuBar *menu_bar,
> -				  GtkWidget  *child);
> -void       gtk_menu_bar_prepend  (GtkMenuBar *menu_bar,
> -				  GtkWidget  *child);
> -void       gtk_menu_bar_insert   (GtkMenuBar *menu_bar,
> -				  GtkWidget  *child,
> -				  gint        position);
> +GtkType    gtk_menu_bar_get_type        (void);
> +GtkWidget* gtk_menu_bar_new             (void);
> +void       gtk_menu_bar_append          (GtkMenuBar    *menu_bar,
> +					 GtkWidget     *child);
> +void       gtk_menu_bar_prepend         (GtkMenuBar    *menu_bar,
> +					 GtkWidget     *child);
> +void       gtk_menu_bar_insert          (GtkMenuBar    *menu_bar,
> +					 GtkWidget     *child,
> +					 gint           position);
> +void       gtk_menu_bar_set_shadow_type (GtkMenuBar    *menu_bar,
> +					 GtkShadowType  type);
>  
>  
>  #ifdef __cplusplus
> Index: gtkviewport.h
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkviewport.h,v
> retrieving revision 1.4
> diff -u -r1.4 gtkviewport.h
> --- gtkviewport.h	1998/07/16 02:47:13	1.4
> +++ gtkviewport.h	1998/11/15 06:02:21
> @@ -44,7 +44,7 @@
>  {
>    GtkBin bin;
>  
> -  guint shadow_type;
> +  GtkShadowType shadow_type;
>    GdkWindow *view_window;
>    GdkWindow *bin_window;
>    GtkAdjustment *hadjustment;
> 
> 
> -- 
>          To unsubscribe: mail gtk-devel-list-request@redhat.com with 
>                        "unsubscribe" as the Subject.
> 
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]