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:58:42 +01:00
parent aef9530996
commit fa9d752beb
21 changed files with 99 additions and 2 deletions

View File

@ -135,6 +135,9 @@ init_notebook_widgets (BillTermNB *notebook, gboolean read_only,
notebook->notebook = GTK_WIDGET(gtk_builder_get_object (builder, "term_notebook"));
parent = GTK_WIDGET(gtk_builder_get_object (builder, "terms_notebook_window"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(notebook->notebook), "GncBillTermsDialog");
/* load the "days" widgets */
notebook->days_due_days = read_widget (builder, "days:due_days", read_only);
notebook->days_disc_days = read_widget (builder, "days:discount_days", read_only);
@ -436,6 +439,10 @@ new_billterm_dialog (BillTermsWindow *btw, GncBillTerm *term,
nbt->dialog = GTK_WIDGET(gtk_builder_get_object (builder, dialog_name));
nbt->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry"));
nbt->desc_entry = GTK_WIDGET(gtk_builder_get_object (builder, dialog_desc));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(nbt->dialog), "GncBillTermsDialog");
if (name)
gtk_entry_set_text (GTK_ENTRY (nbt->name_entry), name);
@ -773,6 +780,9 @@ gnc_ui_billterms_window_new (QofBook *book)
btw->type_label = GTK_WIDGET(gtk_builder_get_object (builder, "type_label"));
btw->term_vbox = GTK_WIDGET(gtk_builder_get_object (builder, "term_vbox"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(btw->dialog), "GncBillTermsDialog");
/* Initialize the view */
view = GTK_TREE_VIEW(btw->terms_view);
store = gtk_list_store_new (NUM_BILL_TERM_COLS, G_TYPE_STRING, G_TYPE_POINTER);

View File

@ -66,6 +66,9 @@ gcoi_create_dialog(Split* split)
dco->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "choose_owner_dialog"));
g_assert(dco->dialog);
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dco->dialog), "GncChooseOwnerDialog");
/* Get the title widget and set the title */
widget = GTK_WIDGET(gtk_builder_get_object (builder, "title_label"));
if (1 == 1)

View File

@ -575,6 +575,9 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust)
gnc_builder_add_from_file (builder, "dialog-customer.glade", "customer_dialog");
cw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "customer_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(cw->dialog), "GncCustomerDialog");
g_object_set_data (G_OBJECT (cw->dialog), "dialog_info", cw);
/* Get entry points */

View File

@ -140,6 +140,9 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_close_dialog");
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_close_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog");
date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box"));
ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0);
@ -231,6 +234,9 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_account_dialog"));
ddc->memo_entry = GTK_WIDGET(gtk_builder_get_object (builder, "memo_entry"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog");
acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox"));
ddc->acct_combo = gnc_account_sel_new();
gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
@ -346,6 +352,9 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_account_dialog");
ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "date_account_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ddc->dialog), "GncDateCloseDialog");
acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox"));
ddc->acct_combo = gnc_account_sel_new();
if (*acct)

View File

@ -438,6 +438,9 @@ gnc_employee_new_window (QofBook *bookp,
gnc_builder_add_from_file (builder, "dialog-employee.glade", "employee_dialog");
ew->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "employee_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ew->dialog), "GncEmployeeDialog");
g_object_set_data (G_OBJECT (ew->dialog), "dialog_info", ew);
/* Get entry points */

View File

@ -252,6 +252,9 @@ iw_ask_unpost (InvoiceWindow *iw)
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "unpost_message_dialog"));
toggle = GTK_TOGGLE_BUTTON(gtk_builder_get_object (builder, "yes_tt_reset"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncInvoiceDialog");
gtk_window_set_transient_for (GTK_WINDOW(dialog),
GTK_WINDOW(iw_get_window(iw)));
@ -2262,6 +2265,9 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
gnc_builder_add_from_file (builder, "dialog-invoice.glade", "invoice_entry_vbox");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "invoice_entry_vbox"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncInvoiceDialog");
/* Autoconnect all the signals */
gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, iw);
@ -2537,6 +2543,9 @@ gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type, QofBook *bookp,
gnc_builder_add_from_file (builder, "dialog-invoice.glade", "new_invoice_dialog");
iw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new_invoice_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(iw->dialog), "GncInvoiceDialog");
g_object_set_data (G_OBJECT (iw->dialog), "dialog_info", iw);
/* Grab the widgets */

View File

@ -340,6 +340,9 @@ gnc_job_new_window (QofBook *bookp, GncOwner *owner, GncJob *job)
/* Find the dialog */
jw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "job_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(jw->dialog), "GncJobDialog");
/* Get entry points */
jw->id_entry = GTK_WIDGET(gtk_builder_get_object (builder, "id_entry"));
jw->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry"));

View File

@ -592,6 +592,9 @@ gnc_order_new_window (QofBook *bookp, OrderDialogType type,
gnc_builder_add_from_file (builder, "dialog-order.glade", "order_entry_dialog");
ow->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "order_entry_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ow->dialog), "GncOrderDialog");
/* Grab the widgets */
ow->id_entry = GTK_WIDGET(gtk_builder_get_object (builder, "id_entry"));
ow->ref_entry = GTK_WIDGET(gtk_builder_get_object (builder, "ref_entry"));
@ -704,6 +707,9 @@ gnc_order_window_new_order (QofBook *bookp, GncOwner *owner)
ow->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "new_order_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ow->dialog), "GncOrderDialog");
g_object_set_data (G_OBJECT (ow->dialog), "dialog_info", ow);
/* Grab the widgets */

View File

@ -930,6 +930,9 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
gnc_builder_add_from_file (builder, "dialog-payment.glade", "payment_dialog");
pw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "payment_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(pw->dialog), "GncPaymentDialog");
/* Grab the widgets and build the dialog */
pw->payment_warning = GTK_WIDGET (gtk_builder_get_object (builder, "payment_warning"));
pw->ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "okbutton"));

View File

@ -441,6 +441,9 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor)
gnc_builder_add_from_file (builder, "dialog-vendor.glade", "vendor_dialog");
vw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "vendor_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(vw->dialog), "GncVendorDialog");
/* Get entry points */
vw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder, "id_entry"));
vw->company_entry = GTK_WIDGET (gtk_builder_get_object (builder, "company_entry"));

View File

@ -41,6 +41,7 @@
#include "gnc-prefs.h"
#include "gnc-ui-util.h"
#include "gnc-window.h"
#include "dialog-utils.h"
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
@ -463,6 +464,9 @@ gnc_plugin_page_invoice_create_widget (GncPluginPage *plugin_page)
priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
// Set the style context for this page so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(priv->widget), "GncInvoicePage");
gtk_widget_show (priv->widget);
widget = gnc_invoice_create_page(priv->iw, page);

View File

@ -560,6 +560,7 @@ gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page)
GtkTreeViewColumn *col;
const gchar *state_section = NULL;
gchar* label = "";
const gchar *style_label = NULL;
ENTER("page %p", plugin_page);
page = GNC_PLUGIN_PAGE_OWNER_TREE (plugin_page);
@ -574,6 +575,9 @@ gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page)
gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
gtk_widget_show (priv->widget);
// Set the style context for this page so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(priv->widget), "GncBusinessPage");
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -598,33 +602,39 @@ gnc_plugin_page_owner_tree_create_widget (GncPluginPage *plugin_page)
g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
gnc_tree_view_configure_columns(GNC_TREE_VIEW(tree_view));
switch (priv->owner_type)
{
case GNC_OWNER_NONE :
case GNC_OWNER_UNDEFINED :
PWARN("missing owner_type");
label = _("Unknown");
style_label = "GncUnknown";
break;
case GNC_OWNER_CUSTOMER :
label = _("Customers");
state_section = "Customers Overview";
style_label = "GncCustomers";
break;
case GNC_OWNER_JOB :
label = _("Jobs");
state_section = "Jobs Overview";
style_label = "GncJobs";
break;
case GNC_OWNER_VENDOR :
label = _("Vendors");
state_section = "Vendors Overview";
style_label = "GncVendors";
break;
case GNC_OWNER_EMPLOYEE :
label = _("Employees");
state_section = "Employees Overview";
style_label = "GncEmployees";
break;
}
// Set a secondary style context for this page so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(priv->widget), style_label);
g_object_set(G_OBJECT(tree_view), "state-section", state_section,
"show-column-menu", TRUE,
NULL);

View File

@ -818,6 +818,9 @@ csv_export_assistant_create (CsvExportInfo *info)
window = GTK_WIDGET(gtk_builder_get_object (builder, "csv_export_assistant"));
info->window = window;
// Set the style context for this assistant so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(window), "GncAssistExport");
/* Load default settings */
load_settings (info);

View File

@ -581,6 +581,9 @@ csv_import_assistant_create (CsvImportInfo *info)
window = GTK_WIDGET(gtk_builder_get_object (builder, "csv_account_import_assistant"));
info->window = window;
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(window), "GncAssistAccountImport");
/* Load default settings */
load_settings (info);

View File

@ -392,6 +392,9 @@ CsvImpTransAssist::CsvImpTransAssist ()
gnc_builder_add_from_file (builder , "assistant-csv-trans-import.glade", "csv_transaction_assistant");
csv_imp_asst = GTK_ASSISTANT(gtk_builder_get_object (builder, "csv_transaction_assistant"));
// Set the style context for this assistant so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(csv_imp_asst), "GncAssistTransImport");
/* Enable buttons on all page. */
gtk_assistant_set_page_complete (csv_imp_asst,
GTK_WIDGET(gtk_builder_get_object (builder, "start_page")),

View File

@ -3434,6 +3434,9 @@ get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
GTK_TEXT_VIEW(wind->convert_log));
wind->summary_text = GTK_WIDGET(gtk_builder_get_object (builder, "summary_page"));
// Set the style context for this assistant so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(wind->window), "GncAssistQifImport");
wind->new_transaction_view =
GTK_WIDGET(gtk_builder_get_object (builder, "new_transaction_view"));
wind->old_transaction_view =

View File

@ -108,6 +108,9 @@ gnc_plugin_bi_import_showGUI(void)
gui->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview1"));
gui->entryFilename = GTK_WIDGET(gtk_builder_get_object (builder, "entryFilename"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gui->dialog), "GncBillImportDialog");
gui->book = gnc_get_current_book();
gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billing_id>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)$");

View File

@ -104,6 +104,9 @@ gnc_plugin_customer_import_showGUI(void)
gui->entryFilename = GTK_WIDGET(gtk_builder_get_object (builder, "entryFilename"));
gui->type = "CUSTOMER"; // Set a default type to import
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(gui->dialog), "GncCustomerImportDialog");
gui->regexp = g_string_new ( "^(?<id>[^;]+);(?<company>[^;]*);(?<name>[^;]+);(?<addr1>[^;]+);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipaddr4>[^;]*);?(?<shipphone>[^;]*);?(?<shipfax>[^;]*);?(?<shipemail>[^;]*)");
gui->book = gnc_get_current_book();

View File

@ -505,6 +505,9 @@ static CustomReportDialog *gnc_ui_custom_report_internal(GncMainWindow * window)
set_reports_view_and_model(crd);
crd->window = window;
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(crd->dialog), "GncCustomReportDialog");
gnc_restore_window_size (GNC_PREFS_GROUP_REPORT_SAVED_CONFIGS, GTK_WINDOW(crd->dialog));
/* connect the signals */

View File

@ -197,6 +197,9 @@ gnc_style_sheet_new (StyleSheetDialog * ssd)
template_combo = GTK_WIDGET(gtk_builder_get_object (builder, "template_combobox"));
name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(dlg), "GncStyleSheetDialog");
g_assert(ssd);
/* Erase the initial dummy entry. */
@ -410,6 +413,9 @@ gnc_style_sheet_select_dialog_create(void)
ss->toplevel = GTK_WIDGET(gtk_builder_get_object (builder, "select_style_sheet_dialog"));
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(ss->toplevel), "GncStyleSheetDialog");
ss->list_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "style_sheet_list_view"));
ss->list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);
gtk_tree_view_set_model(ss->list_view, GTK_TREE_MODEL(ss->list_store));

View File

@ -49,6 +49,7 @@
#include <gnc-glib-utils.h>
#include "gfec.h"
#include "dialog-custom-report.h"
#include "dialog-utils.h"
#include "gnc-component-manager.h"
#include "gnc-engine.h"
#include "gnc-gnome-utils.h"
@ -424,6 +425,9 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page )
priv->container = GTK_CONTAINER(gtk_frame_new(NULL));
gtk_frame_set_shadow_type(GTK_FRAME(priv->container), GTK_SHADOW_NONE);
// Set the style context for this page so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(priv->container), "GncReportPage");
gtk_container_add(GTK_CONTAINER(priv->container),
gnc_html_get_widget(priv->html));