diff options
-rw-r--r-- | pluma/pluma-status-combo-box.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/pluma/pluma-status-combo-box.c b/pluma/pluma-status-combo-box.c index 20166c59..91973ca6 100644 --- a/pluma/pluma-status-combo-box.c +++ b/pluma/pluma-status-combo-box.c @@ -106,6 +106,39 @@ pluma_status_combo_box_set_property (GObject *object, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +pluma_status_combo_box_constructed (GObject *object) +{ + PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (object); + GtkStyleContext *context; + GtkCssProvider *css; + GError *error = NULL; + const gchar style[] = + "* {\n" +#if !GTK_CHECK_VERSION (3, 20, 0) + " -GtkWidget-focus-line-width: 0;\n" + " -GtkWidget-focus-padding: 0;\n" +#endif + " padding: 0;\n" + "}"; + + /* make it as small as possible */ + css = gtk_css_provider_new (); + if (!gtk_css_provider_load_from_data (css, style, -1, &error)) + { + g_warning ("%s", error->message); + g_error_free (error); + return; + } + + context = gtk_widget_get_style_context (GTK_WIDGET (combo)); + gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (css); +} +#endif + static void pluma_status_combo_box_changed (PlumaStatusComboBox *combo, GtkMenuItem *item) @@ -129,6 +162,9 @@ pluma_status_combo_box_class_init (PlumaStatusComboBoxClass *klass) object_class->finalize = pluma_status_combo_box_finalize; object_class->get_property = pluma_status_combo_box_get_property; object_class->set_property = pluma_status_combo_box_set_property; +#if GTK_CHECK_VERSION (3, 0, 0) + object_class->constructed = pluma_status_combo_box_constructed; +#endif klass->changed = pluma_status_combo_box_changed; @@ -148,6 +184,7 @@ pluma_status_combo_box_class_init (PlumaStatusComboBoxClass *klass) NULL, G_PARAM_READWRITE)); +#if !GTK_CHECK_VERSION (3, 0, 0) /* Set up a style for the button to decrease spacing. */ gtk_rc_parse_string ( "style \"pluma-status-combo-button-style\"\n" @@ -158,6 +195,7 @@ pluma_status_combo_box_class_init (PlumaStatusComboBoxClass *klass) " ythickness = 0\n" "}\n" "widget \"*.pluma-status-combo-button\" style \"pluma-status-combo-button-style\""); +#endif g_type_class_add_private (object_class, sizeof(PlumaStatusComboBoxPrivate)); } @@ -246,6 +284,17 @@ button_press_event (GtkWidget *widget, static void set_shadow_type (PlumaStatusComboBox *combo) { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context; + GtkShadowType shadow_type; + GtkWidget *statusbar; + + /* This is a hack needed to use the shadow type of a statusbar */ + statusbar = gtk_statusbar_new (); + context = gtk_widget_get_style_context (statusbar); + + gtk_style_context_get_style (context, "shadow-type", &shadow_type, NULL); +#else GtkShadowType shadow_type; GtkWidget *statusbar; @@ -254,6 +303,7 @@ set_shadow_type (PlumaStatusComboBox *combo) gtk_widget_ensure_style (statusbar); gtk_widget_style_get (statusbar, "shadow-type", &shadow_type, NULL); +#endif gtk_frame_set_shadow_type (GTK_FRAME (combo->priv->frame), shadow_type); gtk_widget_destroy (statusbar); |