[gedit] Use a more polished way to remove the custom style from the notebook.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Use a more polished way to remove the custom style from the notebook.
- Date: Wed, 12 Jan 2011 15:03:06 +0000 (UTC)
commit 0e5dedf5c4a44f9f7cc28952d76ad70f7c2d0552
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Jan 12 16:02:57 2011 +0100
Use a more polished way to remove the custom style from the notebook.
gedit/gedit-notebook.c | 59 +++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index 8fd86d1..88ca5c6 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -62,10 +62,9 @@ struct _GeditNotebookPrivate
GeditNotebookShowTabsModeType show_tabs_mode;
- GtkBorder padding;
+ GtkCssProvider *css;
guint close_buttons_sensitive : 1;
- guint collapse_border : 1;
};
G_DEFINE_TYPE(GeditNotebook, gedit_notebook, GTK_TYPE_NOTEBOOK)
@@ -169,6 +168,12 @@ gedit_notebook_dispose (GObject *object)
notebook->priv->ui_settings = NULL;
}
+ if (notebook->priv->css != NULL)
+ {
+ g_object_unref (notebook->priv->css);
+ notebook->priv->css = NULL;
+ }
+
G_OBJECT_CLASS (gedit_notebook_parent_class)->dispose (object);
}
@@ -656,48 +661,42 @@ gedit_notebook_collapse_border (GeditNotebook *nb,
gboolean collapse)
{
GtkStyleContext *context;
- GtkCssProvider *css;
GError *error = NULL;
- gchar *modified_style;
- const gchar notebook_style[] =
+ const gchar style[] =
"* {\n"
- " padding-left: %d;\n"
- " padding-right: %d;\n"
+ " padding-left: 0;\n"
+ " padding-right: 0;\n"
"}";
g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
- nb->priv->collapse_border = collapse;
context = gtk_widget_get_style_context (GTK_WIDGET (nb));
if (collapse)
{
- gtk_style_context_get_padding (context, 0, &nb->priv->padding);
- modified_style = g_strdup_printf (notebook_style, 0, 0);
- }
- else
- {
- modified_style = g_strdup_printf (notebook_style,
- nb->priv->padding.left,
- nb->priv->padding.right);
- }
+ /* make it as small as possible */
+ if (nb->priv->css == NULL)
+ {
+ nb->priv->css = gtk_css_provider_new ();
+ }
- /* make it as small as possible */
- css = gtk_css_provider_new ();
- if (gtk_css_provider_load_from_data (css, modified_style,
- -1, &error))
- {
- gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ if (gtk_css_provider_load_from_data (nb->priv->css, style, -1, &error))
+ {
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (nb->priv->css),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ else
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
- else
+ else if (nb->priv->css != NULL)
{
- g_warning ("%s", error->message);
- g_error_free (error);
+ gtk_style_context_remove_provider (context,
+ GTK_STYLE_PROVIDER (nb->priv->css));
}
-
- g_free (modified_style);
- g_object_unref (css);
}
/* ex:set ts=8 noet: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]