[gedit] Revert "Use css stylesheet file instead of inline styles"
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Revert "Use css stylesheet file instead of inline styles"
- Date: Thu, 21 Apr 2011 11:30:26 +0000 (UTC)
commit c7fdb02da08d0a5229517b30aca1f6eb4240db25
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Apr 21 13:29:14 2011 +0200
Revert "Use css stylesheet file instead of inline styles"
This reverts commit c2fbbed25740d45426b9de17d9a2aeec6c350152.
data/Makefile.am | 6 +---
data/gedit.css | 19 -----------
gedit/gedit-close-button.c | 29 ++++++++++++++++-
gedit/gedit-close-button.h | 3 ++
gedit/gedit-multi-notebook.c | 68 ++++++++++++++++++++-------------------
gedit/gedit-multi-notebook.h | 3 ++
gedit/gedit-notebook.c | 70 ++++++++++++++++++++++++++++++++++++++++
gedit/gedit-notebook.h | 3 ++
gedit/gedit-status-combo-box.c | 34 +++++++++++++++++++-
gedit/gedit-status-combo-box.h | 2 +
gedit/gedit-window.c | 14 +-------
gedit/gedit.c | 34 -------------------
12 files changed, 180 insertions(+), 105 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index ea1a1c6..4d388a3 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -29,17 +29,13 @@ gsettings_SCHEMAS = org.gnome.gedit.gschema.xml
convertdir = $(datadir)/GConf/gsettings
convert_DATA = gedit.convert
-cssdir = $(datadir)/gedit/css
-css_DATA = gedit.css
-
EXTRA_DIST = \
$(desktop_in_files) \
$(service_in_files) \
$(man_MANS) \
gedit.pc.in \
org.gnome.gedit.gschema.xml.in.in \
- gedit.convert \
- gedit.css
+ gedit.convert
CLEANFILES = \
$(desktop_DATA) \
diff --git a/gedit/gedit-close-button.c b/gedit/gedit-close-button.c
index d0cdbce..6a9021a 100644
--- a/gedit/gedit-close-button.c
+++ b/gedit/gedit-close-button.c
@@ -22,16 +22,37 @@
#include "gedit-close-button.h"
-G_DEFINE_TYPE (GeditCloseButton, gedit_close_button, GTK_TYPE_BUTTON)
+struct _GeditCloseButtonClassPrivate
+{
+ GtkCssProvider *css;
+};
+
+G_DEFINE_TYPE_WITH_CODE (GeditCloseButton, gedit_close_button, GTK_TYPE_BUTTON,
+ g_type_add_class_private (g_define_type_id, sizeof (GeditCloseButtonClassPrivate)))
static void
gedit_close_button_class_init (GeditCloseButtonClass *klass)
{
+ static const gchar button_style[] =
+ "* {\n"
+ "-GtkButton-default-border : 0;\n"
+ "-GtkButton-default-outside-border : 0;\n"
+ "-GtkButton-inner-border: 0;\n"
+ "-GtkWidget-focus-line-width : 0;\n"
+ "-GtkWidget-focus-padding : 0;\n"
+ "padding: 0;\n"
+ "}";
+
+ klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClassPrivate);
+
+ klass->priv->css = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
}
static void
gedit_close_button_init (GeditCloseButton *button)
{
+ GtkStyleContext *context;
GtkWidget *image;
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
@@ -39,6 +60,12 @@ gedit_close_button_init (GeditCloseButton *button)
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (button), image);
+
+ /* make it small */
+ context = gtk_widget_get_style_context (GTK_WIDGET (button));
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (GEDIT_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
GtkWidget *
diff --git a/gedit/gedit-close-button.h b/gedit/gedit-close-button.h
index 3ac444f..791a730 100644
--- a/gedit/gedit-close-button.h
+++ b/gedit/gedit-close-button.h
@@ -36,6 +36,7 @@ G_BEGIN_DECLS
typedef struct _GeditCloseButton GeditCloseButton;
typedef struct _GeditCloseButtonClass GeditCloseButtonClass;
+typedef struct _GeditCloseButtonClassPrivate GeditCloseButtonClassPrivate;
struct _GeditCloseButton
{
@@ -45,6 +46,8 @@ struct _GeditCloseButton
struct _GeditCloseButtonClass
{
GtkButtonClass parent_class;
+
+ GeditCloseButtonClassPrivate *priv;
};
GType gedit_close_button_get_type (void) G_GNUC_CONST;
diff --git a/gedit/gedit-multi-notebook.c b/gedit/gedit-multi-notebook.c
index 83a4f46..9efddc5 100644
--- a/gedit/gedit-multi-notebook.c
+++ b/gedit/gedit-multi-notebook.c
@@ -36,6 +36,7 @@ struct _GeditMultiNotebookPrivate
GeditTab *active_tab;
guint removing_notebook : 1;
+ guint collapse : 1;
};
enum
@@ -449,12 +450,6 @@ add_notebook (GeditMultiNotebook *mnb,
mnb->priv->notebooks = g_list_append (mnb->priv->notebooks,
notebook);
-
- gtk_style_context_add_class (gtk_widget_get_style_context (notebook),
- "first");
-
- gtk_style_context_add_class (gtk_widget_get_style_context (notebook),
- "last");
}
else
{
@@ -463,6 +458,7 @@ add_notebook (GeditMultiNotebook *mnb,
GtkAllocation allocation;
GtkWidget *active_notebook = mnb->priv->active_notebook;
gint active_nb_pos;
+ gboolean collapse_new_notebook = FALSE;
paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_show (paned);
@@ -476,16 +472,6 @@ add_notebook (GeditMultiNotebook *mnb,
gtk_container_remove (GTK_CONTAINER (parent), active_notebook);
gtk_container_add (GTK_CONTAINER (parent), paned);
- /* check if we need to uncollapse the active notebook */
- if (active_notebook == g_list_last (mnb->priv->notebooks)->data)
- {
- gtk_style_context_remove_class (gtk_widget_get_style_context (active_notebook),
- "last");
-
- gtk_style_context_add_class (gtk_widget_get_style_context (notebook),
- "last");
- }
-
gtk_paned_pack1 (GTK_PANED (paned), active_notebook, TRUE, FALSE);
g_object_unref (active_notebook);
@@ -495,11 +481,26 @@ add_notebook (GeditMultiNotebook *mnb,
gtk_paned_set_position (GTK_PANED (paned),
allocation.width / 2);
+ /* check if we need to uncollapse the active notebook */
+ if (active_notebook == g_list_last (mnb->priv->notebooks)->data &&
+ mnb->priv->collapse)
+ {
+ collapse_new_notebook = TRUE;
+ gedit_notebook_collapse_border (GEDIT_NOTEBOOK (active_notebook),
+ FALSE);
+ }
+
active_nb_pos = g_list_index (mnb->priv->notebooks,
active_notebook);
mnb->priv->notebooks = g_list_insert (mnb->priv->notebooks,
notebook,
active_nb_pos + 1);
+
+ if (collapse_new_notebook)
+ {
+ gedit_notebook_collapse_border (GEDIT_NOTEBOOK (notebook),
+ TRUE);
+ }
}
gtk_widget_show (notebook);
@@ -531,25 +532,14 @@ remove_notebook (GeditMultiNotebook *mnb,
if (current->next != NULL)
{
new_notebook = GTK_WIDGET (current->next->data);
-
- if (current->prev == NULL)
- {
- gtk_style_context_add_class (gtk_widget_get_style_context (new_notebook),
- "first");
- }
}
else
{
new_notebook = GTK_WIDGET (mnb->priv->notebooks->data);
- gtk_style_context_add_class (gtk_widget_get_style_context (current->prev->data),
- "last");
- }
-
- if (current->prev == NULL)
- {
- gtk_style_context_remove_class (gtk_widget_get_style_context (notebook),
- "first");
+ /* we must check if we need to collapse the new last notebook */
+ gedit_notebook_collapse_border (GEDIT_NOTEBOOK (current->prev->data),
+ mnb->priv->collapse);
}
parent = gtk_widget_get_parent (notebook);
@@ -584,9 +574,6 @@ remove_notebook (GeditMultiNotebook *mnb,
g_object_unref (children->data);
g_list_free (children);
- gtk_style_context_remove_region (gtk_widget_get_style_context (notebook),
- "notebook");
-
disconnect_notebook_signals (mnb, notebook);
g_signal_emit (G_OBJECT (mnb), signals[NOTEBOOK_REMOVED], 0, notebook);
@@ -919,6 +906,21 @@ gedit_multi_notebook_next_notebook (GeditMultiNotebook *mnb)
}
void
+gedit_multi_notebook_collapse_notebook_border (GeditMultiNotebook *mnb,
+ gboolean collapse)
+{
+ GeditNotebook *notebook;
+
+ g_return_if_fail (GEDIT_IS_MULTI_NOTEBOOK (mnb));
+
+ mnb->priv->collapse = (collapse != FALSE);
+
+ notebook = GEDIT_NOTEBOOK (g_list_last (mnb->priv->notebooks)->data);
+
+ gedit_notebook_collapse_border (notebook, collapse);
+}
+
+void
gedit_multi_notebook_foreach_notebook (GeditMultiNotebook *mnb,
GtkCallback callback,
gpointer callback_data)
diff --git a/gedit/gedit-multi-notebook.h b/gedit/gedit-multi-notebook.h
index 1ee87b5..98ce8e4 100644
--- a/gedit/gedit-multi-notebook.h
+++ b/gedit/gedit-multi-notebook.h
@@ -123,6 +123,9 @@ void gedit_multi_notebook_remove_active_notebook (GeditMultiNotebook *mnb);
void gedit_multi_notebook_previous_notebook (GeditMultiNotebook *mnb);
void gedit_multi_notebook_next_notebook (GeditMultiNotebook *mnb);
+void gedit_multi_notebook_collapse_notebook_border (GeditMultiNotebook *mnb,
+ gboolean collapse);
+
void gedit_multi_notebook_foreach_notebook (GeditMultiNotebook *mnb,
GtkCallback callback,
gpointer callback_data);
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index 64117ea..c61fa63 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -62,6 +62,8 @@ struct _GeditNotebookPrivate
GeditNotebookShowTabsModeType show_tabs_mode;
+ GtkCssProvider *css;
+
guint close_buttons_sensitive : 1;
guint ignore_focused_page_update : 1;
};
@@ -167,6 +169,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);
}
@@ -677,4 +685,66 @@ gedit_notebook_get_close_buttons_sensitive (GeditNotebook *nb)
return nb->priv->close_buttons_sensitive;
}
+static void
+remove_right_padding (GeditNotebook *nb)
+{
+ GtkStyleContext *context;
+ GtkBorder padding;
+ gchar *modified_style;
+ GError *error = NULL;
+ const gchar style[] =
+ ".notebook {\n"
+ "padding: %d 0 %d %d;\n"
+ "}";
+
+ /* FIXME: find out a css like way to do this, right now padding-right/left
+ 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);
+
+ /* make it as small as possible */
+ if (nb->priv->css == NULL)
+ {
+ 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);
+ }
+
+ 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));
+ }
+}
+
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index 27a32be..4a1f981 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -120,6 +120,9 @@ void gedit_notebook_set_close_buttons_sensitive
gboolean gedit_notebook_get_close_buttons_sensitive
(GeditNotebook *nb);
+void gedit_notebook_collapse_border (GeditNotebook *nb,
+ gboolean collapse);
+
G_END_DECLS
#endif /* GEDIT_NOTEBOOK_H */
diff --git a/gedit/gedit-status-combo-box.c b/gedit/gedit-status-combo-box.c
index 239900a..3cbcea6 100644
--- a/gedit/gedit-status-combo-box.c
+++ b/gedit/gedit-status-combo-box.c
@@ -43,6 +43,11 @@ struct _GeditStatusComboBoxPrivate
GtkWidget *current_item;
};
+struct _GeditStatusComboBoxClassPrivate
+{
+ GtkCssProvider *css;
+};
+
/* Signals */
enum
{
@@ -60,7 +65,8 @@ enum
static guint signals[NUM_SIGNALS] = { 0 };
-G_DEFINE_TYPE (GeditStatusComboBox, gedit_status_combo_box, GTK_TYPE_EVENT_BOX)
+G_DEFINE_TYPE_WITH_CODE (GeditStatusComboBox, gedit_status_combo_box, GTK_TYPE_EVENT_BOX,
+ g_type_add_class_private (g_define_type_id, sizeof (GeditStatusComboBoxClassPrivate)))
static void
gedit_status_combo_box_finalize (GObject *object)
@@ -142,6 +148,15 @@ gedit_status_combo_box_class_init (GeditStatusComboBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ static const gchar style[] =
+ "* {\n"
+ "-GtkButton-default-border : 0;\n"
+ "-GtkButton-default-outside-border : 0;\n"
+ "-GtkButton-inner-border: 0;\n"
+ "-GtkWidget-focus-line-width : 0;\n"
+ "-GtkWidget-focus-padding : 0;\n"
+ "padding: 0;\n"
+ "}";
object_class->finalize = gedit_status_combo_box_finalize;
object_class->get_property = gedit_status_combo_box_get_property;
@@ -167,6 +182,11 @@ gedit_status_combo_box_class_init (GeditStatusComboBoxClass *klass)
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GeditStatusComboBoxPrivate));
+
+ klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_STATUS_COMBO_BOX, GeditStatusComboBoxClassPrivate);
+
+ klass->priv->css = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (klass->priv->css, style, -1, NULL);
}
static void
@@ -305,6 +325,8 @@ set_shadow_type (GeditStatusComboBox *combo)
static void
gedit_status_combo_box_init (GeditStatusComboBox *self)
{
+ GtkStyleContext *context;
+
self->priv = GEDIT_STATUS_COMBO_BOX_GET_PRIVATE (self);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE);
@@ -364,6 +386,16 @@ gedit_status_combo_box_init (GeditStatusComboBox *self)
"deactivate",
G_CALLBACK (menu_deactivate),
self);
+
+ /* make it as small as possible */
+ context = gtk_widget_get_style_context (GTK_WIDGET (self->priv->button));
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (GEDIT_STATUS_COMBO_BOX_GET_CLASS (self)->priv->css),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ context = gtk_widget_get_style_context (GTK_WIDGET (self->priv->frame));
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (GEDIT_STATUS_COMBO_BOX_GET_CLASS (self)->priv->css),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
/* public functions */
diff --git a/gedit/gedit-status-combo-box.h b/gedit/gedit-status-combo-box.h
index e20137b..c893627 100644
--- a/gedit/gedit-status-combo-box.h
+++ b/gedit/gedit-status-combo-box.h
@@ -50,6 +50,8 @@ struct _GeditStatusComboBox
struct _GeditStatusComboBoxClass
{
GtkEventBoxClass parent_class;
+
+ GeditStatusComboBoxClassPrivate *priv;
void (*changed) (GeditStatusComboBox *combo,
GtkMenuItem *item);
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 907c066..ac64595 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -382,18 +382,8 @@ gedit_window_window_state_event (GtkWidget *widget,
show = !(event->new_window_state &
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
- if (show)
- {
- gtk_style_context_remove_class (gtk_widget_get_style_context (widget),
- "fullscreen");
- }
- else
- {
- gtk_style_context_add_class (gtk_widget_get_style_context (widget),
- "fullscreen");
- }
-
- gtk_widget_reset_style (widget);
+ gedit_multi_notebook_collapse_notebook_border (window->priv->multi_notebook,
+ !show);
}
if (GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event)
diff --git a/gedit/gedit.c b/gedit/gedit.c
index 418bc4e..e4caec4 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -159,38 +159,6 @@ gedit_main_window (void)
}
static void
-load_css ()
-{
- /* Load css */
- GtkCssProvider *css = gtk_css_provider_new ();
- gchar *css_path;
- GError *error = NULL;
-
- css_path = g_build_filename (gedit_dirs_get_gedit_data_dir (),
- "css",
- "gedit.css",
- NULL);
-
- if (!gtk_css_provider_load_from_path (css, css_path, &error))
- {
- g_warning ("Failed to load stylesheet `%s': %s",
- css_path,
- error->message);
-
- g_error_free (error);
- }
- else
- {
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (css),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
-
- g_free (css_path);
- g_object_unref (css);
-}
-
-static void
gedit_main (gboolean service)
{
GeditPluginsEngine *engine;
@@ -217,8 +185,6 @@ gedit_main (gboolean service)
gedit_debug_message (DEBUG_APP, "Init session manager");
gedit_session_init ();
- load_css ();
-
if (!service && gedit_session_is_restored ())
{
restored = gedit_session_load ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]