[gcalctool] Add colours to buttons
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcalctool] Add colours to buttons
- Date: Wed, 31 Mar 2010 07:13:52 +0000 (UTC)
commit b1d8deb7978dfe65a415ef0b66fe859e1caaf10e
Author: Robert Ancell <robert ancell gmail com>
Date: Wed Mar 31 18:11:39 2010 +1100
Add colours to buttons
NEWS | 2 +
data/gcalctool.ui | 58 ++++++++++++++++++++--------------------
src/gtk.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 29 deletions(-)
---
diff --git a/NEWS b/NEWS
index b5df030..6d0654d 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,8 @@ Overview of changes in gcalctool 5.31.1
* Put tooltips on trigonometric buttons
* Rename "Clr" buton to "Clear"
+
+ * Add colours to buttons
Overview of changes in gcalctool 5.30.0
diff --git a/data/gcalctool.ui b/data/gcalctool.ui
index f9a9524..ca3a719 100644
--- a/data/gcalctool.ui
+++ b/data/gcalctool.ui
@@ -2250,17 +2250,17 @@
<property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="calc_result_button">
- <property name="label" translatable="yes" comments="Label on the solve button (clicking this solves the displayed calculation)">=</property>
+ <child>
+ <object class="GtkButton" id="calc_percentage_button">
+ <property name="label">%</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for the solve button">Calculate result [=]</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip on the percentage button">Percentage [%]</property>
<property name="border_width">3</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
- <signal name="clicked" handler="solve_cb"/>
+ <signal name="clicked" handler="button_cb"/>
</object>
<packing>
<property name="left_attach">2</property>
@@ -2355,16 +2355,16 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="calc_clear_button">
- <property name="label" translatable="yes" comments="Label on the clear display button">Clear</property>
+ <object class="GtkButton" id="calc_result_button">
+ <property name="label" translatable="yes" comments="Label on the solve button (clicking this solves the displayed calculation)">=</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltop for the clear display button">Clear display [Escape]</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for the solve button">Calculate result [=]</property>
<property name="border_width">3</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
- <signal name="clicked" handler="clear_cb"/>
+ <signal name="clicked" handler="solve_cb"/>
</object>
<packing>
<property name="left_attach">4</property>
@@ -2416,16 +2416,16 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="calc_percentage_button">
- <property name="label">%</property>
+ <object class="GtkButton" id="calc_clear_button">
+ <property name="label" translatable="yes" comments="Label on the clear display button">Clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip on the percentage button">Percentage [%]</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltop for the clear display button">Clear display [Escape]</property>
<property name="border_width">3</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
- <signal name="clicked" handler="button_cb"/>
+ <signal name="clicked" handler="clear_cb"/>
</object>
<packing>
<property name="left_attach">4</property>
@@ -2668,16 +2668,21 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="calc_modulus_divide_button">
- <property name="label">mod</property>
+ <object class="GtkButton" id="calc_factor_button">
+ <property name="label">fact</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for the modulus division button">Modulus divide</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for the factorize button">Factorize into prime numbers (Ctrl+F)</property>
<property name="border_width">3</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
- <signal name="clicked" handler="button_cb"/>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="calc_factor_button-atkobject">
+ <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the factorize button">Factorize</property>
+ </object>
+ </child>
+ <signal name="clicked" handler="factorize_cb"/>
</object>
<packing>
<property name="top_attach">3</property>
@@ -2975,22 +2980,17 @@
<property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="calc_factor_button">
- <property name="label">fact</property>
+ <child>
+ <object class="GtkButton" id="calc_modulus_divide_button">
+ <property name="label">mod</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for the factorize button">Factorize into prime numbers (Ctrl+F)</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for the modulus division button">Modulus divide</property>
<property name="border_width">3</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="calc_factor_button-atkobject">
- <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the factorize button">Factorize</property>
- </object>
- </child>
- <signal name="clicked" handler="factorize_cb"/>
+ <signal name="clicked" handler="button_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/src/gtk.c b/src/gtk.c
index efdf6e8..aa13844 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -1606,6 +1606,28 @@ preferences_dialog_delete_cb(GtkWidget *widget)
static void
+set_tint (GtkWidget *widget, gint red, gint green, gint blue, gint alpha)
+{
+ GtkStyle *style = gtk_widget_get_style(widget);
+ int j;
+
+ for (j = 0; j < 5; j++) {
+ GdkColor tint, color;
+
+ tint.red = red;
+ tint.green = green;
+ tint.blue = blue;
+
+ color.red = (style->bg[j].red * (10 - alpha) + tint.red * alpha) / 10;
+ color.green = (style->bg[j].green * (10 - alpha) + tint.green * alpha) / 10;
+ color.blue = (style->bg[j].blue * (10 - alpha) + tint.blue * alpha) / 10;
+ gdk_colormap_alloc_color(gdk_colormap_get_system(), &color, FALSE, TRUE);
+ gtk_widget_modify_bg(widget, j, &color);
+ }
+}
+
+
+static void
create_main_window()
{
int i;
@@ -1656,8 +1678,60 @@ create_main_window()
SNPRINTF(name, MAXLINE, "calc_%d_button", i);
set_string_data(X.ui, name, "calc_subscript_text", subscript_digits[i]);
set_string_data(X.ui, name, "calc_superscript_text", superscript_digits[i]);
+ set_tint(GET_WIDGET(name), 0, 0, 65535, 1);
}
+ set_tint(GET_WIDGET("calc_10_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_11_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_12_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_13_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_14_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_15_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_pi_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_eulers_number_button"), 0, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_numeric_point_button"), 0, 0, 65535, 2);
+ set_tint(GET_WIDGET("calc_percentage_button"), 0, 0, 65535, 2);
+ set_tint(GET_WIDGET("subscript_togglebutton"), 0, 0, 65535, 2);
+ set_tint(GET_WIDGET("superscript_togglebutton"), 0, 0, 65535, 2);
+ set_tint(GET_WIDGET("calc_exponential_button"), 0, 0, 65535, 2);
+
+ set_tint(GET_WIDGET("calc_result_button"), 0, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_factor_button"), 0, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_clear_button"), 0, 0, 0, 2);
+
+ set_tint(GET_WIDGET("calc_add_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_subtract_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_multiply_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_divide_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_modulus_divide_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_and_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_or_button"), 65535, 0, 0, 1);
+ set_tint(GET_WIDGET("calc_xor_button"), 65535, 0, 0, 1);
+
+ set_tint(GET_WIDGET("calc_cosine_button"), 65535, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_sine_button"), 65535, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_tangent_button"), 65535, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_hyperbolic_cosine_button"), 65535, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_hyperbolic_sine_button"), 65535, 65535, 0, 1);
+ set_tint(GET_WIDGET("calc_hyperbolic_tangent_button"), 65535, 65535, 0, 1);
+
+ set_tint(GET_WIDGET("calc_start_group_button"), 65535, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_end_group_button"), 65535, 65535, 65535, 1);
+
+ set_tint(GET_WIDGET("calc_store_button"), 65535, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_recall_button"), 65535, 0, 65535, 1);
+ set_tint(GET_WIDGET("calc_ans_button"), 65535, 0, 65535, 1);
+
+ set_tint(GET_WIDGET("calc_integer_portion_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_fractional_portion_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_x_pow_y_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_factorial_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_root_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_abs_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_inverse_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_logarithm_button"), 0, 65535, 65535, 1);
+ set_tint(GET_WIDGET("calc_natural_logarithm_button"), 0, 65535, 65535, 1);
+
/* Set base button data */
set_int_data(X.ui, "calc_base_2_button", "base", 2);
set_int_data(X.ui, "calc_base_8_button", "base", 8);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]