Hello again, I've just tried that last patch I posted on a different computer than my development one, and found that it didn't work. Dag nabbit. I've got it working again though (added some changes to gnome-mud.schemas.in), and made a few revisions to the original patch, taking out renduntant comments and bad formatting. This one should be applied while outside the gnome-mud directory, "patch -p1 < gnome-mud-transparency.2.patch". Please excuse my brains for the first useless patch. (And probably a second, knowing my luck. :-/) -- Daniel Patton <seven-nation army com>
Index: gnome-mud/gnome-mud.schemas.in =================================================================== RCS file: /cvs/gnome/gnome-mud/gnome-mud.schemas.in,v retrieving revision 1.20 diff -u -r1.20 gnome-mud.schemas.in --- a/gnome-mud/gnome-mud.schemas.in 18 Dec 2003 12:12:46 -0000 1.20 +++ b/gnome-mud/gnome-mud.schemas.in 29 Jun 2004 04:22:06 -0000 @@ -49,6 +49,67 @@ </schema> <schema> + <key>/schemas/apps/gnome-mud/ui/background_type</key> + <applyto>/apps/gnome-mud/ui/background_type</applyto> + <owner>gnome-mud</owner> + <type>string</type> + <default>color</default> + <locale name="C"> + <short>Background type</short> + <long> + Specifies the background type to use. One of: + "color", "image", or "transparent". + </long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/gnome-mud/ui/background_image</key> + <applyto>/apps/gnome-mud/ui/background_image</applyto> + <owner>gnome-mud</owner> + <type>string</type> + <default></default> + <locale name="C"> + <short>Background image</short> + <long> + Directory & filename of the background image + to display, if background_type is set to "image". + </long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/gnome-mud/ui/background_transparent</key> + <applyto>/apps/gnome-mud/ui/background_transparent</applyto> + <owner>gnome-mud</owner> + <type>boolean</type> + <default>FALSE</default> + <locale name="C"> + <short>Background transparency</short> + <long> + Toggle to use background transparency. + Can be one of "TRUE" or "FALSE". + </long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/gnome-mud/ui/background_shade</key> + <applyto>/apps/gnome-mud/ui/background_shade</applyto> + <owner>gnome-mud</owner> + <type>double</type> + <default>0</default> + <locale name="C"> + <short>Background shade</short> + <long> + GNOME-Mud can shade the background when using either + transparency or a background image. It must be specified + as a float, e.g. "0.172". + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/gnome-mud/ui/palette</key> <applyto>/apps/gnome-mud/ui/palette</applyto> <owner>gnome-mud</owner> Index: gnome-mud/src/gnome-mud.h =================================================================== RCS file: /cvs/gnome/gnome-mud/src/gnome-mud.h,v retrieving revision 1.37 diff -u -r1.37 gnome-mud.h --- a/gnome-mud/src/gnome-mud.h 26 Jan 2004 13:12:20 -0000 1.37 +++ b/gnome-mud/src/gnome-mud.h 29 Jun 2004 04:22:08 -0000 @@ -123,6 +123,11 @@ GdkColor Background; GdkColor Colors[C_MAX]; + + gchar *BackgroundType; // Color, Picture, Transparent + gchar *BackgroundImage; + gdouble BackgroundShade; + gboolean BackgroundTransparent; }; struct wizard_data2 { Index: gnome-mud/src/init.c =================================================================== RCS file: /cvs/gnome/gnome-mud/src/init.c,v retrieving revision 1.102 diff -u -r1.102 init.c --- a/gnome-mud/src/init.c 22 Feb 2004 00:17:26 -0000 1.102 +++ b/gnome-mud/src/init.c 29 Jun 2004 04:22:15 -0000 @@ -811,12 +811,20 @@ gtk_signal_connect(GTK_OBJECT(text_entry), "key_press_event", GTK_SIGNAL_FUNC (text_entry_key_press_cb), NULL); gtk_signal_connect(GTK_OBJECT(text_entry), "activate", GTK_SIGNAL_FUNC (text_entry_activate), NULL); gtk_widget_grab_focus (text_entry); - + gtk_widget_show_all (window); tray_create(); - + vte_terminal_set_font_from_string(VTE_TERMINAL(main_connection->window), prefs.FontName); - + + if (strcmp(prefs.BackgroundType, "transparent") == 0) { + vte_terminal_set_background_transparent(VTE_TERMINAL(main_connection->window), prefs.BackgroundTransparent); + } else if(strcmp(prefs.BackgroundType, "image") == 0) { + vte_terminal_set_background_image_file(VTE_TERMINAL(main_connection->window), prefs.BackgroundImage); + } + + vte_terminal_set_background_saturation(VTE_TERMINAL(main_connection->window), prefs.BackgroundShade); + g_snprintf(buf, 1023, _("GNOME-Mud version %s (compiled %s, %s)\n"), VERSION, __TIME__, __DATE__); terminal_feed(main_connection->window, buf); terminal_feed(main_connection->window, _("Distributed under the terms of the GNU General Public License.\n")); Index: gnome-mud/src/prefs.c =================================================================== RCS file: /cvs/gnome/gnome-mud/src/prefs.c,v retrieving revision 1.61 diff -u -r1.61 prefs.c --- a/gnome-mud/src/prefs.c 17 Dec 2003 14:26:00 -0000 1.61 +++ b/gnome-mud/src/prefs.c 29 Jun 2004 04:22:18 -0000 @@ -206,7 +206,6 @@ } \ } \ } - #define UPDATE_INT(Entry, Variable, Loop, LoopFunction, Callback) \ } \ else if (strcmp(key, Entry) == 0) \ @@ -224,6 +223,24 @@ } \ } +#define UPDATE_DOUBLE(Entry, Variable, Loop, LoopFunction, Callback) \ + } \ + else if (strcmp(key, Entry) == 0) \ + { \ + prefs.Variable = gconf_value_get_float(gconf_entry_get_value(entry)); \ + \ + if (Loop) \ + { \ + for (i = 0; i < MAX_CONNECTIONS; i++) \ + { \ + if (connections[i] != NULL) \ + { \ + vte_terminal_##LoopFunction (VTE_TERMINAL(connections[i]->window), prefs.Variable); \ + } \ + } \ + } + + #define UPDATE_COLOR(Entry, Variable) \ } \ else if (strcmp(key, Entry) == 0) \ @@ -264,9 +281,9 @@ \ g_free(colors); - if (0) - { - ; +if (0) + { + UPDATE_STRING("font", FontName, TRUE, set_font_from_string, NULL ); UPDATE_STRING("commdev", CommDev, FALSE, NULL, NULL ); UPDATE_BOOLEAN("echo", EchoText, FALSE, NULL, NULL ); @@ -274,8 +291,7 @@ UPDATE_BOOLEAN("system_keys", DisableKeys, FALSE, NULL, NULL ); UPDATE_STRING("terminal_type", TerminalType, TRUE, set_emulation, NULL ); UPDATE_STRING("mudlist_file", MudListFile, FALSE, NULL, NULL ); - UPDATE_COLOR("foreground_color", Foreground ); - UPDATE_COLOR("background_color", Background ); + UPDATE_COLOR("foreground_color", Foreground ); UPDATE_BOOLEAN("scroll_on_output", ScrollOnOutput, TRUE, set_scroll_on_output, NULL ); UPDATE_INT("scrollback_lines", Scrollback, TRUE, set_scrollback_lines, NULL ); UPDATE_STRING("tab_location", TabLocation, FALSE, NULL, tab_location); @@ -283,6 +299,12 @@ UPDATE_STRING("last_log_dir", LastLogDir, FALSE, NULL, NULL ); UPDATE_INT("history_count", History, FALSE, NULL, NULL ); UPDATE_INT("flush_interval", FlushInterval, FALSE, NULL, NULL ); + UPDATE_STRING("background_type", BackgroundType, TRUE, NULL, NULL); + UPDATE_STRING("background_image", BackgroundImage, TRUE, set_background_image_file, NULL); + UPDATE_BOOLEAN("background_transparent", BackgroundTransparent, TRUE, set_background_transparent, NULL); + UPDATE_DOUBLE("background_shade", BackgroundShade, TRUE, set_background_saturation, NULL); + UPDATE_COLOR("background_color", Background); + } #ifndef WITHOUT_MAPPER @@ -375,6 +397,9 @@ #define GCONF_GET_INT(entry, subdir, variable) \ prefs.variable = gconf_client_get_int(gconf_client, "/apps/gnome-mud/" #subdir "/" #entry, NULL); + +#define GCONF_GET_DOUBLE(entry, subdir, variable) \ + prefs.variable = gconf_client_get_float(gconf_client, "/apps/gnome-mud/" #subdir "/" #entry, NULL); #define GCONF_GET_COLOR(entry, subdir, variable) \ p = gconf_client_get_string(gconf_client, "/apps/gnome-mud/" #subdir "/" #entry, NULL);\ @@ -399,7 +424,12 @@ GCONF_GET_BOOLEAN(scroll_on_output, functionality, ScrollOnOutput); GCONF_GET_INT(history_count, functionality, History); GCONF_GET_INT(flush_interval, functionality, FlushInterval); - + + GCONF_GET_STRING(background_type, ui, BackgroundType); + GCONF_GET_STRING(background_image, ui, BackgroundImage); + GCONF_GET_BOOLEAN(background_transparent, ui, BackgroundTransparent); + GCONF_GET_DOUBLE(background_shade, ui, BackgroundShade); + /* palette */ p = gconf_client_get_string(gconf_client, "/apps/gnome-mud/ui/palette", NULL); @@ -570,6 +600,57 @@ } } +static void prefs_select_bg_image_cb(GtkWidget *widget, gpointer data) +{ + gchar *s = gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(widget), TRUE); + gchar *bgt = prefs.BackgroundType; + + if (strcmp(bgt, "image") != 0) + return; + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_image", s, NULL); +} + +static void prefs_select_bg_shade_cb(GtkWidget *widget, gpointer data) +{ + gdouble s = gtk_range_get_value(GTK_RANGE(widget)); + gconf_client_set_float(gconf_client, "/apps/gnome-mud/ui/background_shade", s, NULL); +} + +static void prefs_select_bg_type_cb(GtkWidget *widget, gpointer data) +{ + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) // Workaround to prevent this hitting twice, maybe there's a better signal? + return; + gint i; + gchar *s = gtk_button_get_label(GTK_BUTTON(widget)); + + if (strcmp(s, "Color: ") == 0) + { + for (i = 0; i < MAX_CONNECTIONS; i++) + { + if (connections[i] != NULL) { + vte_terminal_set_background_transparent(VTE_TERMINAL(connections[i]->window), FALSE); + vte_terminal_set_background_image_file(VTE_TERMINAL(connections[i]->window), NULL); + } + + } + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_type", "color", NULL); + + } else if (strcmp(s, "Picture: ") == 0) + { + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_type", "image", NULL); + gconf_client_set_bool(gconf_client, "/apps/gnome-mud/ui/background_transparent", FALSE, NULL); + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_image", "", NULL); + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_image", prefs.BackgroundImage, NULL); + + } else if (strcmp(s, "Transparent") == 0) + { + gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_type", "transparent", NULL); + gconf_client_set_bool(gconf_client, "/apps/gnome-mud/ui/background_transparent", TRUE, NULL); + + } + +} + static void prefs_select_palette_cb(GnomeColorPicker *colorpicker, guint r, guint g, guint b, guint alpha, gpointer data) { gint i = GPOINTER_TO_INT(data); @@ -616,22 +697,32 @@ #endif GtkWidget *prefs_color_frame (GtkWidget *prefs_window) -{ +{ GtkWidget *table_colorfont; GtkWidget *label_palette; GtkWidget *label_background; GtkWidget *label_foreground; + GtkWidget *label_background_tint; + GtkWidget *radio_background_color; + GtkWidget *radio_background_picture; + GtkWidget *radio_background_transparent; GtkWidget *picker_foreground; GtkWidget *picker_background; GtkWidget *picker_font; + GtkWidget *table1; GtkWidget *table2; GtkWidget *label_font; - + GtkWidget *hbox1; + GtkWidget *label_none; + GtkWidget *slider_background_tint; + GtkWidget *filesel_background; + GtkWidget *label_full; + GtkTooltips *tooltip = gtk_tooltips_new(); gint i, j, k; - table_colorfont = gtk_table_new (5, 2, FALSE); + table_colorfont = gtk_table_new (6, 2, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table_colorfont), 8); gtk_table_set_row_spacings (GTK_TABLE (table_colorfont), 4); @@ -652,11 +743,11 @@ label_palette = gtk_label_new (_("Color palette:")); gtk_widget_show (label_palette); - gtk_table_attach (GTK_TABLE (table_colorfont), label_palette, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); + gtk_table_attach (GTK_TABLE (table_colorfont), label_palette, 0, 1, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_palette), 1, 0.5); gtk_misc_set_padding (GTK_MISC (label_palette), 8, 0); - label_background = gtk_label_new (_("Background color:")); + label_background = gtk_label_new (_("Background:")); gtk_widget_show (label_background); gtk_table_attach (GTK_TABLE (table_colorfont), label_background, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_background), 1, 0.5); @@ -677,19 +768,51 @@ gtk_table_attach (GTK_TABLE (table_colorfont), picker_foreground, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gnome_color_picker_set_i16(GNOME_COLOR_PICKER(picker_foreground), prefs.Foreground.red, prefs.Foreground.green, prefs.Foreground.blue, 0); + table1 = gtk_table_new(2, 2, FALSE); + gtk_widget_show (table1); + gtk_table_attach (GTK_TABLE (table_colorfont), table1, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); + radio_background_color = gtk_radio_button_new_with_label(NULL, "Color: "); + gtk_table_attach(GTK_TABLE(table1), radio_background_color, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); picker_background = gnome_color_picker_new (); - gtk_tooltips_set_tip(tooltip, picker_background, - _("Default background color used when the connection " - "doesn't request the use of a specific color."), - NULL); - gtk_widget_show (picker_background); - gtk_table_attach (GTK_TABLE (table_colorfont), picker_background, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); + gtk_table_attach(GTK_TABLE(table1), picker_background, 2, 3, 1, 2, (GTK_FILL | GTK_EXPAND), 0, 0, 0); gnome_color_picker_set_i16(GNOME_COLOR_PICKER(picker_background), prefs.Background.red, prefs.Background.green, prefs.Background.blue, 0); - - table2 = gtk_table_new (2, 8, FALSE); - gtk_widget_show (table2); - gtk_table_attach (GTK_TABLE (table_colorfont), table2, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); + radio_background_picture = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_background_color)), "Picture: "); + gtk_table_attach(GTK_TABLE(table1), radio_background_picture, 1, 2, 2, 3, (GTK_FILL | GTK_EXPAND), 0, 0, 0); + filesel_background = gnome_pixmap_entry_new("image", "Background Image", FALSE); + if (prefs.BackgroundImage != "") gnome_file_entry_set_filename(GNOME_FILE_ENTRY(filesel_background), prefs.BackgroundImage); + + gtk_table_attach(GTK_TABLE(table1), filesel_background, 2, 3, 2, 3, (GTK_FILL|GTK_EXPAND), 0, 0, 0); + radio_background_transparent = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_background_color)), "Transparent"); + gtk_table_attach(GTK_TABLE(table1), radio_background_transparent, 1, 3, 3, 4, (GTK_FILL | GTK_EXPAND), 0, 0, 0); + + if (strcmp(prefs.BackgroundType, "image") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_background_picture), TRUE); + } else if (strcmp(prefs.BackgroundType, "transparent") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_background_transparent), TRUE); + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_background_color), TRUE); + } + + label_background_tint = gtk_label_new("Background shade:"); + gtk_table_attach(GTK_TABLE(table_colorfont), label_background_tint, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL), 0, 0, 0); + hbox1 = gtk_hbox_new (FALSE, 0); + gtk_table_attach(GTK_TABLE(table_colorfont), hbox1, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL), 0, 0, 0); + label_none = gtk_label_new("None"); + gtk_label_set_markup(GTK_LABEL(label_none), "<i>None</i>"); + gtk_box_pack_start(GTK_BOX(hbox1), label_none, FALSE, FALSE, 0); + slider_background_tint = gtk_hscale_new_with_range(0.0, 1.0, 0.1); + gtk_range_set_inverted(GTK_RANGE(slider_background_tint), TRUE); + gtk_range_set_value(GTK_RANGE(slider_background_tint), prefs.BackgroundShade); + gtk_scale_set_draw_value(GTK_SCALE(slider_background_tint), FALSE); + gtk_box_pack_start(GTK_BOX(hbox1), slider_background_tint, TRUE, TRUE, 0); + label_full = gtk_label_new("Full"); + gtk_label_set_markup(GTK_LABEL(label_full), "<i>Full</i>"); + gtk_box_pack_start(GTK_BOX(hbox1), label_full, FALSE, FALSE, 0); + table2 = gtk_table_new (2, 8, FALSE); + gtk_widget_show (table2); + gtk_table_attach (GTK_TABLE (table_colorfont), table2, 1, 2, 5, 6, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); + for (i = 0, j = 0, k = 0; i < C_MAX; i++) { GtkWidget *picker = gnome_color_picker_new(); @@ -717,7 +840,13 @@ gtk_signal_connect(GTK_OBJECT(picker_font), "font-set", GTK_SIGNAL_FUNC(prefs_select_font_cb), (gpointer) prefs_window); gtk_signal_connect(GTK_OBJECT(picker_foreground), "color-set", GTK_SIGNAL_FUNC(prefs_select_fg_color_cb), NULL); gtk_signal_connect(GTK_OBJECT(picker_background), "color-set", GTK_SIGNAL_FUNC(prefs_select_bg_color_cb), NULL); - + gtk_signal_connect(GTK_OBJECT(radio_background_color), "clicked", GTK_SIGNAL_FUNC(prefs_select_bg_type_cb), NULL); + gtk_signal_connect(GTK_OBJECT(radio_background_picture), "clicked", GTK_SIGNAL_FUNC(prefs_select_bg_type_cb), NULL); + gtk_signal_connect(GTK_OBJECT(radio_background_transparent), "toggled", GTK_SIGNAL_FUNC(prefs_select_bg_type_cb), NULL); + + gtk_signal_connect(GTK_OBJECT(filesel_background), "changed", GTK_SIGNAL_FUNC(prefs_select_bg_image_cb), NULL ); + gtk_signal_connect(GTK_OBJECT(slider_background_tint), "value-changed", GTK_SIGNAL_FUNC(prefs_select_bg_shade_cb), NULL); + return table_colorfont; }
Attachment:
signature.asc
Description: This is a digitally signed message part