Add css style context to various widgets so they can easily be changed

With the use of css, there is the ability to change the appearance of
the widgets to the users preference.
This commit is contained in:
Robert Fewell 2017-07-02 09:55:18 +01:00
parent 887a74e6d1
commit 443f92eed1
35 changed files with 126 additions and 3 deletions

View File

@ -1188,6 +1188,10 @@ gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data)
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "encodings_dialog"));
data->encodings_dialog = dialog;
// Set the style context for this assistant so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncAssistXmlEncoding");
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, data);
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->assistant));

View File

@ -1320,6 +1320,9 @@ gnc_account_window_create(AccountWindow *aw)
aw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_dialog"));
awo = G_OBJECT (aw->dialog);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(aw->dialog), "GncAccountDialog");
g_object_set_data (awo, "dialog_info", aw);
if (!aw->modal)

View File

@ -340,6 +340,9 @@ void gnc_ui_close_book (QofBook* book)
gnc_builder_add_from_file (builder, "dialog-book-close.glade", "close_book_dialog");
cbw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "close_book_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(cbw->dialog), "GncBookCloseDialog");
PINFO("Closed Book Window is %p, Dialog is %p", cbw, cbw->dialog);
/* close date */

View File

@ -266,6 +266,9 @@ gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
retval->ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "ss_ok_button"));
label = GTK_WIDGET(gtk_builder_get_object (builder, "item_label"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(retval->dialog), "GncSecurityDialog");
gnc_cbwe_require_list_item(GTK_COMBO_BOX(retval->namespace_combo));
gnc_cbwe_require_list_item(GTK_COMBO_BOX(retval->commodity_combo));
@ -966,8 +969,13 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace,
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, retval);
retval->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "security_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(retval->dialog), "GncSecurityDialog");
if (parent != NULL)
gtk_window_set_transient_for (GTK_WINDOW (retval->dialog), GTK_WINDOW (parent));
retval->edit_commodity = NULL;
help_button = GTK_WIDGET(gtk_builder_get_object (builder, "help_button"));

View File

@ -108,6 +108,9 @@ gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "duplicate_transaction_dialog"));
dt_dialog->dialog = dialog;
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncDupTransDialog");
/* parent */
if (parent != NULL)
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));

View File

@ -277,6 +277,9 @@ gnc_ui_file_access( int type )
faw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "file_access_dialog" ));
g_object_set_data_full( G_OBJECT(faw->dialog), "FileAccessWindow", faw, g_free );
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(faw->dialog), "GncFileAccessDialog");
faw->frame_file = GTK_WIDGET(gtk_builder_get_object (builder, "frame_file" ));
faw->frame_database = GTK_WIDGET(gtk_builder_get_object (builder, "frame_database" ));
faw->readonly_checkbutton = GTK_WIDGET(gtk_builder_get_object (builder, "readonly_checkbutton"));

View File

@ -54,6 +54,9 @@ gnc_ui_object_references_show( const gchar* explanation_text, GList* objlist )
gnc_builder_add_from_file (builder, "dialog-object-references.glade", "object_references_dialog" );
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "object_references_dialog" ));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncObjectRefDialog");
explanation = GTK_LABEL(gtk_builder_get_object (builder, "lbl_explanation" ));
gtk_label_set_text( explanation, explanation_text );

View File

@ -1728,6 +1728,9 @@ gnc_options_dialog_new_modal(gboolean modal, gchar *title)
retval->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "gnucash_options_dialog"));
retval->page_list = GTK_WIDGET(gtk_builder_get_object (builder, "page_list_scroll"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(retval->dialog), "GncOptionsDialog");
/* Page List */
{
GtkTreeView *view;

View File

@ -1267,6 +1267,9 @@ gnc_preferences_dialog_create(void)
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "gnucash_preferences_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncPreferenceDialog");
#ifndef REGISTER2_ENABLED
/* Hide preferences that are related to register2 */
box = GTK_WIDGET (gtk_builder_get_object (builder, "label14"));

View File

@ -192,6 +192,9 @@ gnc_dialog_query_view_new (GList *param_list, Query *q)
dqv->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "query_view_dialog"));
g_object_set_data (G_OBJECT (dqv->dialog), "dialog-info", dqv);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dqv->dialog), "GncQueryViewDialog");
/* grab the widgets */
dqv->label = GTK_WIDGET(gtk_builder_get_object (builder, "dialog_label"));
result_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "result_hbox"));

View File

@ -381,6 +381,9 @@ gnc_reset_warnings_dialog (GtkWindow *parent)
gnc_builder_add_from_file (builder, "dialog-reset-warnings.glade", "reset_warnings_dialog");
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "reset_warnings_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncResetWarningsDialog");
gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
rw_dialog->dialog = dialog;

View File

@ -233,6 +233,10 @@ new_tax_table_dialog (TaxTableWindow *ttw, gboolean new_table,
gnc_builder_add_from_file (builder, "dialog-tax-table.glade", "new_tax_table_dialog");
ntt->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "new_tax_table_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ntt->dialog), "GncTaxTableDialog");
ntt->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry"));
if (name)
gtk_entry_set_text (GTK_ENTRY (ntt->name_entry), name);
@ -712,6 +716,9 @@ gnc_ui_tax_table_window_new (QofBook *book)
ttw->names_view = GTK_WIDGET(gtk_builder_get_object (builder, "tax_tables_view"));
ttw->entries_view = GTK_WIDGET(gtk_builder_get_object (builder, "tax_table_entries"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ttw->dialog), "GncTaxTableDialog");
/* Create the tax tables view */
view = GTK_TREE_VIEW(ttw->names_view);
store = gtk_list_store_new (NUM_TAX_TABLE_COLS, G_TYPE_STRING,

View File

@ -336,6 +336,9 @@ gnc_totd_dialog (GtkWindow *parent, gboolean startup)
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "totd_dialog"));
gtk_window_set_transient_for(GTK_WINDOW (dialog), parent);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncTotdDialog");
totd_dialog->dialog = dialog;
ENTER("totd_dialog %p, dialog %p", totd_dialog, dialog);

View File

@ -1867,6 +1867,9 @@ gnc_xfer_dialog_create(GtkWidget *parent, XferDialog *xferData)
xferData->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "transfer_dialog"));
g_object_set_data_full (G_OBJECT (xferData->dialog), "builder", builder, g_object_unref);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(xferData->dialog), "GncTransferDialog");
/* parent */
if (parent != NULL)
gtk_window_set_transient_for (GTK_WINDOW (xferData->dialog), GTK_WINDOW (parent));

View File

@ -51,6 +51,9 @@ gnc_get_username_password (GtkWidget *parent,
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "username_password_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncUserPassDialog");
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));

View File

@ -35,6 +35,7 @@
#include "gnc-ui-util.h"
#include "qof.h"
#include "gnc-session.h"
#include "dialog-utils.h"
#define ACCT_DATA_TAG "gnc-account-sel_acct"
@ -154,6 +155,9 @@ gnc_account_sel_init (GNCAccountSel *gas)
g_object_set(gas, "spacing", 2, (gchar*)NULL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gas), "GncAccountSel");
gas->store = gtk_list_store_new(NUM_ACCT_COLS, G_TYPE_STRING, G_TYPE_POINTER);
widget = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(gas->store));
gas->combo = GTK_COMBO_BOX(widget);

View File

@ -42,6 +42,7 @@
#include "gnc-locale-utils.h"
#include "gnc-ui-util.h"
#include "qof.h"
#include "dialog-utils.h"
#ifdef G_OS_WIN32
# include <gdk/gdkwin32.h>
@ -139,6 +140,9 @@ gnc_amount_edit_init (GNCAmountEdit *gae)
gae->fraction = 0;
gae->evaluate_on_enter = FALSE;
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gae), "GncAmountEdit");
g_signal_connect (G_OBJECT (gae), "changed",
G_CALLBACK (gnc_amount_edit_changed), NULL);
}

View File

@ -34,6 +34,7 @@
#include "gnc-prefs.h"
#include "gnc-main-window.h"
#include "gnc-gui-query.h"
#include "dialog-utils.h"
#define GNC_PREF_AUTOSAVE_SHOW_EXPLANATION "autosave-show-explanation"
#define GNC_PREF_AUTOSAVE_INTERVAL "autosave-interval-minutes"
@ -96,6 +97,10 @@ static gboolean autosave_confirm(GtkWidget *toplevel)
GTK_BUTTONS_NONE,
"%s",
_("Save file automatically?"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncAutoSaveDialog");
gtk_message_dialog_format_secondary_text
(GTK_MESSAGE_DIALOG(dialog),
ngettext("Your data file needs to be saved to your hard disk to save your changes. "

View File

@ -215,6 +215,9 @@ gctt_init (GncCombott *combott)
gtk_orientable_set_orientation (GTK_ORIENTABLE(combott), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(combott), "GncCombott");
priv->active = 0;
priv->text_col = 0;
priv->tip_col = 1;

View File

@ -68,6 +68,7 @@
#include "gnc-gtk-utils.h"
#include "gnc-ui-util.h"
#include "gnc-engine.h"
#include "dialog-utils.h"
/** The debugging module used by this file. */
static QofLogModule log_module = GNC_MOD_GUI;
@ -226,6 +227,9 @@ gnc_currency_edit_class_init (GNCCurrencyEditClass *klass)
static void
gnc_currency_edit_init (GNCCurrencyEdit *gce)
{
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gce), "GncCurrencyEdit");
g_signal_connect (gce, "notify::mnemonic",
G_CALLBACK (gnc_currency_edit_mnemonic_changed), gce);
g_signal_connect (gce, "changed",

View File

@ -43,6 +43,7 @@
#include "gnc-date.h"
#include "gnc-date-delta.h"
#include "dialog-utils.h"
#define GDD_LABEL "gdd"
@ -161,6 +162,9 @@ gnc_date_delta_init (GNCDateDelta *gdd)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE(gdd), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gdd), "GncDateDelta");
gdd->value_spin = NULL;
gdd->units_combo = NULL;
gdd->polarity_combo = NULL;

View File

@ -671,6 +671,9 @@ gnc_date_edit_init (GNCDateEdit *gde)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE(gde), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gde), "GncDateEdit");
gde->disposed = FALSE;
gde->popup_in_progress = FALSE;
gde->lower_hour = 7;

View File

@ -160,6 +160,9 @@ gnc_date_format_init (GNCDateFormat *gdf)
gtk_orientable_set_orientation (GTK_ORIENTABLE(gdf), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gdf), "GncDateFormat");
/* Open up the Glade and set the signals */
builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "gnc-date-format.glade", "format-liststore");

View File

@ -31,6 +31,7 @@
#include <math.h>
#include <stdlib.h>
#include <gnc-gdate-utils.h>
#include "dialog-utils.h"
/**
* Marking ...
@ -261,13 +262,12 @@ _gdc_get_view_options(void)
static void
gnc_dense_cal_init(GncDenseCal *dcal)
{
GtkStyleContext *context;
gboolean colorAllocSuccess[MAX_COLORS];
gtk_orientable_set_orientation (GTK_ORIENTABLE(dcal), GTK_ORIENTATION_VERTICAL);
context = gtk_widget_get_style_context (GTK_WIDGET(dcal));
gtk_style_context_add_class (context,"GncDenseCal");
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dcal), "GncDenseCal");
{
GtkTreeModel *options;

View File

@ -38,6 +38,7 @@
#include "gnc-plugin-manager.h"
#include "gnc-ui.h"
#include "gnc-window.h"
#include "dialog-utils.h"
/* Static Globals *******************************************************/
@ -239,6 +240,9 @@ gnc_embedded_window_init (GncEmbeddedWindow *window,
gtk_orientable_set_orientation (GTK_ORIENTABLE(window), GTK_ORIENTATION_VERTICAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(window), "GncEmbededWindow");
gnc_embedded_window_setup_window (window);
gnc_gobject_tracking_remember(G_OBJECT(window),

View File

@ -170,6 +170,9 @@ gnc_file_dialog (const char * title,
response = gtk_dialog_run(GTK_DIALOG(file_box));
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(file_box), "GncFileDialog");
if (response == GTK_RESPONSE_ACCEPT)
{
/* look for constructs like postgres://foo */

View File

@ -203,6 +203,9 @@ gnc_frequency_init(GncFrequency *gf)
gtk_orientable_set_orientation (GTK_ORIENTABLE(gf), GTK_ORIENTATION_VERTICAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gf), "GncFrequency");
builder = gtk_builder_new();
gnc_builder_add_from_file (builder , "gnc-frequency.glade", "adjustment1");
gnc_builder_add_from_file (builder , "gnc-frequency.glade", "adjustment2");

View File

@ -37,6 +37,7 @@
#include <stdio.h>
#include "gnc-general-select.h"
#include "dialog-utils.h"
/* Signal codes */
enum
@ -144,6 +145,9 @@ gnc_general_select_init (GNCGeneralSelect *gsl)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE(gsl), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gsl), "GncGeneralSelect");
gsl->disposed = FALSE;
gsl->selected_item = NULL;
}

View File

@ -2545,6 +2545,9 @@ gnc_main_window_init (GncMainWindow *window,
priv->merged_actions_table =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(window), "GncMainWindow");
priv->event_handler_id =
qof_event_register_handler(gnc_main_window_event_handler, window);

View File

@ -38,6 +38,7 @@
#include "gnc-period-select.h"
#include "gnc-prefs.h"
#include <gnc-gdate-utils.h>
#include "dialog-utils.h"
enum
{
@ -615,6 +616,9 @@ gnc_period_select_init (GncPeriodSelect *period)
gtk_orientable_set_orientation (GTK_ORIENTABLE(period), GTK_ORIENTATION_HORIZONTAL);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(period), "GncPeriodSelect");
priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
priv->start = TRUE;
}

View File

@ -215,6 +215,9 @@ gnc_query_view_init (GNCQueryView *qview)
{
GNCQueryViewPriv *priv;
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(qview), "GncQueryView");
qview->query = NULL;
qview->num_columns = 0;

View File

@ -189,6 +189,9 @@ gnc_recurrence_init( GncRecurrence *gr )
recurrenceSet(&gr->recurrence, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gr), "GncRecurrence");
/* Open up the builder file */
builder = gtk_builder_new();
gnc_builder_add_from_file (builder, "gnc-recurrence.glade", "GCB_PeriodType_liststore");

View File

@ -29,6 +29,7 @@
#include "gnc-splash.h"
#include "core-utils/gnc-version.h"
#include "gnc-prefs.h"
#include "dialog-utils.h"
#define MARKUP_STRING "<span size='small'>%s</span>"
#define GNC_PREF_SHOW_SPLASH "show-splash-screen"
@ -68,6 +69,9 @@ gnc_show_splash_screen (void)
gtk_window_set_decorated(GTK_WINDOW (splash), FALSE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (splash), TRUE);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(splash), "GncSplash");
g_signal_connect (splash, "destroy",
G_CALLBACK (splash_destroy_cb), NULL);

View File

@ -250,6 +250,9 @@ gnc_tree_view_init (GncTreeView *view, GncTreeViewClass *klass)
/* Ask gtk to help the user keep track of rows. */
g_object_set(view, "rules-hint", TRUE, NULL);
// Set the style context for this page so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(view), "GncTreeView");
/* Handle column drag and drop */
gtk_tree_view_set_column_drag_function(GTK_TREE_VIEW(view),
gnc_tree_view_drop_ok_cb, NULL, NULL);

View File

@ -37,6 +37,7 @@
#include "gnc-locale-utils.h"
#include "gnc-ui-util.h"
#include "window-main-summarybar.h"
#include "dialog-utils.h"
typedef struct
{
@ -533,6 +534,9 @@ gnc_main_window_summary_new (void)
retval->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_set_homogeneous (GTK_BOX (retval->hbox), FALSE);
// Set the style context for this widget so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(retval->hbox), "GncSummaryBar");
retval->totals_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (retval->datamodel));
g_object_unref (retval->datamodel);