Using gtk theme colors for mini-commander entry widget
- From: Norman Stevens <norman arcady u-net com>
- To: gnome list <gnome-list gnome org>
- Subject: Using gtk theme colors for mini-commander entry widget
- Date: Wed, 22 Dec 1999 03:04:22 +0000 (GMT)
Currently the mini-commander applet uses specific colors for the
text entry widget. It is not easy to set this up to use the
colors specified in the gtk theme since this involves looking
up colors in the gtkrc and entering them in the color picker
dialogs. Furthermore you would have to do this every time you
changed your gtk theme.
The attached patch added a new option to the preferences which
if used makes mini-commander use the gtk theme's color scheme.
Norman
diff -ur old/command_line.c src/command_line.c
--- old/command_line.c Sat Nov 6 01:18:07 1999
+++ src/command_line.c Wed Dec 22 02:25:42 1999
@@ -437,7 +437,10 @@
GTK_SIGNAL_FUNC(commandFocusOut_event),
NULL);
- command_entry_update_color();
+ if (!prop.useThemeColors)
+ {
+ command_entry_update_color();
+ }
command_entry_update_size();
}
diff -ur old/preferences.c src/preferences.c
--- old/preferences.c Thu Sep 9 22:39:39 1999
+++ src/preferences.c Wed Dec 22 02:31:30 1999
@@ -35,6 +35,9 @@
properties prop;
properties propTmp;
+static GtkWidget *colorPickerFg = NULL;
+static GtkWidget *colorPickerBg = NULL;
+
static void
checkBoxToggled_signal(GtkWidget *checkBoxWidget, int *data)
{
@@ -56,6 +59,15 @@
}
static void
+useThemeColorsChanged_signal(GtkWidget *useThemeColorsWidget, int *data)
+{
+ *data = GTK_TOGGLE_BUTTON(useThemeColorsWidget)->active;
+ /* toggle enabled state of color pickers */
+ gtk_widget_set_sensitive(colorPickerFg, !*data);
+ gtk_widget_set_sensitive(colorPickerBg, !*data);
+}
+
+static void
colorCmdFgChanged_signal(GtkWidget *colorPickerWidget, gpointer *data)
{
gushort r, g, b;
@@ -95,6 +107,7 @@
propTmp.autoCompleteHistory = -1;
propTmp.cmdLineY = -1;
propTmp.flatLayout = -1;
+ propTmp.useThemeColors = -1;
propTmp.cmdLineColorFgR = -1;
propTmp.cmdLineColorFgG = -1;
propTmp.cmdLineColorFgB = -1;
@@ -169,6 +182,10 @@
}
/* colors */
+ if(propTmp.useThemeColors != -1)
+ {
+ prop.useThemeColors = propTmp.useThemeColors;
+ }
if(propTmp.cmdLineColorFgR != -1)
{
prop.cmdLineColorFgR = propTmp.cmdLineColorFgR;
@@ -201,6 +218,7 @@
}
if(propTmp.showHandle != -1
+ || propTmp.useThemeColors != -1
|| propTmp.showFrame != -1
|| propTmp.cmdLineY != -1
|| propTmp.cmdLineColorFgR != -1
@@ -241,6 +259,7 @@
prop.cmdLineY = gnome_config_get_int("mini_commander/cmd_line_y=24");
/* colors */
+ prop.useThemeColors = gnome_config_get_int("mini_commander/use_theme_colors=1");
prop.cmdLineColorFgR = gnome_config_get_int("mini_commander/cmd_line_color_fg_r=54613");
prop.cmdLineColorFgG = gnome_config_get_int("mini_commander/cmd_line_color_fg_g=54613");
prop.cmdLineColorFgB = gnome_config_get_int("mini_commander/cmd_line_color_fg_b=54613");
@@ -381,6 +400,7 @@
gnome_config_set_int("mini_commander/cmd_line_y", prop.cmdLineY);
/* colors */
+ gnome_config_set_int("mini_commander/use_theme_colors",prop.useThemeColors);
gnome_config_set_int("mini_commander/cmd_line_color_fg_r", prop.cmdLineColorFgR);
gnome_config_set_int("mini_commander/cmd_line_color_fg_g", prop.cmdLineColorFgG);
gnome_config_set_int("mini_commander/cmd_line_color_fg_b", prop.cmdLineColorFgB);
@@ -441,14 +461,14 @@
{
static GnomeHelpMenuEntry helpEntry = { NULL, "properties" };
GtkWidget *propertiesBox;
- GtkWidget *vbox, *vbox1, *frame;
+ GtkWidget *vbox, *vbox1, *vbox2, *frame;
GtkWidget *hbox, *hbox1;
GtkWidget *table;
GtkWidget *checkTime, *checkDate, *checkHandle, *checkFrame, *checkAutoCompleteHistory;
GtkWidget *label;
GtkWidget *entry;
- GtkWidget *colorPicker;
GtkWidget *scrolledWindow;
+ GtkWidget *useThemeColors;
char textLabel[50], buffer[50];
int i, j;
@@ -666,11 +686,26 @@
frame = gtk_frame_new(_("Colors"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+ vbox2 = gtk_vbox_new(FALSE, GNOME_PAD_SMALL);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox2), GNOME_PAD_SMALL);
+ gtk_container_add(GTK_CONTAINER(frame), vbox2);
+
+ useThemeColors = gtk_check_button_new_with_label (_("Use theme colors"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useThemeColors),
+ prop.useThemeColors);
+ gtk_signal_connect(GTK_OBJECT(useThemeColors),"toggled",
+ GTK_SIGNAL_FUNC(useThemeColorsChanged_signal),
+ &propTmp.useThemeColors);
+ gtk_signal_connect_object(GTK_OBJECT(useThemeColors), "toggled",
+ GTK_SIGNAL_FUNC(gnome_property_box_changed),
+ GTK_OBJECT(propertiesBox));
+ gtk_box_pack_start(GTK_BOX(vbox2), useThemeColors, FALSE, TRUE, 0);
+
table = gtk_table_new(2, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), GNOME_PAD_SMALL);
gtk_table_set_col_spacings(GTK_TABLE(table), GNOME_PAD_SMALL);
gtk_container_set_border_width(GTK_CONTAINER(table), GNOME_PAD_SMALL);
- gtk_container_add(GTK_CONTAINER(frame), table);
+ gtk_box_pack_end(GTK_BOX(vbox2), table, FALSE, FALSE, 0);
/* fg */
label = gtk_label_new(_("Command line foreground:"));
@@ -682,17 +717,18 @@
GTK_FILL, 0,
0, 0);
- colorPicker = gnome_color_picker_new();
- gnome_color_picker_set_i16(GNOME_COLOR_PICKER(colorPicker),
+ colorPickerFg = gnome_color_picker_new();
+ gnome_color_picker_set_i16(GNOME_COLOR_PICKER(colorPickerFg),
prop.cmdLineColorFgR,
prop.cmdLineColorFgG,
prop.cmdLineColorFgB,
0);
- gtk_signal_connect(GTK_OBJECT(colorPicker),
+ gtk_widget_set_sensitive(colorPickerFg, !prop.useThemeColors);
+ gtk_signal_connect(GTK_OBJECT(colorPickerFg),
"color_set",
GTK_SIGNAL_FUNC(colorCmdFgChanged_signal),
(gpointer *) NULL);
- gtk_signal_connect_object(GTK_OBJECT(colorPicker),
+ gtk_signal_connect_object(GTK_OBJECT(colorPickerFg),
"color_set",
GTK_SIGNAL_FUNC(gnome_property_box_changed),
GTK_OBJECT(propertiesBox));
@@ -700,7 +736,7 @@
gtk_box_pack_start(GTK_BOX(hbox), colorPicker, FALSE, TRUE, 0);
*/
gtk_table_attach(GTK_TABLE(table),
- colorPicker,
+ colorPickerFg,
1, 2,
0, 1,
0, 0,
@@ -716,28 +752,28 @@
1, 2,
GTK_FILL, 0,
0, 0);
- colorPicker = gnome_color_picker_new();
- gnome_color_picker_set_i16(GNOME_COLOR_PICKER(colorPicker),
+ colorPickerBg = gnome_color_picker_new();
+ gnome_color_picker_set_i16(GNOME_COLOR_PICKER(colorPickerBg),
prop.cmdLineColorBgR,
prop.cmdLineColorBgG,
prop.cmdLineColorBgB,
0);
- gtk_signal_connect(GTK_OBJECT(colorPicker),
+ gtk_widget_set_sensitive(colorPickerBg, !prop.useThemeColors);
+ gtk_signal_connect(GTK_OBJECT(colorPickerBg),
"color_set",
GTK_SIGNAL_FUNC(colorCmdBgChanged_signal),
(gpointer *) NULL);
- gtk_signal_connect_object(GTK_OBJECT(colorPicker),
+ gtk_signal_connect_object(GTK_OBJECT(colorPickerBg),
"color_set",
GTK_SIGNAL_FUNC(gnome_property_box_changed),
GTK_OBJECT(propertiesBox));
gtk_table_attach(GTK_TABLE(table),
- colorPicker,
+ colorPickerBg,
1, 2,
1, 2,
0, 0,
0, 0);
-
gnome_property_box_append_page(GNOME_PROPERTY_BOX(propertiesBox),
vbox,
diff -ur old/preferences.h src/preferences.h
--- old/preferences.h Thu Sep 9 22:39:40 1999
+++ src/preferences.h Wed Dec 22 01:09:16 1999
@@ -19,6 +19,7 @@
int reducedSizeY;
int cmdLineY;
int flatLayout;
+ int useThemeColors;
int cmdLineColorFgR;
int cmdLineColorFgG;
int cmdLineColorFgB;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]