[gedit] [gedit-notebook] factor out a remove_right_padding
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] [gedit-notebook] factor out a remove_right_padding
- Date: Sat, 5 Mar 2011 20:13:57 +0000 (UTC)
commit cdb35c0b2929f5055a424ce880492fc106a5ae20
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Mar 5 21:13:27 2011 +0100
[gedit-notebook] factor out a remove_right_padding
gedit/gedit-notebook.c | 62 +++++++++++++++++++++++++++--------------------
1 files changed, 36 insertions(+), 26 deletions(-)
---
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index 6a72f86..b8c7d1c 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -656,56 +656,66 @@ gedit_notebook_get_close_buttons_sensitive (GeditNotebook *nb)
return nb->priv->close_buttons_sensitive;
}
-void
-gedit_notebook_collapse_border (GeditNotebook *nb,
- gboolean collapse)
+static void
+remove_right_padding (GeditNotebook *nb)
{
GtkStyleContext *context;
- GError *error = NULL;
GtkBorder padding;
gchar *modified_style;
+ GError *error = NULL;
const gchar style[] =
".notebook {\n"
" padding: %d 0 %d %d;\n"
"}";
- g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
-
/* FIXME: find out a css like way to do this, right now padding-right/left
- doesn't work */
+ doesn't work */
context = gtk_widget_get_style_context (GTK_WIDGET (nb));
gtk_style_context_get_padding (context, gtk_style_context_get_state (context),
&padding);
modified_style = g_strdup_printf (style, padding.top, padding.bottom, padding.left);
- if (collapse)
+ /* make it as small as possible */
+ if (nb->priv->css == NULL)
{
- /* make it as small as possible */
- if (nb->priv->css == NULL)
- {
- nb->priv->css = gtk_css_provider_new ();
- }
+ nb->priv->css = gtk_css_provider_new ();
+ }
- if (gtk_css_provider_load_from_data (nb->priv->css, modified_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);
- }
+ if (gtk_css_provider_load_from_data (nb->priv->css, modified_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);
+ }
+
+ g_free (modified_style);
+}
+
+void
+gedit_notebook_collapse_border (GeditNotebook *nb,
+ gboolean collapse)
+{
+ g_return_if_fail (GEDIT_IS_NOTEBOOK (nb));
+
+ if (collapse)
+ {
+ remove_right_padding (nb);
}
+ /* if we made some modification put it back to the default state */
else if (nb->priv->css != NULL)
{
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (nb));
gtk_style_context_remove_provider (context,
GTK_STYLE_PROVIDER (nb->priv->css));
}
-
- g_free (modified_style);
}
/* ex:set ts=8 noet: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]