| 1 | package Tk::GtkSettings; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Tk::GtkSettings - Give Tk applications the looks of Gtk applications | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =cut | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 17 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||
| 18 | $delete_output | ||||||||||||||||||||||||||||
| 19 | $gtkpath | ||||||||||||||||||||||||||||
| 20 | $verbose | ||||||||||||||||||||||||||||
| 21 | $out_file | ||||||||||||||||||||||||||||
| 22 | alterColor | ||||||||||||||||||||||||||||
| 23 | appName | ||||||||||||||||||||||||||||
| 24 | convertColorCode | ||||||||||||||||||||||||||||
| 25 | export2file | ||||||||||||||||||||||||||||
| 26 | export2Xdefaults | ||||||||||||||||||||||||||||
| 27 | export2xrdb | ||||||||||||||||||||||||||||
| 28 | export2Xresources | ||||||||||||||||||||||||||||
| 29 | groupAdd | ||||||||||||||||||||||||||||
| 30 | groupAll | ||||||||||||||||||||||||||||
| 31 | groupDelete | ||||||||||||||||||||||||||||
| 32 | groupExists | ||||||||||||||||||||||||||||
| 33 | groupMembers | ||||||||||||||||||||||||||||
| 34 | groupMembersAdd | ||||||||||||||||||||||||||||
| 35 | groupMembersReplace | ||||||||||||||||||||||||||||
| 36 | groupOption | ||||||||||||||||||||||||||||
| 37 | groupOptionAll | ||||||||||||||||||||||||||||
| 38 | groupOptionDelete | ||||||||||||||||||||||||||||
| 39 | gtkKey | ||||||||||||||||||||||||||||
| 40 | gtkKeyAll | ||||||||||||||||||||||||||||
| 41 | gtkKeyDelete | ||||||||||||||||||||||||||||
| 42 | hex2rgb | ||||||||||||||||||||||||||||
| 43 | hexstring | ||||||||||||||||||||||||||||
| 44 | initDefaults | ||||||||||||||||||||||||||||
| 45 | loadGtkInfo | ||||||||||||||||||||||||||||
| 46 | platformPermitted | ||||||||||||||||||||||||||||
| 47 | removefromFile | ||||||||||||||||||||||||||||
| 48 | removeFromXdefaults | ||||||||||||||||||||||||||||
| 49 | removeFromXresources | ||||||||||||||||||||||||||||
| 50 | removeFromxrdb | ||||||||||||||||||||||||||||
| 51 | resetAll | ||||||||||||||||||||||||||||
| 52 | rgb2hex | ||||||||||||||||||||||||||||
| 53 | ) ] ); | ||||||||||||||||||||||||||||
| 54 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 57 | applyGtkSettings | ||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub appName; | ||||||||||||||||||||||||||||
| 61 | sub export2xrdb; | ||||||||||||||||||||||||||||
| 62 | sub generateOutput; | ||||||||||||||||||||||||||||
| 63 | sub initDefaults; | ||||||||||||||||||||||||||||
| 64 | sub loadGtkInfo; | ||||||||||||||||||||||||||||
| 65 | sub platformPermitted; | ||||||||||||||||||||||||||||
| 66 | sub resetAll; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | our $delete_output = 1; | |||||||||||||||||||||||||||
| 69 | 1 | our $gtkpath; | |||||||||||||||||||||||||||
| 70 | 1 | our $verbose = 0; | |||||||||||||||||||||||||||
| 71 | 1 | our $out_file; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if (platformPermitted) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 1 | $gtkpath = $ENV{HOME} . "/.config/gtk-3.0/"; | |||||||||||||||||||||||||||
| 75 | 1 | $out_file = $ENV{HOME} . "/.tkgtksettings"; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | my $no_gtk = 0; | |||||||||||||||||||||||||||
| 79 | 1 | my %gtksettings = (); | |||||||||||||||||||||||||||
| 80 | 1 | my %groups = (main => [[''], {}]); | |||||||||||||||||||||||||||
| 81 | 1 | my $app_name = ''; | |||||||||||||||||||||||||||
| 82 | 1 | my $marker; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | my @basegtkeys = qw( | |||||||||||||||||||||||||||
| 85 | theme_fg_color | ||||||||||||||||||||||||||||
| 86 | theme_bg_color | ||||||||||||||||||||||||||||
| 87 | theme_text_color | ||||||||||||||||||||||||||||
| 88 | theme_base_color | ||||||||||||||||||||||||||||
| 89 | theme_view_hover_decoration_color | ||||||||||||||||||||||||||||
| 90 | theme_hovering_selected_bg_color | ||||||||||||||||||||||||||||
| 91 | theme_selected_bg_color | ||||||||||||||||||||||||||||
| 92 | theme_selected_fg_color | ||||||||||||||||||||||||||||
| 93 | theme_view_active_decoration_color | ||||||||||||||||||||||||||||
| 94 | theme_button_background_normal | ||||||||||||||||||||||||||||
| 95 | theme_button_decoration_hover | ||||||||||||||||||||||||||||
| 96 | theme_button_decoration_focus | ||||||||||||||||||||||||||||
| 97 | theme_button_foreground_normal | ||||||||||||||||||||||||||||
| 98 | theme_button_foreground_active | ||||||||||||||||||||||||||||
| 99 | borders | ||||||||||||||||||||||||||||
| 100 | warning_color | ||||||||||||||||||||||||||||
| 101 | success_color | ||||||||||||||||||||||||||||
| 102 | error_color | ||||||||||||||||||||||||||||
| 103 | theme_unfocused_fg_color | ||||||||||||||||||||||||||||
| 104 | theme_unfocused_text_color | ||||||||||||||||||||||||||||
| 105 | theme_unfocused_bg_color | ||||||||||||||||||||||||||||
| 106 | theme_unfocused_base_color | ||||||||||||||||||||||||||||
| 107 | theme_unfocused_selected_bg_color_alt | ||||||||||||||||||||||||||||
| 108 | theme_unfocused_selected_bg_color | ||||||||||||||||||||||||||||
| 109 | theme_unfocused_selected_fg_color | ||||||||||||||||||||||||||||
| 110 | theme_button_background_backdrop | ||||||||||||||||||||||||||||
| 111 | theme_button_decoration_hover_backdrop | ||||||||||||||||||||||||||||
| 112 | theme_button_decoration_focus_backdrop | ||||||||||||||||||||||||||||
| 113 | theme_button_foreground_backdrop | ||||||||||||||||||||||||||||
| 114 | theme_button_foreground_active_backdrop | ||||||||||||||||||||||||||||
| 115 | unfocused_borders | ||||||||||||||||||||||||||||
| 116 | warning_color_backdrop | ||||||||||||||||||||||||||||
| 117 | success_color_backdrop | ||||||||||||||||||||||||||||
| 118 | error_color_backdrop | ||||||||||||||||||||||||||||
| 119 | insensitive_fg_color | ||||||||||||||||||||||||||||
| 120 | insensitive_base_fg_color | ||||||||||||||||||||||||||||
| 121 | insensitive_bg_color | ||||||||||||||||||||||||||||
| 122 | insensitive_base_color | ||||||||||||||||||||||||||||
| 123 | insensitive_selected_bg_color | ||||||||||||||||||||||||||||
| 124 | insensitive_selected_fg_color | ||||||||||||||||||||||||||||
| 125 | theme_button_background_insensitive | ||||||||||||||||||||||||||||
| 126 | theme_button_decoration_hover_insensitive | ||||||||||||||||||||||||||||
| 127 | theme_button_decoration_focus_insensitive | ||||||||||||||||||||||||||||
| 128 | theme_button_foreground_insensitive | ||||||||||||||||||||||||||||
| 129 | theme_button_foreground_active_insensitive | ||||||||||||||||||||||||||||
| 130 | insensitive_borders | ||||||||||||||||||||||||||||
| 131 | warning_color_insensitive | ||||||||||||||||||||||||||||
| 132 | success_color_insensitive | ||||||||||||||||||||||||||||
| 133 | error_color_insensitive | ||||||||||||||||||||||||||||
| 134 | insensitive_unfocused_fg_color | ||||||||||||||||||||||||||||
| 135 | theme_unfocused_view_text_color | ||||||||||||||||||||||||||||
| 136 | insensitive_unfocused_bg_color | ||||||||||||||||||||||||||||
| 137 | theme_unfocused_view_bg_color | ||||||||||||||||||||||||||||
| 138 | insensitive_unfocused_selected_bg_color | ||||||||||||||||||||||||||||
| 139 | insensitive_unfocused_selected_fg_color | ||||||||||||||||||||||||||||
| 140 | theme_button_background_backdrop_insensitive | ||||||||||||||||||||||||||||
| 141 | theme_button_decoration_hover_backdrop_insensitive | ||||||||||||||||||||||||||||
| 142 | theme_button_decoration_focus_backdrop_insensitive | ||||||||||||||||||||||||||||
| 143 | theme_button_foreground_backdrop_insensitive | ||||||||||||||||||||||||||||
| 144 | theme_button_foreground_active_backdrop_insensitive | ||||||||||||||||||||||||||||
| 145 | unfocused_insensitive_borders | ||||||||||||||||||||||||||||
| 146 | warning_color_insensitive_backdrop | ||||||||||||||||||||||||||||
| 147 | success_color_insensitive_backdrop | ||||||||||||||||||||||||||||
| 148 | error_color_insensitive_backdrop | ||||||||||||||||||||||||||||
| 149 | link_color | ||||||||||||||||||||||||||||
| 150 | link_visited_color | ||||||||||||||||||||||||||||
| 151 | tooltip_text | ||||||||||||||||||||||||||||
| 152 | tooltip_background | ||||||||||||||||||||||||||||
| 153 | tooltip_border | ||||||||||||||||||||||||||||
| 154 | content_view_bg | ||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | my @contentwidgets = qw( | |||||||||||||||||||||||||||
| 158 | Entry | ||||||||||||||||||||||||||||
| 159 | FilterEntry | ||||||||||||||||||||||||||||
| 160 | FloatEntry | ||||||||||||||||||||||||||||
| 161 | Spinbox | ||||||||||||||||||||||||||||
| 162 | Text | ||||||||||||||||||||||||||||
| 163 | TextUndo | ||||||||||||||||||||||||||||
| 164 | TextEditor | ||||||||||||||||||||||||||||
| 165 | ROText | ||||||||||||||||||||||||||||
| 166 | XText | ||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1 | my @listwidgets = qw( | |||||||||||||||||||||||||||
| 170 | Dirlist | ||||||||||||||||||||||||||||
| 171 | DirTree | ||||||||||||||||||||||||||||
| 172 | HList | ||||||||||||||||||||||||||||
| 173 | ITree | ||||||||||||||||||||||||||||
| 174 | IconList | ||||||||||||||||||||||||||||
| 175 | Listbox | ||||||||||||||||||||||||||||
| 176 | ListBrowser | ||||||||||||||||||||||||||||
| 177 | Tlist | ||||||||||||||||||||||||||||
| 178 | Tree | ||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 1 | my %mainoptions = qw( | |||||||||||||||||||||||||||
| 182 | background theme_bg_color | ||||||||||||||||||||||||||||
| 183 | foreground theme_fg_color | ||||||||||||||||||||||||||||
| 184 | font gtk-font-name | ||||||||||||||||||||||||||||
| 185 | activeBackground theme_button_decoration_focus | ||||||||||||||||||||||||||||
| 186 | activeForeground theme_fg_color | ||||||||||||||||||||||||||||
| 187 | disabledBackground theme_button_background_insensitive | ||||||||||||||||||||||||||||
| 188 | disabledForeground theme_button_foreground_insensitive | ||||||||||||||||||||||||||||
| 189 | backPageColor theme_button_background_backdrop | ||||||||||||||||||||||||||||
| 190 | headerBackground theme_button_decoration_hover | ||||||||||||||||||||||||||||
| 191 | highlightBackground theme_bg_color | ||||||||||||||||||||||||||||
| 192 | highlightColor theme_selected_bg_color | ||||||||||||||||||||||||||||
| 193 | inactiveBackground theme_button_background_backdrop | ||||||||||||||||||||||||||||
| 194 | insertBackground theme_fg_color | ||||||||||||||||||||||||||||
| 195 | errorColor error_color | ||||||||||||||||||||||||||||
| 196 | warningColor warning_color | ||||||||||||||||||||||||||||
| 197 | linkColor link_color | ||||||||||||||||||||||||||||
| 198 | selectBackground theme_selected_bg_color | ||||||||||||||||||||||||||||
| 199 | selectForeground theme_selected_fg_color | ||||||||||||||||||||||||||||
| 200 | troughColor insensitive_bg_color | ||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | my %contentoptions = qw( | |||||||||||||||||||||||||||
| 204 | background content_view_bg | ||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 1 | my %listoptions = qw( | |||||||||||||||||||||||||||
| 208 | background content_view_bg | ||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 1 | appName(''); | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =over 4 | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | use Tk::GtkSettings; | ||||||||||||||||||||||||||||
| 218 | applyGtkSettings; | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | #or | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | use Tk::GtkSettings qw(initDefaults export2xrdb); | ||||||||||||||||||||||||||||
| 223 | initDefaults; | ||||||||||||||||||||||||||||
| 224 | #do your adjustments here | ||||||||||||||||||||||||||||
| 225 | export2xrdb; | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | #then initialize your perl/Tk app. | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | use Tk; | ||||||||||||||||||||||||||||
| 230 | my $w = new MainWindow; | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | #Do your stuff here | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | $w->MainLoop; | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =back | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | =head1 ABSTRACT | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | Apply Gtk colors and fonts to your perl/Tk application | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | Tk::GtkSettings attempts to overcome some very old complaints about Tk: | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | - It's ugly! | ||||||||||||||||||||||||||||
| 247 | - It's complicated to adjust colors and fonts to your desktop style | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | Tk::GtkSettings loads your Gtk configuration files and applies it's font and color settings to your perl/Tk application. | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | B<initDefaults> loads some nice (at least we think so) default settings that copies your Gtk theme pretty well. | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | However, it gives plenty of tools for you to adjust it and mess it up any way you like. | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | It is harmless to install on Windows or Mac. It just will not do anything on these systems. That makes it | ||||||||||||||||||||||||||||
| 256 | smooth to add as a dependency to your own package if you want it to be able to run on Windows and Mac as well. | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | In working with colors it assumes 8-bit color depth. | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | =head1 EXPORTS | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =over 4 | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =item B<$delete_output> | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Usefull for testing and debugging. B<export2xrdb> exports to a file which then is sent to xrdb. | ||||||||||||||||||||||||||||
| 267 | It checks if this file should be deleted when done. Default value is 1. | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =item B<$gtkpath> | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | Usefull for testing. Default value is ~/.config/gtk-3.0/. That is the location where the | ||||||||||||||||||||||||||||
| 272 | Gtk configuration files reside. This variable is not defined when on Windows or Mac. | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | =item B<$out_file> | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | Default value ~/.tkgtksettings. Used by B<export2xrdb>. This variable is not defined | ||||||||||||||||||||||||||||
| 277 | on Windows or Mac. | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =item B<$verbose> | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | Usefull for testing and debugging. Default value is 0. If set B<Tk::GtkSettings> will | ||||||||||||||||||||||||||||
| 282 | complain about everything not in order. Otherwise it will quietly fail. | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =item B<alterColor>(I<$hexcolor>, I<$offset>) | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | Adjusts $hexcolor by $offset. It takes every color chanel and adds or substracts $offset. | ||||||||||||||||||||||||||||
| 287 | If the channel value is greater than 127 it will substract, otherwise it will add. | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | alterColor('#000000', 1) returns #010101 | ||||||||||||||||||||||||||||
| 290 | alterColor('#FFFFFF', 1) returns #FEFEFE | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 3 | ▶ | sub alterColor { | ||||||||||||||||||||||||||
|
Subroutine
alterColor: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 3 | my ($hex, $offset) = @_; | |||||||||||||||||||||||||||
| 296 | 3 | my @rgb = hex2rgb($hex); | |||||||||||||||||||||||||||
| 297 | 3 | my @rgba = (); | |||||||||||||||||||||||||||
| 298 | 3 | for (@rgb) { | |||||||||||||||||||||||||||
| 299 | 9 | ▶ | if ($_ < 128) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 3 | my $c = $_ + $offset; | |||||||||||||||||||||||||||
| 301 | 3 | ▶ | $c = 0 if $c < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 3 | push @rgba, $c | |||||||||||||||||||||||||||
| 303 | } else { | ||||||||||||||||||||||||||||
| 304 | 6 | my $c = $_ - $offset; | |||||||||||||||||||||||||||
| 305 | 6 | ▶ | $c = 255 if $c > 255; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 6 | push @rgba, $c | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | 3 | return rgb2hex(@rgba) | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =item B<applyGtkSettings> | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | Just making life easy. Call this one and your done, unless you require adjustments. | ||||||||||||||||||||||||||||
| 315 | It calls B<initDefaults> and exports the whole bunch to xrdb. | ||||||||||||||||||||||||||||
| 316 | Exported by default. | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =cut | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub applyGtkSettings { | ||||||||||||||||||||||||||
|
Subroutine
applyGtkSettings: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 0 | initDefaults; | |||||||||||||||||||||||||||
| 323 | 0 | export2xrdb; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =item B<appName>(I<$name>) | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | Sets and returns your application name. By default it is set to the basename of what is in B<$0>. Your Gtk settings | ||||||||||||||||||||||||||||
| 329 | will only be applied to your application in xrdb. You can set it to an empty string. Then it will | ||||||||||||||||||||||||||||
| 330 | apply your Gtk settings to all your perl/Tk applications. | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 1 | ▶ | sub appName { | ||||||||||||||||||||||||||
|
Subroutine
appName: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 335 | 1 | ▶ | if (@_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 1 | $app_name = shift; | |||||||||||||||||||||||||||
| 337 | 1 | $app_name = basename($app_name); #remove leading folders | |||||||||||||||||||||||||||
| 338 | 1 | $app_name =~ s/\.[^.]+$//; #remove extension | |||||||||||||||||||||||||||
| 339 | 1 | $marker = "!$app_name Tk::GtkSettings section\n"; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | 1 | return $app_name | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | =item B<convertColorCode>(I<'rgb(255, 0, 0)'>) | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | Some color settings in the Gtk configuration files are in the format 'rgb(255, 255, 255)'. | ||||||||||||||||||||||||||||
| 347 | B<convertColorCode> converts these to a hex color string. | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 1 | ▶ | sub convertColorCode { | ||||||||||||||||||||||||||
|
Subroutine
convertColorCode: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 352 | 1 | my $input = shift; | |||||||||||||||||||||||||||
| 353 | 1 | ▶ | if ($input =~ /rgb\((\d+),(\d+),(\d+)\)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 1 | my $r = substr(sprintf("0x%X", $1), 2); | |||||||||||||||||||||||||||
| 355 | 1 | my $g = substr(sprintf("0x%X", $2), 2); | |||||||||||||||||||||||||||
| 356 | 1 | my $b = substr(sprintf("0x%X", $3), 2); | |||||||||||||||||||||||||||
| 357 | 1 | return "#$r$g$b" | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =item B<decodeFont>(I<$gtkfontstring>) | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Converts the font string in gtk to something Tk can handle | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =cut | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 2 | ▶ | sub decodeFont { | ||||||||||||||||||||||||||
|
Subroutine
decodeFont: called CC=4 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||
| 368 | 2 | my $rawfont = shift; | |||||||||||||||||||||||||||
| 369 | 2 | my $family = ''; | |||||||||||||||||||||||||||
| 370 | 2 | my $style = ''; | |||||||||||||||||||||||||||
| 371 | 2 | my $size = ''; | |||||||||||||||||||||||||||
| 372 | 2 | ▶ | if ($rawfont =~ s/^([^,]+),//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | 2 | $family = $1; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | 2 | $rawfont =~ s/^\s*//; #remove leading spaces | |||||||||||||||||||||||||||
| 376 | 2 | ▶ | if ($rawfont =~ s/^([^\d]+)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | 0 | $style = $1; | |||||||||||||||||||||||||||
| 378 | 0 | $style =~ s/^\s*//; #remove leading spaces | |||||||||||||||||||||||||||
| 379 | 0 | $style =~ s/\s*!//; #remove trailing spaces | |||||||||||||||||||||||||||
| 380 | 0 | $style = lc($style); | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | 2 | ▶ | if ($rawfont =~ s/^(\d+)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | 2 | $size = $1; | |||||||||||||||||||||||||||
| 384 | 2 | $size =~ s/\s*!//; #remove trailing spaces | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | 2 | return "{$family} $size $style" | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =item B<export2file>(I<$file>, ?I<$removeflag>?) | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | Exports your Gtk settings to $file in a format recognized by xrdb. It looks for a section | ||||||||||||||||||||||||||||
| 392 | in the file marked by appName . "Tk::GtkSettings section\n". If it finds it it will replace this section. | ||||||||||||||||||||||||||||
| 393 | Otherwise it will append your Gtk settings to the end of the file. If $file does not yet exist it | ||||||||||||||||||||||||||||
| 394 | will create it. if $removeflag is true it will not export but remove the section from $file. | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 2 | ▶ | sub export2file { | ||||||||||||||||||||||||||
|
Subroutine
export2file: called CC=13 SCAR=33.8
Pod
documented
| |||||||||||||||||||||||||||||
| 399 | 2 | my ($file, $remove) = @_; | |||||||||||||||||||||||||||
| 400 | 2 | ▶ | $remove = 0 unless defined $remove; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | 2 | my $out = ""; | |||||||||||||||||||||||||||
| 402 | 2 | my $found = 0; | |||||||||||||||||||||||||||
| 403 | 2 | ▶ | if (-e $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | 2 | ▶ | unless (open(XDEF, "<$file")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | ▶ | warn "cannot open $file" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | return | ||||||||||||||||||||||||||||
| 407 | 0 | } | |||||||||||||||||||||||||||
| 408 | 2 | my $inside = 0; | |||||||||||||||||||||||||||
| 409 | 2 | ▶ | while (my $l = <XDEF>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 53 | ▶ | if ($inside) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 0 | ▶ | if ($l eq $marker) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 0 | $inside = 0; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||
| 415 | 53 | ▶ | if ($l eq $marker) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | 0 | $inside = 1; | |||||||||||||||||||||||||||
| 417 | 0 | $found = 1; | |||||||||||||||||||||||||||
| 418 | 0 | ▶ | $out = "$out$l" . generateOutput . $l unless $remove; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | } else { | ||||||||||||||||||||||||||||
| 420 | 53 | $out = "$out$l"; | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | 2 | close XDEF; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 2 | ▶ | unless ($found) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | 2 | $out = "$out\n$marker" . generateOutput . "$marker\n" | |||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | 2 | ▶ | unless (open(XDEFO, ">$file")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 430 | 0 | ▶ | warn "cannot open $file" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | return | ||||||||||||||||||||||||||||
| 432 | 0 | } | |||||||||||||||||||||||||||
| 433 | 2 | print XDEFO $out; | |||||||||||||||||||||||||||
| 434 | 2 | close XDEFO; | |||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | =item B<export2Xdefaults>(?I<$removeflag>?) | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | Same as B<export2file>, however the file is always '~/.Xdefaults'. | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | =cut | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 0 | ▶ | sub export2Xdefaults { | ||||||||||||||||||||||||||
|
Subroutine
export2Xdefaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 444 | 0 | export2file( $ENV{HOME} . '/.Xdefaults'); | |||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | =item B<export2Xresources>(?I<$removeflag>?) | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | Same as B<export2file>, however the file is always '~/.Xresources'. | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =cut | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 0 | ▶ | sub export2Xresources { | ||||||||||||||||||||||||||
|
Subroutine
export2Xresources: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 454 | 0 | export2file( $ENV{HOME} . '/.Xresources'); | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =item B<export2xrdb> | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | exports your Gtk settings directly to the xrdb database. | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =cut | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | ▶ | sub export2xrdb { | ||||||||||||||||||||||||||
|
Subroutine
export2xrdb: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 464 | 0 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | return if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if (open(OFILE, ">", $out_file)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | 0 | print OFILE generateOutput; | |||||||||||||||||||||||||||
| 468 | 0 | close OFILE; | |||||||||||||||||||||||||||
| 469 | 0 | system "xrdb $out_file"; | |||||||||||||||||||||||||||
| 470 | 0 | ▶ | unlink $out_file if $delete_output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | =item B<generateOutput> | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | Generates the output used by the export functions. Returns a string. | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | =cut | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 2 | ▶ | sub generateOutput { | ||||||||||||||||||||||||||
|
Subroutine
generateOutput: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||
| 481 | 2 | ▶ | return if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 482 | 2 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 2 | my $output = ''; | |||||||||||||||||||||||||||
| 484 | #group main has to be done first. | ||||||||||||||||||||||||||||
| 485 | 2 | my (@g) = ('main'); | |||||||||||||||||||||||||||
| 486 | 2 | for (sort keys %groups) { | |||||||||||||||||||||||||||
| 487 | 8 | ▶ | push @g, $_ unless $_ eq 'main'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | 2 | for (@g) { | |||||||||||||||||||||||||||
| 490 | 8 | my $name = $_; | |||||||||||||||||||||||||||
| 491 | 8 | my $group = $groups{$name}; | |||||||||||||||||||||||||||
| 492 | 8 | my $options = $group->[1]; | |||||||||||||||||||||||||||
| 493 | 8 | my $mem = $group->[0]; | |||||||||||||||||||||||||||
| 494 | 8 | for (@$mem) { | |||||||||||||||||||||||||||
| 495 | 28 | my $member = $_; | |||||||||||||||||||||||||||
| 496 | 28 | for (sort keys %$options) { | |||||||||||||||||||||||||||
| 497 | 86 | my $val = gtkKey($options->{$_}); | |||||||||||||||||||||||||||
| 498 | 86 | ▶ | $val = $options->{$_} unless defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | 86 | ▶ | unless ($name eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 500 | 44 | $output = $output . $app_name . "*$member." . $_ . ": " . $val . "\n"; | |||||||||||||||||||||||||||
| 501 | } else { | ||||||||||||||||||||||||||||
| 502 | 42 | $output = $output . $app_name . '*' . $_ . ": " . $val . "\n"; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | 2 | return $output | |||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | =item B<groupAdd>(I<$groupname>, I<\@members>, I<\%options>) | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | Adds $groupname to the groups hash. If @members or %options are not specified, | ||||||||||||||||||||||||||||
| 513 | it will leave them empty. | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | =cut | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 7 | ▶ | sub groupAdd { | ||||||||||||||||||||||||||
|
Subroutine
groupAdd: called CC=7 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||
| 518 | 7 | my ($group, $members, $options) = @_; | |||||||||||||||||||||||||||
| 519 | 7 | ▶ | unless (defined $group) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 520 | 0 | ▶ | warn "group is not defined" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 521 | return | ||||||||||||||||||||||||||||
| 522 | 0 | } | |||||||||||||||||||||||||||
| 523 | 7 | ▶ | $members = [] unless defined $members; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 524 | 7 | ▶ | $options = {} unless defined $options; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 525 | 7 | ▶ | unless (exists $groups{$group}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 526 | 7 | $groups{$group} = [$members, $options] | |||||||||||||||||||||||||||
| 527 | } else { | ||||||||||||||||||||||||||||
| 528 | 0 | ▶ | warn "group $group already exists" if $verbose | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | =item B<groupAll> | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | Returns a list of all available groups. | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | =cut | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 1 | ▶ | sub groupAll { | ||||||||||||||||||||||||||
|
Subroutine
groupAll: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 539 | 1 | return keys %groups | |||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | =item B<groupDelete>(I<$groupname>) | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | Removes $groupsname from the groups hash. You cannot delete the 'main' group. | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | =cut | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 2 | ▶ | sub groupDelete { | ||||||||||||||||||||||||||
|
Subroutine
groupDelete: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 549 | 2 | my $group = shift; | |||||||||||||||||||||||||||
| 550 | 2 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | 2 | ▶ | if ($group eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 552 | 1 | ▶ | warn "deleting main group is not allowed" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 553 | 1 | return 0 | |||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | 1 | delete $groups{$group}; | |||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | 1 | return 1 | |||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | =item B<groupExists>(I<$groupname>) | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | Returns true if $groupname is available. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =cut | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 59 | ▶ | sub groupExists { | ||||||||||||||||||||||||||
|
Subroutine
groupExists: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||
| 567 | 59 | my $group = shift; | |||||||||||||||||||||||||||
| 568 | 59 | ▶ | unless (defined $group) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | 0 | ▶ | warn "group not specified or is not defined" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 570 | 0 | return 0 | |||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | 59 | ▶ | unless (exists $groups{$group}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 573 | 1 | ▶ | warn "group $group does not exist" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 574 | 1 | return 0 | |||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||
| 576 | 58 | return 1 | |||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =item B<groupMembers>(I<$groupname>) | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | Returns the list of existing members of $groupname. It will return an empty list | ||||||||||||||||||||||||||||
| 582 | if $groupname equals 'main'. | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | =cut | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | 2 | ▶ | sub groupMembers { | ||||||||||||||||||||||||||
|
Subroutine
groupMembers: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 587 | 2 | my $group = shift; | |||||||||||||||||||||||||||
| 588 | 2 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 589 | 2 | ▶ | if ($group eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 590 | 0 | warn "no access to main group members"; | |||||||||||||||||||||||||||
| 591 | return () | ||||||||||||||||||||||||||||
| 592 | 0 | } | |||||||||||||||||||||||||||
| 593 | 2 | my $l = $groups{$group}->[0]; | |||||||||||||||||||||||||||
| 594 | 2 | return @$l; | |||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | =item B<groupMembersAdd>(I<$groupname>, I<@newmembers>) | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | Adds new members to $groupname. You cannot add members to the 'main' group. | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | =cut | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | 1 | ▶ | sub groupMembersAdd { | ||||||||||||||||||||||||||
|
Subroutine
groupMembersAdd: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 605 | 1 | my $group = shift; | |||||||||||||||||||||||||||
| 606 | 1 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 607 | 1 | ▶ | if ($group eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 608 | 0 | warn "no access to main group members"; | |||||||||||||||||||||||||||
| 609 | return | ||||||||||||||||||||||||||||
| 610 | 0 | } | |||||||||||||||||||||||||||
| 611 | 1 | my $l = $groups{$group}->[0]; | |||||||||||||||||||||||||||
| 612 | 1 | push @$l, @_; | |||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =item B<groupMembersReplace>(I<$groupname>, I<@members>) | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | Replaces the list of members in $groupsname by @members. You cannot modify the members list of the 'main' group. | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | =cut | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 1 | ▶ | sub groupMembersReplace { | ||||||||||||||||||||||||||
|
Subroutine
groupMembersReplace: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 623 | 1 | my $group = shift; | |||||||||||||||||||||||||||
| 624 | 1 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 625 | 1 | ▶ | if ($group eq 'main') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 626 | 0 | warn "No access to main group members"; | |||||||||||||||||||||||||||
| 627 | return | ||||||||||||||||||||||||||||
| 628 | 0 | } | |||||||||||||||||||||||||||
| 629 | 1 | my $l = $groups{$group}->[0]; | |||||||||||||||||||||||||||
| 630 | 1 | @$l = @_; | |||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =item B<groupOption>(I<$groupname>, I<$option>, ?I<$value>?) | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | Sets and returns the value of $option in $groupname. $value should be a corresponding key from | ||||||||||||||||||||||||||||
| 637 | the Gtk hash. If that key is not found, it assumes a direct value. | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | =cut | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | 47 | ▶ | sub groupOption { | ||||||||||||||||||||||||||
|
Subroutine
groupOption: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||
| 642 | 47 | my $group = shift; | |||||||||||||||||||||||||||
| 643 | 47 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 644 | 47 | my $option = shift; | |||||||||||||||||||||||||||
| 645 | 47 | ▶ | unless (defined $option) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 646 | 0 | ▶ | warn "option not defined or specified" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 647 | return | ||||||||||||||||||||||||||||
| 648 | 0 | } | |||||||||||||||||||||||||||
| 649 | 47 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 650 | 45 | my $value = shift; | |||||||||||||||||||||||||||
| 651 | 45 | $groups{$group}->[1]->{$option} = $value; | |||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||
| 653 | 47 | return $groups{$group}->[1]->{$option} | |||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | =item B<groupOptionAll>(I<$groupname>) | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | Returns a list of all available options in $groupname. | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | =cut | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | 2 | ▶ | sub groupOptionAll { | ||||||||||||||||||||||||||
|
Subroutine
groupOptionAll: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 664 | 2 | my $group = shift; | |||||||||||||||||||||||||||
| 665 | 2 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 666 | 2 | my $opt = $groups{$group}->[1]; | |||||||||||||||||||||||||||
| 667 | 2 | return keys %$opt | |||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | =item B<groupOptionDelete>(I<$groupname>, I<$option>) | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | Removes $option from $groupname | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | =cut | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | 1 | ▶ | sub groupOptionDelete { | ||||||||||||||||||||||||||
|
Subroutine
groupOptionDelete: called CC=4 SCAR=17.2
Pod
documented
| |||||||||||||||||||||||||||||
| 678 | 1 | my $group = shift; | |||||||||||||||||||||||||||
| 679 | 1 | ▶ | if (groupExists($group)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 680 | 1 | my $option = shift; | |||||||||||||||||||||||||||
| 681 | 1 | ▶ | unless (defined $option) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 682 | 0 | ▶ | warn "option not defined or specified" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 683 | return | ||||||||||||||||||||||||||||
| 684 | 0 | } | |||||||||||||||||||||||||||
| 685 | 1 | delete $groups{$group}->[1]->{$option}; | |||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | =item B<gtkKey>(I<$key>, ?I<$value>?) | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | Sets and returns the value of $key in the Gtk hash | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | =cut | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | 93 | ▶ | sub gtkKey { | ||||||||||||||||||||||||||
|
Subroutine
gtkKey: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 696 | 93 | my ($key, $val) = @_; | |||||||||||||||||||||||||||
| 697 | 93 | ▶ | return undef if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 698 | 93 | ▶ | $gtksettings{$key} = $val if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 699 | 93 | ▶ | if (exists $gtksettings{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 700 | 66 | return $gtksettings{$key} | |||||||||||||||||||||||||||
| 701 | } else { | ||||||||||||||||||||||||||||
| 702 | 27 | ▶ | warn "item $key not present in gtk settings" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||
| 704 | return undef | ||||||||||||||||||||||||||||
| 705 | 27 | } | |||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | =item B<gtkKeyAll> | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | Returns a list of all available keys in the Gtk hash. | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | =cut | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | 0 | ▶ | sub gtkKeyAll { | ||||||||||||||||||||||||||
|
Subroutine
gtkKeyAll: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 714 | 0 | ▶ | return 0 if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 715 | 0 | return keys %gtksettings | |||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | =item B<gtkKeyDelete>(I<$key>) | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | Delets $key from the Gtk hash. | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | =cut | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | 1 | ▶ | sub gtkKeyDelete { | ||||||||||||||||||||||||||
|
Subroutine
gtkKeyDelete: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||
| 725 | 1 | my $key = shift; | |||||||||||||||||||||||||||
| 726 | 1 | ▶ | return 0 if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 727 | 1 | ▶ | if (exists $gtksettings{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 728 | 1 | delete $gtksettings{$key} | |||||||||||||||||||||||||||
| 729 | } else { | ||||||||||||||||||||||||||||
| 730 | 0 | ▶ | warn "item $key not present in gtk settings" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | =item B<hex2rgb>(I<$hex_color>) | ||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||
| 736 | Returns and array with the decimal values of red, green and blue. | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | =cut | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | 4 | ▶ | sub hex2rgb { | ||||||||||||||||||||||||||
|
Subroutine
hex2rgb: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 741 | 4 | my $hex = shift; | |||||||||||||||||||||||||||
| 742 | 4 | $hex =~ s/^(\#|Ox)//; | |||||||||||||||||||||||||||
| 743 | 4 | $_ = $hex; | |||||||||||||||||||||||||||
| 744 | 4 | my ($r, $g, $b) = m/(\w{2})(\w{2})(\w{2})/; | |||||||||||||||||||||||||||
| 745 | 4 | my @rgb = (); | |||||||||||||||||||||||||||
| 746 | 4 | $rgb[0] = CORE::hex($r); | |||||||||||||||||||||||||||
| 747 | 4 | $rgb[1] = CORE::hex($g); | |||||||||||||||||||||||||||
| 748 | 4 | $rgb[2] = CORE::hex($b); | |||||||||||||||||||||||||||
| 749 | return @rgb | ||||||||||||||||||||||||||||
| 750 | 4 | } | |||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||
| 752 | =item B<hexstring>(I<$num>) | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | Return the hexadecimal representation of $num in a two character string. | ||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||
| 756 | =cut | ||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||
| 758 | 13 | ▶ | sub hexstring { | ||||||||||||||||||||||||||
|
Subroutine
hexstring: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 759 | 13 | my $num = shift; | |||||||||||||||||||||||||||
| 760 | 13 | my $hex = substr(sprintf("0x%X", $num), 2); | |||||||||||||||||||||||||||
| 761 | 13 | ▶ | if (length($hex) < 2) { $hex = "0$hex" } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 762 | 13 | return $hex | |||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | =item B<initDefaults> | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | Initializes some sensible defaults. Also does a full reset and loads Gtk configuration files. | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | =cut | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | 2 | ▶ | sub initDefaults { | ||||||||||||||||||||||||||
|
Subroutine
initDefaults: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 772 | 2 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 773 | 2 | resetAll; | |||||||||||||||||||||||||||
| 774 | 2 | loadGtkInfo; | |||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||
| 776 | 2 | for (keys %mainoptions) { | |||||||||||||||||||||||||||
| 777 | 38 | groupOption('main', $_, $mainoptions{$_}) | |||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||
| 780 | #adding the icontheme option | ||||||||||||||||||||||||||||
| 781 | 2 | my $iconlib = gtkKey('gtk-icon-theme-name'); | |||||||||||||||||||||||||||
| 782 | 2 | ▶ | groupOption('main', 'iconTheme', $iconlib) if defined $iconlib; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||
| 784 | #adding the guidecolor option | ||||||||||||||||||||||||||||
| 785 | 2 | my $bg = gtkKey('content_view_bg'); | |||||||||||||||||||||||||||
| 786 | 2 | my $gc = alterColor($bg, 70); | |||||||||||||||||||||||||||
| 787 | 2 | groupOption('main', 'guideColor', $gc); | |||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | 2 | my @cw = @contentwidgets; | |||||||||||||||||||||||||||
| 790 | 2 | my %co = %contentoptions; | |||||||||||||||||||||||||||
| 791 | 2 | groupAdd('content', \@cw, \%co); | |||||||||||||||||||||||||||
| 792 | 2 | my @lw = @listwidgets; | |||||||||||||||||||||||||||
| 793 | 2 | my %lo = %listoptions; | |||||||||||||||||||||||||||
| 794 | 2 | groupAdd('list', \@lw, \%lo); | |||||||||||||||||||||||||||
| 795 | 2 | groupOption('list', 'highlightThickness', 1); | |||||||||||||||||||||||||||
| 796 | 2 | groupAdd('menu', ['Menu', 'NoteBook'], {borderWidth => 1}); | |||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||
| 799 | =item B<loadGtkInfo> | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | Empties the Gtk hash and (re)loads the Gtk configuration files. | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | =cut | ||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | 2 | ▶ | sub loadGtkInfo { | ||||||||||||||||||||||||||
|
Subroutine
loadGtkInfo: called CC=13 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||
| 806 | 2 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 807 | 2 | %gtksettings = (); | |||||||||||||||||||||||||||
| 808 | 2 | my $cf = $gtkpath . "colors.css"; | |||||||||||||||||||||||||||
| 809 | 2 | ▶ | if (open(OFILE, "<", $cf)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 810 | 2 | ▶ | while (<OFILE>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 811 | 140 | my $line = $_; | |||||||||||||||||||||||||||
| 812 | 140 | ▶ | if ($line =~ s/\@define-color\s//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 813 | 140 | ▶ | if ($line =~ /([^\s]+)\s([^;]+);/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 814 | 140 | my $key = $1; | |||||||||||||||||||||||||||
| 815 | 140 | my $color = $2; | |||||||||||||||||||||||||||
| 816 | 140 | ▶ | $color = convertColorCode($color) if $color =~ /^rgb\(/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 817 | 140 | $key = _truncate($key); | |||||||||||||||||||||||||||
| 818 | 140 | $gtksettings{$key} = $color | |||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||
| 822 | 2 | close OFILE | |||||||||||||||||||||||||||
| 823 | } else { | ||||||||||||||||||||||||||||
| 824 | 0 | ▶ | warn "cannot open Gtk colors.css" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 825 | 0 | $no_gtk = 1; | |||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | 2 | my $sf = $gtkpath . "settings.ini"; | |||||||||||||||||||||||||||
| 828 | 2 | ▶ | if (open(OFILE, "<", $sf)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 829 | 2 | ▶ | while (<OFILE>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 830 | 24 | my $line = $_; | |||||||||||||||||||||||||||
| 831 | 24 | ▶ | if ($line =~ /([^=]+)=([^\n]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 832 | 22 | $gtksettings{$1} = $2 | |||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||
| 835 | 2 | close OFILE; | |||||||||||||||||||||||||||
| 836 | 2 | ▶ | if (exists $gtksettings{'gtk-font-name'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 837 | 2 | my $font = decodeFont($gtksettings{'gtk-font-name'}); | |||||||||||||||||||||||||||
| 838 | 2 | $gtksettings{'gtk-font-name'} = $font; | |||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||
| 840 | } else { | ||||||||||||||||||||||||||||
| 841 | 0 | ▶ | warn "cannot open Gtk settings.ini" if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 842 | 0 | $no_gtk = 1; | |||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||
| 846 | =item B<platformPermitted> | ||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | Returns true if you are not on Windows or Mac. | ||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||
| 850 | =cut | ||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||
| 852 | 8 | ▶ | sub platformPermitted { | ||||||||||||||||||||||||||
|
Subroutine
platformPermitted: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||
| 853 | 8 | my $platform = $^O; | |||||||||||||||||||||||||||
| 854 | 8 | ▶ | return 0 if (($Config{osname} eq 'MSWin32') or ($Config{osname} eq 'darwin')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Tk::GtkSettings::Config{"osname"} eq "MSWin32" or $Tk::GtkSettings::Config{"osname"} eq "darwin"
MC/DC0%0/2
$Tk::GtkSettings::Config{"osname"} eq "MSWin32" or $Tk::GtkSettings::Config{"osname"} eq "darwin"
$Tk::GtkSettings::Config{"osname"} eq "MSWin32"
$Tk::GtkSettings::Config{"osname"} eq "darwin"
Truth table33%1/3
A or B
A= $Tk::GtkSettings::Config{"osname"} eq "MSWin32"B= $Tk::GtkSettings::Config{"osname"} eq "darwin"
| |||||||||||||||||||||||||||||
| 855 | 8 | return 1 | |||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | =item B<removeFromfile>(I<$file>) | ||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||
| 860 | Same as export2file($file, 1) | ||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | =cut | ||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | 0 | ▶ | sub removeFromfile { | ||||||||||||||||||||||||||
|
Subroutine
removeFromfile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 865 | 0 | my $f = shift; | |||||||||||||||||||||||||||
| 866 | 0 | export2file($f, 1); | |||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||
| 869 | =item B<removeFromXdefaults> | ||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||
| 871 | Same as export2Xdefaults(1) | ||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||
| 873 | =cut | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | 0 | ▶ | sub removeFromXdefaults { | ||||||||||||||||||||||||||
|
Subroutine
removeFromXdefaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 876 | 0 | export2file('~/.Xdefaults', 1); | |||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | =item B<removeFromXresources> | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | Same as export2Xresources(1) | ||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | =cut | ||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | 0 | ▶ | sub removeFromXresources { | ||||||||||||||||||||||||||
|
Subroutine
removeFromXresources: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 886 | 0 | export2file('~/.Xresouces', 1); | |||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | =item B<removeFromxrdb> | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | Removes all the settings previously defined from the xrdb database | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | =cut | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | 0 | ▶ | sub removeFromxrdb { | ||||||||||||||||||||||||||
|
Subroutine
removeFromxrdb: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 896 | 0 | ▶ | return unless platformPermitted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 897 | 0 | ▶ | return if $no_gtk; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if (open(OFILE, ">", $out_file)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 899 | 0 | print OFILE generateOutput; | |||||||||||||||||||||||||||
| 900 | 0 | close OFILE; | |||||||||||||||||||||||||||
| 901 | 0 | system "xrdb -remove $out_file"; | |||||||||||||||||||||||||||
| 902 | 0 | ▶ | unlink $out_file if $delete_output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | =item B<resetAll> | ||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||
| 908 | Removes all groups and options. The group 'main' will remain, but all its options are also deleted. | ||||||||||||||||||||||||||||
| 909 | This does not affect the Gtk hash. | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | =cut | ||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||
| 913 | 2 | ▶ | sub resetAll { | ||||||||||||||||||||||||||
|
Subroutine
resetAll: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 914 | 2 | %groups = ( | |||||||||||||||||||||||||||
| 915 | main => [[''], {}] | ||||||||||||||||||||||||||||
| 916 | ) | ||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | =item B<rgb2hex>(I<$red>, I<$green>, I<$blue>) | ||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | Converts the decimval values $red, $green and $blue into a hex color string. | ||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||
| 923 | =cut | ||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | 4 | ▶ | sub rgb2hex { | ||||||||||||||||||||||||||
|
Subroutine
rgb2hex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 926 | 4 | my ($red, $green, $blue) = @_; | |||||||||||||||||||||||||||
| 927 | 4 | my $r = hexstring($red); | |||||||||||||||||||||||||||
| 928 | 4 | my $g = hexstring($green); | |||||||||||||||||||||||||||
| 929 | 4 | my $b = hexstring($blue); | |||||||||||||||||||||||||||
| 930 | 4 | return "#$r$g$b" | |||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | 140 | ▶ | sub _truncate { | ||||||||||||||||||||||||||
|
Subroutine
_truncate: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 935 | 140 | my $name = shift; | |||||||||||||||||||||||||||
| 936 | 140 | for (@basegtkeys) { | |||||||||||||||||||||||||||
| 937 | 3734 | my $key = $_; | |||||||||||||||||||||||||||
| 938 | 3734 | ▶ | if (substr($name, 0, length($key)) eq $key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 939 | 140 | return $key | |||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||
| 942 | 0 | return $name | |||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||
| 945 | =back | ||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||
| 947 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | Copyright 2022 - 2023 by Hans Jeuken | ||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||
| 951 | Same as Perl | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | Hans Jeuken (jeuken dot hans at gmail dot com) | ||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | =head1 BUGS AND CAVEATS | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | If you find any bugs, please contact the author. | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | =head1 TODO | ||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||
| 963 | =cut | ||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | 1 | 1; | |||||||||||||||||||||||||||
| 967 | __END__ | ||||||||||||||||||||||||||||