From 9c9e564ec1fcc20682d52619e67f477b4154366f Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Wed, 28 Dec 2016 11:44:35 -0800 Subject: [PATCH] Add a few style classes This will allow themes a bit more control over the styling. Since you can no longer select objects by class name in gtk version > 3.20 there is no other easy way to theme these elements. Added classes for "xed-window", "xed-searchbar", "xed-statusbar", and "xed-panel" with additional classes of "side" and "bottom" for the panels --- xed/xed-panel.c | 11 +++++++++++ xed/xed-searchbar.c | 2 ++ xed/xed-statusbar.c | 2 ++ xed/xed-window.c | 12 ++++++------ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/xed/xed-panel.c b/xed/xed-panel.c index bcffb17..fab35d3 100644 --- a/xed/xed-panel.c +++ b/xed/xed-panel.c @@ -424,6 +424,17 @@ xed_panel_constructor (GType type, build_notebook_for_panel (panel); gtk_box_pack_start (GTK_BOX (panel->priv->main_box), panel->priv->notebook, TRUE, TRUE, 0); + gtk_style_context_add_class (gtk_widget_get_style_context (panel), "xed-panel"); + + if (panel->priv->orientation == GTK_ORIENTATION_VERTICAL) + { + gtk_style_context_add_class (gtk_widget_get_style_context (panel), "side"); + } + else + { + gtk_style_context_add_class (gtk_widget_get_style_context (panel), "bottom"); + } + return obj; } diff --git a/xed/xed-searchbar.c b/xed/xed-searchbar.c index 996b9a7..09de427 100755 --- a/xed/xed-searchbar.c +++ b/xed/xed-searchbar.c @@ -564,6 +564,8 @@ xed_searchbar_init (XedSearchbar *searchbar) NULL); g_free (file); + gtk_style_context_add_class (gtk_widget_get_style_context (searchbar), "xed-searchbar"); + searchbar->priv->search_entry = xed_history_entry_new ("history-search-for", TRUE); gtk_widget_set_hexpand (searchbar->priv->search_entry, TRUE); xed_history_entry_set_escape_func (XED_HISTORY_ENTRY (searchbar->priv->search_entry), diff --git a/xed/xed-statusbar.c b/xed/xed-statusbar.c index 05f2d40..ba104e5 100644 --- a/xed/xed-statusbar.c +++ b/xed/xed-statusbar.c @@ -179,6 +179,8 @@ xed_statusbar_init (XedStatusbar *statusbar) gtk_box_pack_start (GTK_BOX (statusbar), statusbar->priv->error_frame, FALSE, TRUE, 0); + + gtk_style_context_add_class (gtk_widget_get_style_context (statusbar), "xed-statusbar"); } /** diff --git a/xed/xed-window.c b/xed/xed-window.c index 8360e1c..138093f 100644 --- a/xed/xed-window.c +++ b/xed/xed-window.c @@ -3120,15 +3120,13 @@ create_side_panel (XedWindow *window) window->priv->side_panel = xed_panel_new (GTK_ORIENTATION_VERTICAL); - gtk_paned_pack1 (GTK_PANED(window->priv->hpaned), window->priv->side_panel, - FALSE, - FALSE); + gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->side_panel, FALSE, FALSE); - g_signal_connect_after(window->priv->side_panel, "show", G_CALLBACK (side_panel_visibility_changed), window); - g_signal_connect_after(window->priv->side_panel, "hide", G_CALLBACK (side_panel_visibility_changed), window); + g_signal_connect_after (window->priv->side_panel, "show", G_CALLBACK (side_panel_visibility_changed), window); + g_signal_connect_after (window->priv->side_panel, "hide", G_CALLBACK (side_panel_visibility_changed), window); documents_panel = xed_documents_panel_new (window); - xed_panel_add_item_with_stock_icon (XED_PANEL(window->priv->side_panel), documents_panel, _("Documents"), + xed_panel_add_item_with_stock_icon (XED_PANEL (window->priv->side_panel), documents_panel, _("Documents"), GTK_STOCK_FILE); } @@ -3366,6 +3364,8 @@ xed_window_init (XedWindow *window) window->priv->window_group = gtk_window_group_new (); gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window)); + gtk_style_context_add_class (gtk_widget_get_style_context (window), "xed-window"); + main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), main_box); gtk_widget_show (main_box);