G'day all. I've written up some code (patch attached) to have gnome-mud support transparancy, background shading, and background images through the vte widget. I've never contributed to a GNOME project before, and I'm rather keen to get this posted, so it might be a little rough-and ready. The patch should be applied in the /src directory.
Index: prefs.c =================================================================== RCS file: /cvs/gnome/gnome-mud/src/prefs.c,v retrieving revision 1.61 diff -u -r1.61 prefs.c --- prefs.c 17 Dec 2003 14:26:00 -0000 1.61 +++ prefs.c 14 Jun 2004 21:33:05 -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,19 @@ 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); + + //if (prefs.BackgroundType == "color") { + UPDATE_COLOR("background_color", Background); + //} + + + } #ifndef WITHOUT_MAPPER @@ -375,6 +404,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 +431,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 +607,50 @@ } } +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 call? + return; + gint i; + gchar *s = gtk_button_get_label(GTK_BUTTON(widget)); + + if (strcmp(s, "Color: ") == 0) { + // gconf_client_set_string(gconf_client, "/apps/gnome-mud/ui/background_image", "", NULL); + 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_bool(gconf_client, "/apps/gnome-mud/ui/background_transparent", FALSE, 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,55 @@ 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_file_entry_new (NULL, "Background picture"); + 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); + + + //g_print(prefs.BackgroundType); + 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_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 +844,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; } Index: init.c =================================================================== RCS file: /cvs/gnome/gnome-mud/src/init.c,v retrieving revision 1.102 diff -u -r1.102 init.c --- init.c 22 Feb 2004 00:17:26 -0000 1.102 +++ init.c 14 Jun 2004 21:33:08 -0000 @@ -816,7 +816,15 @@ 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.h =================================================================== RCS file: /cvs/gnome/gnome-mud/src/gnome-mud.h,v retrieving revision 1.37 diff -u -r1.37 gnome-mud.h --- gnome-mud.h 26 Jan 2004 13:12:20 -0000 1.37 +++ gnome-mud.h 14 Jun 2004 21:33:10 -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 {
Attachment:
signature.asc
Description: This is a digitally signed message part