Thursday, February 24, 2022

Slow startup of Gnocl based applications in Ubuntu 20.4

 The recent changes to the Ubuntu 20.4 deployment sometimes sees slow startup times of between 25-60secs. Thankfully someone has solved the problem. I've downloaded the module and it works for me.


https://itsfoss.community/t/solved-apps-opening-too-slow-in-ubuntu-20-04/4578/2

With help from a teammate in investigating the common problem with our apps, he discovered a cure by installing the deprecated gtk2 library module. Available in the 20.04 distro.

All you need to do is to run this command:

sudo apt install appmenu-gtk2-module

and then rebooting. You need to reboot to get the new library working.

This allows older applications based on the older menu API to function normally. Solved the issue with Boinc Manager and GKrellm config menu.

Ref: https://launchpad.net/ubuntu/bionic/+package/appmenu-gtk2-module 478

Saturday, February 05, 2022

Creating Empty Lists

Just what it 'says on the tin', create a list of empty strings.

 

proc emptyList {n} {
    for {set i 0} {$i < $n} {incr i} { lappend res {} }
    return $res
}

Friday, November 05, 2021

October News...

 2021-10:
gnocl::text
o insertImage command enhanced to follow the insert command for text, ie..
$wid insertImage <pos> <imagename> -tags <taglist>
Where image can take a standard image %-markup prefix
gnocl::pango
o new subcmds, markup2options, options2markup
attempts to convert a pango markup string <span> tag to a list of text attibutes e.g., 
gnocl::pango markup2option "<span foreground='red' background='blue'>"  
returns 
{-foreground "red" -background "blue"}
gnocl::pango option2markup {-foreground "red" -background "blue"} 
returns
"<span foreground='red' background='blue'>"
created strings.h header file, keep decls for project string utilites
gnocl::text
o tag 
  new sub command - return character tag properties as pango markup
  new options -underlineColor, -strikethroughColor, not used by widget,
but passed as a pango attribute.
gnocl::canvas
o new command clear, remove all items from canvas.
o new text item options: -clip, -clipHeight, -clipWidth, 
  -fontRise, -fontSizePoints, -fontStrikethough, -markup, 
  -textHeight, -textWidth
gnocl::text
o tag ranges issues resolved.
gnocl::labelWidget
o issues with widget commands now resolved.
gnocl::button
o new option -onDestroy
gnocl::dialog
o removed redundant -modal option, dialog widgets are modal by default

First Attempt at Accessing GObject Private Data - FAILED

When the toolbar is placed in the vertical alignment widget texts are still centred. I thought that making these alignable might be more aesthically pleasing. I didn't complete the job, but I did glean a little bit more on just how to access widget private data. It all seems to pivot around the G_TYPE_INSTANCE_GET_PRIVATE macro.

#if 1
/* ATTEMPT TO LEFT ALIGN BUTTON TEXT */

struct _GtkToolButtonPrivate
{
  GtkWidget *button;
  gchar *stock_id;
  gchar *icon_name;
  gchar *label_text;
  GtkWidget *label_widget;
  GtkWidget *icon_widget;
  GtkSizeGroup *text_size_group;
  guint use_underline : 1;
  guint contents_invalid : 1;
};

typedef struct _GtkToolButtonPrivate GtkToolButtonPrivate;

struct _GtkToolButton
{
  GtkToolItem parent;
  /*< private >*/
  GtkToolButtonPrivate *GSEAL (priv);
};


#define GTK_TOOL_BUTTON_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_TOOL_BUTTON, GtkToolButtonPrivate))

GtkToolButton      *button;
GtkToolButtonPrivate *priv;

priv = GTK_TOOL_BUTTON_GET_PRIVATE (para->item);

GtkWidget *label = priv->label_widget;

gtk_misc_set_alignment (label,0.0,0.5);

#endif 

Friday, October 29, 2021

Converting a Pango Markup Span Tag to a List of Text Widget Tag Options

Its always been a trouble task sharing formatted text between the gnocl::text widget and other display widgets such as the gnocl::label, gnocl::tree and gnocl::list widgets. This diffculty arises from not being able to define text attributes as pango markup, this is understandable given that fact that there is not a smooth overlap between the widget and pango attributes.

What was needed was a way of bridging the two requirments, being able to take a markup <span> tag and converting to an -opt val list.

Parsing markup strings using the pango api is not terribly helpful, it is complex and only works on complete strings, "<span .... ...>" would simply through up a pango formatting error.

The solution has been much simpler by using a series of string mapping operations in the source module with the resul being the creation of a new gnocl::pango subcommand "markup2options". For instance, if: 

set markup "<span font='Serif italic bold 24' foreground='green' background='red'>"

then calling

gnocl::pango markup2options $markup

returns

-font "Serif italic bold 24" -foreground "green" -background "red"

Using this a working script would produce something along the lines of:

$txt tag create test {*}[gnocl::pango markup2options $markup]
$txt insert end $sometext -tags test


Wednesday, October 20, 2021

String and Text Block Insertion Allowing for HTML/Pango String Markup

Tcl offers some really excelling string manipulation tools 'straight out of the box' although sometimes something extra might be needed. What if, for instance, the strings contain markup? Any markup is invisible on screen and so any string positioning needs to ignore the effects of that markup on the overall string length.

This can be achieved by using a simple flag to keep track of where characters in a string are containtained within a markup substring or not.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## insert str1 into str2 at position pos, allow for pango/html markup
# @param[in] str1	
# @param[in] str2
# @param[in] pos
# @param[in] opt
# @return modified string
proc string_insert { str1 str2 pos {opt ""} } {
	switch $opt {
		-markup {
			set flag 1
			set i 0
			set res ""
			foreach c [split $str2 ""] {
				append res $c
				if { $c == "<" } { set flag 0 }
				if { $c == ">" } { set flag 1 }
				if { $flag } { 
					if {$i == $pos } { append res $str1 } 
					incr i
					}  
			}
			return $res
			}
		default {
			return [string range $str2 0 $pos-1]$str1[string range $str2 $pos end]
		}
	}
}



## insert str1 into str2 at specified line and offset, allow for pango/html markup
# @param[in] str1
# @param[in] str2
# @param[in] line
# @param[in] offset
# @param[in] opt
# @return modified string
proc text_insert { str1 str2 line offset {opt ""} } {
	# extract specific line
	set strings [split $str2 \n]
	set ln [lindex $strings $line]
	# make insertion
	if { $opt == "-markup"} {
		set ln [string_insert $str1 $ln $offset $opt]
	} else {
		set ln [string range $ln 0 $offset-1]$str1[string range $ln $offset end]
	}
	# repack the text
	return [join [lreplace $strings $line $line $ln] \n]
}



asdasd

Recent Changes October, 2021

Most significant change during September was the inclusion of the -spellcheck option for the gnocl::text widget.


 2021-09:

gnocl::text

o new boolean option -spellcheck, cget also works, 

gnocl::spellcheck

o moved separate code back into the main module

gnocl::labelEntry

o added substitution strings %X %Y %W %H to -onIconPress/-onIconRelease callback scripts.

o cget -variable now works

gnocl::calendar

o added substitution strings %D %M %Y to -onDoubleDaySelect callback script.

json_shell_utils.tcl