|
Post by vovchik on Aug 27, 2014 20:21:36 GMT 1
Dear guys, Here is a striped, Mac-like background. I would like to do this inline - either with an svg or with the 150 bytes of raw png data as base64. Anybody know how? The svg code is also tiny: <svg width='4' height='4'> <rect width='4' height='1.5' fill='#f5f5f5'/> <rect y='1.5' width='4' height='2.5' fill='#eeeeee'/> </svg>
With kind regards, vovchik PS. I found this useful page: thegnomejournal.wordpress.com/2011/03/15/styling-gtk-with-css/Attachments:back_stripes.tar.gz (10.59 KB)
|
|
|
Post by bigbass on Aug 29, 2014 15:35:18 GMT 1
Hey vovchik
Seems like base 64 inline doesn't want to cooperate with gtk3 at least with my numerous tries as a background-image it still may be possible but no luck with the syntax yet so I will give it a rest until I at least find one working snippet in C and gtk3
this is as close as I got but its still a fail maybe you can get further
gtk_css_provider_load_from_data (provider, " GtkWindow {" "background-image: url('data:image/gif;base64,some_data_string_here') ;" "}", -1, NULL)
Joe
|
|
|
Post by vovchik on Aug 29, 2014 16:31:22 GMT 1
Dear Joe,
Thanks for the snippet. Looks a little like the one I cobbled together, but mine wasn't working. Will experiment:)
With kind regards, vovchik
|
|
|
Post by vovchik on Aug 30, 2014 15:25:08 GMT 1
Dear Joe,
Still trying to get css base64 encoded images to work but, in the meantime, have discovered this useful conversion function available in glib:
' *********************** ' COMPILER DIRECTIVES ' ***********************
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` OPTION PARSE FALSE
' *********************** ' END COMPILER DIRECTIVES ' ***********************
' *********************** ' INITIALIZATION ' ***********************
DECLARE stripes$, stripes64, decoded$ TYPE STRING DECLARE decode_len TYPE unsigned long stripes$ = CONCAT$("<svg width='4' height='4'>" \ "<rect width='4' height='1.5' fill='#f5f5f5'/>" \ "<rect y='1.5' width='4' height='2.5' fill='#eeeeee'/>" \ "</svg>")
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' MAIN ' ***********************
stripes64$ = (unsigned char*)g_base64_encode(stripes$, LEN(stripes$)) PRINT stripes$ PRINT "Unencoded length: ", LEN(stripes$) PRINT stripes64$ PRINT "Encoded length: ", LEN(stripes64$) decoded$ = (unsigned char*)g_base64_decode(stripes64$, &decode_len) PRINT decoded$ PRINT "Decoded length: ", LEN(decoded$)
' *********************** ' END MAIN ' ***********************
With kind regards, vovchik
|
|
|
Post by bigbass on Aug 30, 2014 16:06:45 GMT 1
Hey vovchik We are on the same frequency I was doing this while you posted some debugging tools are needed to see if the syntax will work echo "hello BaCon" | base64 echo aGVsbG8gQmFDb24K | base64 --decode lets try with an encoded image now then generate the original image we can test if the coding part is a valid image or not by doing this url(data:image/gif;base64, the number part of the encoded image hereecho the number part of the encoded image here | base64 --decode > image.gif echo R0lGODlhEAolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7 | base64 --decode > image.gif
will make this image How to encode any image from the command line very easy base64 image.gif
|
|
|
Post by vovchik on Aug 30, 2014 18:32:41 GMT 1
Dear Joe, Yes, exactly at the same time. Your method allows for easy external coversion, while the glib function is good for svgs already defined in the code as strings and for binary images defined as arrays of unsigned char. Our only stumbling block, at the moment, is the little css bit. With kind regards, vovchik
|
|
|
Post by vovchik on Sept 1, 2014 12:55:32 GMT 1
Dear all, Here is the gtk3 version of my 2012 Peg Solitaire game. I changed it from the gtk2 version in that I killed the rsvg lib stuff that previously returned pixbufs and replaced it with gtk pixbuf_loader calls, thereby removing an extra dependency. As it stands it just requires a working gtk3 (and Joe's HUG3). If you play, remember to use the RIGHT mouse key to place pegs. LEFT click to mark and right click to place - the Help screen actually says that, but sometimes people do not read - and I got caught here myself this morning, wondering why a left mouse click was not moving the peg. With kind regards, vovchik Attachments:psol_hug3.tar.gz (52.44 KB)
|
|
|
Post by bigbass on Sept 1, 2014 14:46:45 GMT 1
Hey vovchik Great port of one of your gtk2 apps to gtk3! keeping apps up to date is a great exercise and you can do the inline SVG's after all just not with base64 but its easier to modify inline SVG code if you want and SVG is at least readable/editable on the fly I looked over the the diff changes and there are several! Here is the diff it will be valid for one month only www.diffchecker.com/kzylio5dJoe
|
|
|
Post by vovchik on Sept 1, 2014 20:28:00 GMT 1
Dear Joe, Thanks. I just compiled this version of PegSolitaire for GTK2 by changing one byte. Rather than using hug3.bac as an INCLUDE I used hug.bac. Works the same. That's a nice surprise. With kind regards, vovchik
|
|
|
Post by vovchik on Sept 2, 2014 14:44:06 GMT 1
Dear Joe and all, When I examined the gtk2-HUG version I had done, I noticed that the tooltips were not showing in labels. Hence I turned the labels into EVENT_LABELs, but then discovered that they would not update properly with TEXT, so I had to introduce a little workaround using g_object_set and gtk_bin_get_child. Works just fine. While I was at it, I decided to enhance the little game, using a background image. I think it now looks much better. I will now try to see whether I can approximate this in gtk3 and hug3 by some means or other. With kind regards, vovchik UPDATED: I erroneously placed the wrong source in the achive. Sorry. Attachments:
|
|
|
Post by bigbass on Sept 2, 2014 15:03:05 GMT 1
|
|
|
Post by vovchik on Sept 2, 2014 16:15:09 GMT 1
Dear Joe,
Boradway does look very interesting. I am afraid of borking my system, though, so have to do some reading first. I know we can add the ppa and then theoretically trash it if it doesn't work properly, but what happens to the dev bits? And can non-broadway GTK3 installations still run the progs directly, and not via a socket? Have you tried installing? And if so, how does it perform?
With kind regards, vovchik
|
|
|
Post by bigbass on Sept 2, 2014 16:35:27 GMT 1
Hey vovchik looks fun compsci.ca/v3/viewtopic.php?t=36823Yes I tried and had to revert(broadwayd didnt install ) because ubuntu /mint gtk differences in the package list would be nice not to use java for stuff like this maybe there is a big $$ reason this isn't popular BaCon gtk3 apps in a browser Would like to rebuild some packages to test this on mint
|
|
|
Post by vovchik on Sept 2, 2014 17:03:20 GMT 1
Dear Joe, Broadway would be great if we could get it to install and work painlessly. I just updated the archive of the new gtk2 version of Peg Solitaire since I had the wrong source in the archive. With kind regards, vovchik
|
|
|
Post by vovchik on Sept 3, 2014 13:41:43 GMT 1
Dear Joe, James Fuller has pointed out something about GTK3 frames - the standard enums hardly work because nobody seems to have implemented that stuff in css. Here is a little workaround: ' *********************** ' COMPILER OPTIONS ' ***********************
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` OPTION PARSE FALSE
' *********************** ' END COMPILER OPTIONS ' ***********************
' *********************** ' INITIALIZATION ' ***********************
DECLARE *window TYPE void DECLARE *frame1, *frame2, *frame3, *frame4 TYPE void DECLARE *table TYPE void CONST MY_VERSION$ = "v.01a"
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' SUB & FUNCTIONS ' ***********************
' ----------------- SUB DESTROY(NUMBER widget, void* data) ' ----------------- gtk_main_quit() END SUB
' ----------------- SUB FIX_FRAME(STRING bg$, STRING border$, int size, int pad, int radius, int style) ' ----------------- ' use #xxxxxx or named color in quotes ' plus thickness, pad, radius and style as int LOCAL provider TYPE void* LOCAL display TYPE void* LOCAL screen TYPE void* LOCAL data$, style$ TYPE STRING ' The border-style property accepts the 'none', 'solid', ' 'inset' and 'outset' keywords. SELECT style CASE 0 style$ = "none" CASE 1 style$ = "solid" CASE 2 style$ = "inset" CASE 3 style$ = "outset" END SELECT data$ = ".frame{" & \ "background-color:" & bg$ & ";" & \ "border:" & STR$(size) & "px solid " & border$ & ";" & \ "padding:" & STR$(pad) & "px;" & \ "border-radius:" & STR$(radius) & "px;" \ "border-style:" & style$ & ";" & \ " }" provider = gtk_css_provider_new() display = gdk_display_get_default() screen = gdk_display_get_default_screen(display) gtk_style_context_add_provider_for_screen (screen, provider, 600) gtk_css_provider_load_from_data(provider, data$, -1, NULL) g_object_unref(provider) END SUB
' ----------------- SUB MK_GUI() ' ----------------- LOCAL shadow TYPE int gtk_init(0, 0) window = gtk_window_new(0) 'gtk_window_set_opacity(window, 0.5) gtk_window_set_position(window, 0) gtk_window_set_default_size(window, 250, 250) gtk_window_set_title(window, CONCAT$("Gtk3 Frame - ", MY_VERSION$)) gtk_container_set_border_width(window, 10) table = gtk_table_new(2, 2, TRUE) gtk_table_set_row_spacings(table, 10) gtk_table_set_col_spacings(table, 10) gtk_container_add(window, table) frame1 = gtk_frame_new("Shadow In") gtk_frame_set_shadow_type(frame1, 1) frame2 = gtk_frame_new("Shadow Out") gtk_frame_set_shadow_type(frame2, 2) frame3 = gtk_frame_new("Etched In") gtk_frame_set_shadow_type(frame3, 3) frame4 = gtk_frame_new("Etched Out") gtk_frame_set_shadow_type(frame4, 4) gtk_table_attach_defaults(table, frame1, 0, 1, 0, 1) gtk_table_attach_defaults(table, frame2, 0, 1, 1, 2) gtk_table_attach_defaults(table, frame3, 1, 2, 0, 1) gtk_table_attach_defaults(table, frame4, 1, 2, 1, 2) g_signal_connect_data(window, "destroy", ADDRESS(DESTROY), 0, 0, 0) ' use #xxxxxx or named colors in quotes for bg and border, ' plus thickness, pad, radius and style as int FIX_FRAME("pink", "dimgray", 3, 4, 8, 3) gtk_widget_show_all(window) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI() gtk_main()
' *********************** ' END MAIN ' ***********************
With kind regards, vovchik PS. Now if we could only do this on a widget-by-widget basis, we would be in good shape. Attachments:
|
|