Bug 1271523 - Construct tooltip style from path for Gtk >= 3.20, r=karlt

To apply it needs a patch from Bug 1277818.
This commit is contained in:
Martin Stransky 2016-06-07 06:22:00 +02:00
Родитель baf7982f87
Коммит 34f103fe45
3 изменённых файлов: 29 добавлений и 34 удалений

Просмотреть файл

@ -105,6 +105,17 @@ CreateProgressWidget()
return widget;
}
static GtkWidget*
CreateTooltipWidget()
{
MOZ_ASSERT(gtk_check_version(3, 20, 0) != nullptr,
"CreateTooltipWidget should be used for Gtk < 3.20 only.");
GtkWidget* widget = CreateWindowWidget();
GtkStyleContext* style = gtk_widget_get_style_context(widget);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
return widget;
}
static GtkWidget*
CreateWidget(WidgetNodeType aWidgetType)
{
@ -133,6 +144,8 @@ CreateWidget(WidgetNodeType aWidgetType)
return CreateMenuItemWidget(MOZ_GTK_MENUBAR);
case MOZ_GTK_MENUITEM:
return CreateMenuItemWidget(MOZ_GTK_MENUPOPUP);
case MOZ_GTK_TOOLTIP:
return CreateTooltipWidget();
default:
/* Not implemented */
return nullptr;
@ -221,6 +234,11 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType)
style = CreateChildCSSNode("progress",
MOZ_GTK_PROGRESS_TROUGH);
break;
case MOZ_GTK_TOOLTIP:
// We create this from the path because GtkTooltipWindow is not public.
style = CreateCSSNode("tooltip", nullptr, GTK_TYPE_TOOLTIP);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
break;
default:
// TODO - create style from style path
GtkWidget* widget = GetWidget(aNodeType);

Просмотреть файл

@ -39,7 +39,6 @@ static GtkWidget* gToolbarWidget;
static GtkWidget* gFrameWidget;
static GtkWidget* gTabWidget;
static GtkWidget* gTextViewWidget;
static GtkWidget* gTooltipWidget;
static GtkWidget* gImageMenuItemWidget;
static GtkWidget* gCheckMenuItemWidget;
static GtkWidget* gTreeViewWidget;
@ -88,15 +87,6 @@ GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
return stateFlags;
}
/* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
things they may want to do. */
static void
moz_gtk_set_widget_name(GtkWidget* widget)
{
gtk_widget_set_name(widget, "MozillaGtkWidget");
}
gint
moz_gtk_enable_style_props(style_prop_t styleGetProp)
{
@ -446,19 +436,6 @@ ensure_toolbar_separator_widget()
return MOZ_GTK_SUCCESS;
}
static gint
ensure_tooltip_widget()
{
if (!gTooltipWidget) {
gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
GtkStyleContext* style = gtk_widget_get_style_context(gTooltipWidget);
gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
gtk_widget_realize(gTooltipWidget);
moz_gtk_set_widget_name(gTooltipWidget);
}
return MOZ_GTK_SUCCESS;
}
static gint
ensure_tab_widget()
{
@ -1809,14 +1786,10 @@ static gint
moz_gtk_tooltip_paint(cairo_t *cr, GdkRectangle* rect,
GtkTextDirection direction)
{
GtkStyleContext* style;
ensure_tooltip_widget();
gtk_widget_set_direction(gTooltipWidget, direction);
style = gtk_widget_get_style_context(gTooltipWidget);
GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TOOLTIP, direction);
gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
@ -2738,6 +2711,14 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
ensure_info_bar();
w = gInfoBar;
break;
case MOZ_GTK_TOOLTIP:
{
style = ClaimStyleContext(MOZ_GTK_TOOLTIP);
moz_gtk_add_style_border(style, left, top, right, bottom);
moz_gtk_add_style_padding(style, left, top, right, bottom);
ReleaseStyleContext(style);
return MOZ_GTK_SUCCESS;
}
/* These widgets have no borders, since they are not containers. */
case MOZ_GTK_CHECKBUTTON_LABEL:
case MOZ_GTK_RADIOBUTTON_LABEL:
@ -2761,7 +2742,6 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
case MOZ_GTK_MENUSEPARATOR:
/* These widgets have no borders.*/
case MOZ_GTK_SPINBUTTON:
case MOZ_GTK_TOOLTIP:
case MOZ_GTK_WINDOW:
case MOZ_GTK_RESIZER:
case MOZ_GTK_MENUARROW:
@ -3287,10 +3267,7 @@ gboolean moz_gtk_has_scrollbar_buttons(void)
gint
moz_gtk_shutdown()
{
if (gTooltipWidget)
gtk_widget_destroy(gTooltipWidget);
/* This will destroy all of our widgets */
ResetWidgetCache();
/* TODO - replace it with appropriate widget */
@ -3318,7 +3295,6 @@ moz_gtk_shutdown()
gFrameWidget = NULL;
gTabWidget = NULL;
gTextViewWidget = nullptr;
gTooltipWidget = NULL;
gImageMenuItemWidget = NULL;
gCheckMenuItemWidget = NULL;
gTreeViewWidget = NULL;

Просмотреть файл

@ -411,6 +411,7 @@ STUB(gtk_toggle_button_new)
STUB(gtk_toggle_button_set_active)
STUB(gtk_toggle_button_set_inconsistent)
STUB(gtk_toolbar_new)
STUB(gtk_tooltip_get_type)
STUB(gtk_tree_view_append_column)
STUB(gtk_tree_view_column_new)
STUB(gtk_tree_view_column_set_title)