GtkToolShell: Move vfunc default results to default implementations.

Otherwise the default values are only used if no vfunc is set,
making that default unavailable to vfunc implementations as a fallback,
and unavailable to language bindings (such as gtkmm) that always
have a vfunc implementation, even if that often only tries to call
the base vfunc implemntation.

This was making gtkmm's ToolPalette's (and probably ToolBar's)
items look like buttons instead of being flat.

https://bugzilla.gnome.org/show_bug.cgi?id=656223
This commit is contained in:
Murray Cumming 2011-08-09 16:55:01 +02:00
parent 9379a48e22
commit 342c64c2f2

View File

@ -47,10 +47,42 @@
typedef GtkToolShellIface GtkToolShellInterface; typedef GtkToolShellIface GtkToolShellInterface;
G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET); G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
static GtkReliefStyle gtk_tool_shell_real_get_relief_style (GtkToolShell *shell);
static GtkOrientation gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell);
static gfloat gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell);
static PangoEllipsizeMode gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell);
static void static void
gtk_tool_shell_default_init (GtkToolShellInterface *iface) gtk_tool_shell_default_init (GtkToolShellInterface *iface)
{ {
iface->get_relief_style = gtk_tool_shell_real_get_relief_style;
iface->get_text_orientation = gtk_tool_shell_real_get_text_orientation;
iface->get_text_alignment = gtk_tool_shell_real_get_text_alignment;
iface->get_ellipsize_mode = gtk_tool_shell_real_get_ellipsize_mode;
}
static GtkReliefStyle
gtk_tool_shell_real_get_relief_style (GtkToolShell *shell)
{
return GTK_RELIEF_NONE;
}
static GtkOrientation
gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell)
{
return GTK_ORIENTATION_HORIZONTAL;
}
static gfloat
gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell)
{
return 0.5f;
}
static PangoEllipsizeMode
gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell)
{
return PANGO_ELLIPSIZE_NONE;
} }
@ -123,10 +155,7 @@ gtk_tool_shell_get_relief_style (GtkToolShell *shell)
{ {
GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell); GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
if (iface->get_relief_style) return iface->get_relief_style (shell);
return iface->get_relief_style (shell);
return GTK_RELIEF_NONE;
} }
/** /**
@ -168,10 +197,7 @@ gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
{ {
GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell); GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
if (iface->get_text_orientation) return iface->get_text_orientation (shell);
return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_orientation (shell);
return GTK_ORIENTATION_HORIZONTAL;
} }
/** /**
@ -191,10 +217,7 @@ gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
{ {
GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell); GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
if (iface->get_text_alignment) return iface->get_text_alignment (shell);
return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_alignment (shell);
return 0.5f;
} }
/** /**
@ -214,10 +237,7 @@ gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
{ {
GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell); GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
if (iface->get_ellipsize_mode) return iface->get_ellipsize_mode (shell);
return GTK_TOOL_SHELL_GET_IFACE (shell)->get_ellipsize_mode (shell);
return PANGO_ELLIPSIZE_NONE;
} }
/** /**