顯示具有 GTK 標籤的文章。 顯示所有文章
顯示具有 GTK 標籤的文章。 顯示所有文章

2019/10/04

用 Bash 和 Zenity 指令更換 GTK3 佈景

【前言】


一、前一篇敘述了十六種 gtk3 的佈景,每次要更換還要自己改設定檔,頗為麻煩。因此特別用 bash 和 zenity 指令寫了一個很短的程式,以快速更換佈景,在此與大家分享。


二、這十六種佈景的 css 檔要先依前一篇所述的方法一一製作好(都只要改前面十九行即可),才能使用本程式。檔名以紅色為例,深淺分別是 red-dark.css 和 red-light.css。其餘顏色的英文是 orange、yellow、green、blue、indigo、purple、gray。


三、本文假設佈景目錄名是 Green,放在 $HOME/.themes/ 目錄中。Green 目錄裡是一 gtk-3.0 目錄,所有的 css 檔都放在這裡面。


四、完整的指令在【附錄】裡。本例將之存成 change-theme 檔,放在 $HOME/.local/bin/ 目錄中,且設為可執行檔。開啟虛擬終端機,輸入 change-theme 即可。當然 $PATH 需已包含此目錄。


本文更新於 WordPress:
Changing GTK 3 Themes with BASH and Zenity Commands

2019/09/29

GTK+3 Theme

【前言】


過去本網誌曾談到 gtk3 的設定,但都不完全。最近將 Adwaita 的設定 從頭到尾檢查一遍,去除不必要的,修改保留的,新增必要的,完成了深灰色的佈景。

完成後,除了 GTK3 Demo 和 GTK3 Widget Factory(註一)以外,又測試過二十餘個 gtk3 應用程式,大致都沒問題。(註一:這兩個程式來自 gtk-3-examples 程式包。)

以下範例是用 Synaptic 程式,而完整的設定內容在【附錄】裡。


本文更新於 WordPress:
GTK 3 Themes

2019/09/10

GTK+ 3 CSS Nodes

【前言】


設定 GTK+ 3 的樣式時,一定會用到 CSS nodes 和 style properties。但這些資料分散在各個 widget 的說明中,不利查詢。如果集中到一個檔案裡,會比較方便。本文敘述收集 nodes 的方法,另一篇敘述收集 style properties 的方法

來源資料是官網的 "GTK+ 3 Reference Manual",目前的版本是 3.24.11。

收集的方法是用常見的 bash 和 Linux 指令,作業系統是 Debian 10。

本文更新於 WordPress:
All GTK 3 CSS Nodes

GTK+ 3 Style Properties

【前言】


設定 GTK+ 3 的樣式時,一定會用到 CSS nodes 和 style properties。但這些資料分散在各個 widget 的說明中,不利查詢。如果集中到一個檔案裡,會比較方便。本文敘述收集 style properties 的方法,另一篇敘述收集 CSS nodes 的方法

來源資料是官網的 "GTK+ 3 Reference Manual",目前的版本是 3.24.11。

收集的方法是用常見的 bash 和 Linux 指令,作業系統是 Debian 10。

輸出的資料不含過時不用的 (deprecated) 項目。

本文更新於 WordPress:
All GTK 3 Style Properties

2017/11/02

GTK2 深灰色佈景

GTK2 使用版本:GTK 2.24。

範例:Spacefm


【GTK2 設定檔內容】


.gtkrc-2.0 檔的位置在 ~ 目錄。

# GtkSettings (見官方 "Reference Manual" II; 小括號內是預設值)

gtk-color-scheme = "gray_1: #101010"
gtk-color-scheme = "gray_2: #202020"
gtk-color-scheme = "gray_3: #303030"
gtk-color-scheme = "gray_4: #404040"
gtk-color-scheme = "gray_5: #505050"
gtk-color-scheme = "gray_6: #606060"
gtk-color-scheme = "gray_7: #707070"
gtk-color-scheme = "gray_8: #808080"
gtk-color-scheme = "gray_9: #909090"
gtk-color-scheme = "gray_a: #a0a0a0"
gtk-color-scheme = "gray_b: #b0b0b0"
gtk-color-scheme = "gray_c: #c0c0c0"
gtk-color-scheme = "gray_d: #d0d0d0"
gtk-color-scheme = "gray_e: #e0e0e0"
gtk-color-scheme = "gray_f: #f0f0f0"
gtk-color-scheme = "gray_g: #ffffff"
# A palette of named colors for use in themes ("")
gtk-color-scheme = "info_fg_color: lightgray"
gtk-color-scheme = "info_bg_color: #004000"
gtk-color-scheme = "warning_fg_color: lightgray"
gtk-color-scheme = "warning_bg_color: #804000"
gtk-color-scheme = "question_fg_color: lightgray"
gtk-color-scheme = "question_bg_color: #808000"
gtk-color-scheme = "error_fg_color: lightgray"
gtk-color-scheme = "error_bg_color: #800000"

#gtk-cursor-blink = TRUE
# Whether the cursor should blink (TRUE)

gtk-cursor-blink-time = 1000
# Length of the cursor blink cycle, in milliseconds (1200)

#gtk-cursor-blink-timeout = 2147483647
# Time after which the cursor stops blinking, in seconds (2147483647)

#gtk-cursor-theme-name = NULL
# Name of the cursor theme to use (NULL to use the default theme)

#gtk-cursor-theme-size = 0
# Size to use for cursors (0 ~ 128, 0 to use the default size)

gtk-fallback-icon-theme = "GNOME"
# Name of a icon theme to fall back to (NULL)

#gtk-font-name = "HanaMinA 13"
gtk-font-name = "AR PL UMing TW 13"
# Name of default font to use ("Sans 10")

gtk-icon-sizes = "gtk-menu=16,16:gtk-button=20,20:gtk-small-toolbar=18,18:gtk-large-toolbar=32,32:gtk-dnd=40,40:gtk-dialog=48,48"
# A list of icon sizes (NULL)

gtk-icon-theme-name = "Humanity"
# Name of icon theme to use (See index.theme file; "Hicolor")

gtk-menu-bar-accel = ""
# Keybinding to activate the menu bar ("F10")

gtk-menu-popdown-delay = 0
# The time before hiding a submenu when the pointer is moving towards the submenu (1000)

gtk-menu-popup-delay = 0
# Minimum time the pointer must stay over a menu item before the submenu appear (225)

#gtk-theme-name = "Raleigh"
# Name of theme RC file to load (Dir name, "Raleigh")

gtk-toolbar-icon-size = GTK_ICON_SIZE_SMALL_TOOLBAR
# The size of icons in default toolbars (GTK_ICON_SIZE_LARGE_TOOLBAR)

gtk-toolbar-style = GTK_TOOLBAR_ICONS
# Whether default toolbars have text only, text and icons, icons only, etc. (GTK_TOOLBAR_BOTH)

gtk-tooltip-timeout = 0
# Time, in milliseconds, after which a tooltip could appear if the cursor is hovering on top of a widget (500)

# Widgets and Objects

style "default" {
  fg[NORMAL] = @gray_f
  bg[NORMAL] = @gray_3
  text[NORMAL] = @gray_e
  base[NORMAL] = @gray_2

  fg[PRELIGHT] = @gray_f
  bg[PRELIGHT] = @gray_5
  text[PRELIGHT] = @gray_e
  base[PRELIGHT] = @gray_4

  fg[ACTIVE] = @gray_f
  bg[ACTIVE] = @gray_4
  text[ACTIVE] = @gray_f
  base[ACTIVE] = @gray_5

  fg[SELECTED] = @gray_g
  bg[SELECTED] = @gray_6
  text[SELECTED] = @gray_f
  base[SELECTED] = @gray_5

  fg[INSENSITIVE] = @gray_8
  bg[INSENSITIVE] = @gray_1
  text[INSENSITIVE] = @gray_7
  base[INSENSITIVE] = @gray_1

  xthickness = 1
  ythickness = 1

# A widget that creates a signal when clicked on
  GtkButton::child-displacement-x = 2
  # How far in the x direction to move the child when the button is depressed (0)
  GtkButton::child-displacement-y = 2
  # How far in the y direction to move the child when the button is depressed (0)
  GtkButton::default-border = { 2, 1, 2, 1 }
  # Extra space to add for GTK_CAN_DEFAULT buttons ({ 1, 1, 1, 1 })
#  GtkButton::default-outside-border = { 0, 0, 0, 0 }
  # Extra space to add for GTK_CAN_DEFAULT buttons that is always drawn outside the border ({ 0, 0, 0, 0 })
#  GtkButton::displace-focus = FALSE
  # Whether the child_displacement_x/_y properties should also affect the focus rectangle (FALSE)
#  GtkButton::image-spacing = 2
  # Spacing in pixels between the image and label (2)
#  GtkButton::inner-border = { 1, 1, 1, 1 }
  # Border between button edges and child ({ 1, 1, 1, 1 })

# Create widgets with a discrete toggle button
  GtkCheckButton::indicator-size = 18
  # Size of check or radio indicator (13)
  GtkCheckButton::indicator-spacing = 4
  # Spacing around check or radio indicator (2)

# A widget used to choose from a list of items
#  GtkComboBox::appears-as-list = FALSE
  # Whether dropdowns should look like lists rather than menus (FALSE)
#  GtkComboBox::arrow-size = 15
  # Sets the minimum size of the arrow in the combo box. Note that the arrow size is coupled to the font size, so in case a larger font is used, the arrow will be larger than set by arrow size. (15)
  GtkComboBox::shadow-type = GTK_SHADOW_OUT
  # Which kind of shadow to draw around the combo box (GTK_SHADOW_NONE)

# Create popup windows
  GtkDialog::action-area-border = 3
  # Width of border around the button area at the bottom of the dialog (5)
  GtkDialog::button-spacing = 3
  # Spacing between buttons (6)
  GtkDialog::content-area-border = 3
  # Width of border around the main dialog area (2)
  GtkDialog::content-area-spacing = 3
  # Spacing used between elements of the content area (0)

# A single line text entry field
#  GtkEntry::inner-border = {2, 2, 2, 2}
  # Border between the text and the frame ({2, 2, 2, 2})

# A menu widget
  GtkMenu::arrow-scaling = 1
  # Arbitrary constant to scale down the size of the scroll arrow (0.7)
  GtkMenu::horizontal-offset = 0
  # When the menu is a submenu, position it this number of pixels offset horizontally (-2)
  GtkMenu::horizontal-padding = 2
  # Extra space at the left and right edges of the menu (0)
  GtkMenu::vertical-offset = 2
  # When the menu is a submenu, position it this number of pixels offset vertically (0)
  GtkMenu::vertical-padding = 2
  # Extra space at the top and bottom of the menu (1)

# A subclass widget for GtkMenuShell which holds GtkMenuItem widgets
  GtkMenuBar::internal-padding = 0
  # Amount of border space between the menubar shadow and the menu items (1)

# A menu entry
  GtkMenuItem::arrow-scaling = 0.6
  # Arrow size, relative to the menu item's font size (0 ~ 2, 0.8)
  GtkMenuItem::arrow-spacing = 0
  # Space between label and arrow (10)
#  GtkMenuItem::horizontal-padding = 3
  # Padding to left and right of the menu item (3)
  GtkMenuItem::selected-shadow-type = GTK_SHADOW_ETCHED_OUT
  # Shadow type when item is selected (GTK_SHADOW_NONE)
#  GtkMenuItem::toggle-spacing = 5
  # Space between icon and label (5)
  GtkMenuItem::width-chars = 0
  # The minimum desired width of the menu item in characters (12)

# A widget with two adjustable panes
  GtkPaned::handle-size = 8
  # Width of handle (5)

# Base class for widgets which visualize an adjustment
  GtkRange::arrow-displacement-x = 2
  # How far in the x direction to move the arrow when the button is depressed (0)
  GtkRange::arrow-displacement-y = 2
  # How far in the y direction to move the arrow when the button is depressed (0)
  GtkRange::arrow-scaling = 0.8
  # The arrow size proportion relative to the scroll button size (0.5)
  GtkRange::slider-width = 10
  # Width of scrollbar or scale thumb (14)
  GtkRange::stepper-size = 16
  # Length of step buttons at ends (14)
#  GtkRange::stepper-spacing = 0
  # Spacing between the stepper buttons and thumb (0)
  GtkRange::trough-border = 2
  # Spacing between thumb/steppers and outer trough bevel (1)
  GtkRange::trough-under-steppers = 0
  # Whether to draw the trough across the full length of the range or to exclude the steppers and their spacing (TRUE, 用 FALSE 無效)

# A slider control used to select numeric values (Child of GtkRange)
  GtkScale::slider-length = 24
  # Length of scale's slider (31)
  GtkScale::value-spacing = 5
  # Space between value text and the slider/trough area (2)

# A scrollbar (Child of GtkRange)
  GtkScrollbar::has-backward-stepper = 0
  # Display the standard backward arrow button (1, TRUE/FALSE don't work)
  GtkScrollbar::has-forward-stepper = 1
  # Display the standard forward arrow button (1, TRUE/FALSE don't work)
  GtkScrollbar::has-secondary-backward-stepper = 1
  # Display a second backward arrow button on the opposite end of the scrollbar (0, TRUE/FALSE don't work)
  GtkScrollbar::has-secondary-forward-stepper = 0
  # Display a second forward arrow button on the opposite end of the scrollbar (0, TRUE/FALSE don't work)
  GtkScrollbar::min-slider-length = 14
  # Minimum length of scrollbar slider (21, GTK3 deprecated)

# Adds scrollbars to its child widget
  GtkScrolledWindow::scrollbar-spacing = 0
  # Number of pixels between the scrollbars and the scrolled window (3)

# A toolbar
  GtkToolbar::internal-padding = 2
  # Amount of border space between the toolbar shadow and the buttons (0)
  GtkToolbar::space-size = 8
  # Size of spacers (12)

# A widget for displaying both trees and lists
  GtkTreeView::even-row-color = @gray_3
  # Color to use for even rows
  GtkTreeView::expander-size = 16
  # Size of the expander arrow (12)
  GtkTreeView::horizontal-separator = 0
  # Horizontal space between cells (Must be an even number, 2)
  GtkTreeView::odd-row-color = @gray_2
  # Color to use for odd rows
  GtkTreeView::tree-line-pattern = "\000"
  # Dash pattern used to draw the tree view lines (\001\001)
  GtkTreeView::tree-line-width = 2
  # Width, in pixels, of the tree view lines (1)
  GtkTreeView::vertical-separator = 0
  # Vertical space between cells (Must be an even number, 2)

# Base class for all widgets
  GtkWidget::cursor-aspect-ratio = 0.08
  # Aspect ratio with which to draw insertion cursor (0.04)
  GtkWidget::cursor-color = "#ff0000"
  # Color with which to draw insertion cursor
  GtkWidget::focus-line-pattern = "\002"
  # Dash pattern used to draw the focus indicator (\001\001)
#  GtkWidget::focus-line-width = 1
  # Width, in pixels, of the focus indicator line (1)
  GtkWidget::focus-padding = 0
  # Width, in pixels, between focus indicator and the widget 'box' (1)
#  GtkWidget::interior-focus = TRUE
  # Whether to draw the focus indicator inside widgets (TRUE)
  GtkWidget::link-color = "#ff8040"
  # Color of unvisited links
#  GtkWidget::scroll-arrow-hlength = 16
  # Length of horizontal scroll arrows (16)
#  GtkWidget::scroll-arrow-vlength = 16
  # Length of vertical scroll arrows (16)
  GtkWidget::separator-height = 1
  # Height of separators (This property only takes effect if “wide-separators” is TRUE, 0)
  GtkWidget::separator-width = 1
  # Width of separators (This property only takes effect if “wide-separators” is TRUE, 0)
#  GtkWidget::tooltip-alpha = 255
  # Opacity of widget tooltips (255)
  GtkWidget::tooltip-radius = 3
  # Radius of widget tooltips (0)
  GtkWidget::visited-link-color = "#ff80ff"
  # Color of visited links
  GtkWidget::wide-separators = 1
  # Whether separators have configurable width and should be drawn using a box instead of a line (FALSE)
}

style "button" {
  bg[NORMAL] = @gray_4
  bg[PRELIGHT] = @gray_6
}

style "notebook" {
  bg[NORMAL] = @gray_4
  bg[ACTIVE] = @gray_2

#  GtkNotebook::arrow-spacing = 0
  # Spacing between the scroll arrows and the tabs (0)
  GtkNotebook::has-backward-stepper = 0
  # Whether the standard backward arrow button is displayed (TRUE, 用 FALSE 無效)
#  GtkNotebook::has-forward-stepper = TRUE
  # Whether the standard forward arrow button is displayed (TRUE)
  GtkNotebook::has-secondary-backward-stepper = 1
  # Whether a second backward arrow button is displayed on the opposite end of the tab area (FALSE, 用 TRUE 無效)
#  GtkNotebook::has-secondary-forward-stepper = FALSE
  # Whether a second forward arrow button is displayed on the opposite end of the tab area (FALSE)
  GtkNotebook::tab-overlap = -2
  # Size of tab overlap area (2)
}

style "toolbar" {
  bg[NORMAL] = @gray_6
}

style "tooltips" {
  xthickness = 6
  fg[NORMAL] = @gray_1
  bg[NORMAL] = @gray_a
}

class "GtkToolbar" style "toolbar"
class "GtkWidget" style "default"
widget_class "*<gtkbutton>" style "button"
widget_class "*<gtknotebook>" style "notebook"
widget "gtk-tooltip*" style "tooltips"