QGtkStyle: GTK3 compatible combo boxes
Use gtk_combo_box_new_with_entry when gtk_combo_box_entry_new is not available. The latter was deprecated since 2.24 and is no longer available in GTK3. Notice that gtk_combo_box_new_with_entry returns a GtkComboBox, whereas the old gtk_combo_box_entry_new returned a GtkComboBoxEntry. Change-Id: I4aa3c528c6e04967ed783fce72036acb6063445b Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
This commit is contained in:
parent
b73465550b
commit
15fc255c7c
@ -1835,7 +1835,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
|
||||
GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
|
||||
GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
|
||||
const QHashableLatin1Literal comboBoxPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
|
||||
QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
|
||||
|
||||
// We use the gtk widget to position arrows and separators for us
|
||||
GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
|
||||
@ -1843,8 +1844,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
|
||||
d->gtk_widget_size_allocate(gtkCombo, &geometry);
|
||||
|
||||
QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
|
||||
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
|
||||
QHashableLatin1Literal buttonPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
|
||||
QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
|
||||
GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
|
||||
d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
|
||||
if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
|
||||
@ -1853,7 +1854,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
// Draw the combo box as a line edit with a button next to it
|
||||
if (comboBox->editable || appears_as_list) {
|
||||
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
|
||||
QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
|
||||
QHashableLatin1Literal entryPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry")
|
||||
: comboBox->editable ? QHashableLatin1Literal("GtkComboBox.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
|
||||
GtkWidget *gtkEntry = d->gtkWidget(entryPath);
|
||||
d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
|
||||
QRect frameRect = option->rect;
|
||||
@ -1921,7 +1923,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
|
||||
|
||||
// Draw the separator between label and arrows
|
||||
QHashableLatin1Literal vSeparatorPath = comboBox->editable
|
||||
QHashableLatin1Literal vSeparatorPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new
|
||||
? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
|
||||
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
|
||||
|
||||
@ -1958,7 +1960,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
state = GTK_STATE_NORMAL;
|
||||
|
||||
QHashableLatin1Literal arrowPath("");
|
||||
if (comboBox->editable) {
|
||||
if (comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new) {
|
||||
if (appears_as_list)
|
||||
arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
|
||||
else
|
||||
@ -1996,7 +1998,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
|
||||
|
||||
if (sunken) {
|
||||
int xoff, yoff;
|
||||
const QHashableLatin1Literal toggleButtonPath = comboBox->editable
|
||||
const QHashableLatin1Literal toggleButtonPath = comboBox->editable && QGtkStylePrivate::gtk_combo_box_entry_new
|
||||
? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
|
||||
: QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
|
||||
|
||||
@ -3763,19 +3765,15 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
|
||||
case CC_ComboBox:
|
||||
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
// We employ the gtk widget to position arrows and separators for us
|
||||
GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
|
||||
: d->gtkWidget("GtkComboBox");
|
||||
GtkWidget *gtkCombo = box->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
|
||||
d->gtkWidget("GtkComboBoxEntry") : d->gtkWidget("GtkComboBox");
|
||||
d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
|
||||
GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
|
||||
d->gtk_widget_size_allocate(gtkCombo, &geometry);
|
||||
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
|
||||
QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
|
||||
if (!box->editable) {
|
||||
if (appears_as_list)
|
||||
arrowPath = "GtkComboBox.GtkToggleButton";
|
||||
else
|
||||
arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
|
||||
}
|
||||
QHashableLatin1Literal arrowPath = box->editable && QGtkStylePrivate::gtk_combo_box_entry_new ?
|
||||
QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") : box->editable || appears_as_list ?
|
||||
QHashableLatin1Literal("GtkComboBox.GtkToggleButton") : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
|
||||
|
||||
GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
|
||||
if (!arrowWidget)
|
||||
|
@ -130,6 +130,7 @@ Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new =
|
||||
Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
|
||||
Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
|
||||
Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
|
||||
Ptr_gtk_combo_box_new_with_entry QGtkStylePrivate::gtk_combo_box_new_with_entry = 0;
|
||||
Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
|
||||
Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
|
||||
Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
|
||||
@ -420,6 +421,8 @@ void QGtkStylePrivate::resolveGtk() const
|
||||
gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
|
||||
gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
|
||||
gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
|
||||
gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
|
||||
gtk_combo_box_new_with_entry = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_new_with_entry");
|
||||
gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
|
||||
gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
|
||||
gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
|
||||
@ -459,7 +462,6 @@ void QGtkStylePrivate::resolveGtk() const
|
||||
gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
|
||||
gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
|
||||
gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
|
||||
gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
|
||||
gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
|
||||
gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
|
||||
gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
|
||||
@ -598,7 +600,10 @@ void QGtkStylePrivate::initGtkWidgets() const
|
||||
addWidget(QGtkStylePrivate::gtk_check_button_new());
|
||||
addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
|
||||
addWidget(QGtkStylePrivate::gtk_combo_box_new());
|
||||
addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
|
||||
if (gtk_combo_box_entry_new)
|
||||
addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
|
||||
if (gtk_combo_box_new_with_entry)
|
||||
addWidget(QGtkStylePrivate::gtk_combo_box_new_with_entry());
|
||||
addWidget(QGtkStylePrivate::gtk_entry_new());
|
||||
addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
|
||||
addWidget(QGtkStylePrivate::gtk_expander_new(""));
|
||||
|
@ -149,7 +149,9 @@ typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
|
||||
typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_combo_box_new_with_entry)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
|
||||
typedef GtkWidget* (*Ptr_gtk_button_new)(void);
|
||||
@ -169,7 +171,6 @@ typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
|
||||
typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
|
||||
typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
|
||||
typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
|
||||
typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
|
||||
typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
|
||||
typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
|
||||
@ -409,6 +410,7 @@ public:
|
||||
static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
|
||||
static Ptr_gtk_combo_box_new gtk_combo_box_new;
|
||||
static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
|
||||
static Ptr_gtk_combo_box_new_with_entry gtk_combo_box_new_with_entry;
|
||||
static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
|
||||
static Ptr_gtk_container_add gtk_container_add;
|
||||
static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
|
||||
|
Loading…
Reference in New Issue
Block a user