Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Panel Plugins
xfce4-docklike-plugin
Commits
949ab0e1
Commit
949ab0e1
authored
Nov 27, 2021
by
Artyom Zorin
Committed by
David Keogh
Nov 27, 2021
Browse files
Add option to get the indicator color automatically from the Gtk theme foreground color
parent
a7fd43ce
Pipeline
#12294
passed with stages
in 2 minutes and 20 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Group.cpp
View file @
949ab0e1
...
...
@@ -294,21 +294,41 @@ void Group::onDraw(cairo_t* cr)
{
int
w
=
gtk_widget_get_allocated_width
(
mButton
);
int
h
=
gtk_widget_get_allocated_height
(
mButton
);
double
rgba
[
4
];
if
(
mSFocus
)
if
(
Settings
::
indicatorColorFromTheme
)
{
rgba
[
0
]
=
(
*
Settings
::
indicatorColor
).
red
;
rgba
[
1
]
=
(
*
Settings
::
indicatorColor
).
green
;
rgba
[
2
]
=
(
*
Settings
::
indicatorColor
).
blue
;
rgba
[
3
]
=
(
*
Settings
::
indicatorColor
).
alpha
;
GtkWidget
*
menu
=
gtk_menu_new
();
GtkStyleContext
*
sc
=
gtk_widget_get_style_context
(
menu
);
GValue
gv
=
G_VALUE_INIT
;
gtk_style_context_get_property
(
sc
,
"color"
,
GTK_STATE_FLAG_NORMAL
,
&
gv
);
GdkRGBA
*
indicatorColor
=
(
GdkRGBA
*
)
g_value_get_boxed
(
&
gv
);
gtk_widget_destroy
(
menu
);
rgba
[
0
]
=
(
*
indicatorColor
).
red
;
rgba
[
1
]
=
(
*
indicatorColor
).
green
;
rgba
[
2
]
=
(
*
indicatorColor
).
blue
;
rgba
[
3
]
=
(
*
indicatorColor
).
alpha
;
}
else
{
rgba
[
0
]
=
(
*
Settings
::
inactiveColor
).
red
;
rgba
[
1
]
=
(
*
Settings
::
inactiveColor
).
green
;
rgba
[
2
]
=
(
*
Settings
::
inactiveColor
).
blue
;
rgba
[
3
]
=
(
*
Settings
::
inactiveColor
).
alpha
;
else
{
if
(
mSFocus
)
{
rgba
[
0
]
=
(
*
Settings
::
indicatorColor
).
red
;
rgba
[
1
]
=
(
*
Settings
::
indicatorColor
).
green
;
rgba
[
2
]
=
(
*
Settings
::
indicatorColor
).
blue
;
rgba
[
3
]
=
(
*
Settings
::
indicatorColor
).
alpha
;
}
else
{
rgba
[
0
]
=
(
*
Settings
::
inactiveColor
).
red
;
rgba
[
1
]
=
(
*
Settings
::
inactiveColor
).
green
;
rgba
[
2
]
=
(
*
Settings
::
inactiveColor
).
blue
;
rgba
[
3
]
=
(
*
Settings
::
inactiveColor
).
alpha
;
}
}
const
float
BAR_WEIGHT
=
0.935
;
...
...
src/Settings.cpp
View file @
949ab0e1
...
...
@@ -22,6 +22,7 @@ namespace Settings
State
<
int
>
indicatorOrientation
;
State
<
int
>
indicatorStyle
;
State
<
bool
>
indicatorColorFromTheme
;
State
<
GdkRGBA
*>
indicatorColor
;
State
<
GdkRGBA
*>
inactiveColor
;
...
...
@@ -99,6 +100,15 @@ namespace Settings
Dock
::
drawGroups
();
});
indicatorColorFromTheme
.
setup
(
g_key_file_get_boolean
(
mFile
,
"user"
,
"indicatorColorFromTheme"
,
NULL
),
[](
bool
indicatorColorFromTheme
)
->
void
{
g_key_file_set_boolean
(
mFile
,
"user"
,
"indicatorColorFromTheme"
,
indicatorColorFromTheme
);
saveFile
();
Theme
::
load
();
Dock
::
drawGroups
();
});
gchar
*
colorString
=
g_key_file_get_string
(
mFile
,
"user"
,
"indicatorColor"
,
NULL
);
GdkRGBA
*
color
=
(
GdkRGBA
*
)
malloc
(
sizeof
(
GdkRGBA
));
...
...
src/Settings.hpp
View file @
949ab0e1
...
...
@@ -41,6 +41,7 @@ namespace Settings
extern
State
<
int
>
indicatorOrientation
;
extern
State
<
int
>
indicatorStyle
;
extern
State
<
bool
>
indicatorColorFromTheme
;
extern
State
<
GdkRGBA
*>
indicatorColor
;
extern
State
<
GdkRGBA
*>
inactiveColor
;
...
...
src/SettingsDialog.cpp
View file @
949ab0e1
...
...
@@ -111,6 +111,9 @@ namespace SettingsDialog
}),
dialog
);
GObject
*
customIndicatorColors
=
gtk_builder_get_object
(
builder
,
"g_customIndicatorColors"
);
gtk_widget_set_sensitive
(
GTK_WIDGET
(
customIndicatorColors
),
!
Settings
::
indicatorColorFromTheme
);
GObject
*
indicatorColor
=
gtk_builder_get_object
(
builder
,
"cp_indicatorColor"
);
gtk_color_chooser_set_rgba
(
GTK_COLOR_CHOOSER
(
indicatorColor
),
Settings
::
indicatorColor
);
g_signal_connect
(
indicatorColor
,
"color-set"
,
...
...
@@ -133,6 +136,15 @@ namespace SettingsDialog
}),
dialog
);
GObject
*
indicatorColorFromTheme
=
gtk_builder_get_object
(
builder
,
"c_indicatorColorFromTheme"
);
gtk_toggle_button_set_active
(
GTK_TOGGLE_BUTTON
(
indicatorColorFromTheme
),
Settings
::
indicatorColorFromTheme
);
g_signal_connect
(
indicatorColorFromTheme
,
"toggled"
,
G_CALLBACK
(
+
[](
GtkToggleButton
*
indicatorColorFromTheme
,
GtkWidget
*
customIndicatorColors
)
{
Settings
::
indicatorColorFromTheme
.
set
(
gtk_toggle_button_get_active
(
indicatorColorFromTheme
));
gtk_widget_set_sensitive
(
GTK_WIDGET
(
customIndicatorColors
),
!
Settings
::
indicatorColorFromTheme
);
}),
customIndicatorColors
);
// =====================================================================
GObject
*
iconSize
=
gtk_builder_get_object
(
builder
,
"e_iconSize"
);
...
...
src/Theme.cpp
View file @
949ab0e1
...
...
@@ -68,6 +68,14 @@ std::string Theme::get_theme_colors()
std
::
string
indicatorColor
=
gdk_rgba_to_string
(
Settings
::
indicatorColor
);
std
::
string
inactiveColor
=
gdk_rgba_to_string
(
Settings
::
inactiveColor
);
if
(
Settings
::
indicatorColorFromTheme
)
{
gv
=
G_VALUE_INIT
;
gtk_style_context_get_property
(
sc
,
"color"
,
GTK_STATE_FLAG_NORMAL
,
&
gv
);
indicatorColor
=
gdk_rgba_to_string
((
GdkRGBA
*
)
g_value_get_boxed
(
&
gv
));
inactiveColor
=
gdk_rgba_to_string
((
GdkRGBA
*
)
g_value_get_boxed
(
&
gv
));
}
gtk_widget_destroy
(
menu
);
g_value_unset
(
&
gv
);
...
...
src/_dialogs.xml
View file @
949ab0e1
...
...
@@ -264,11 +264,14 @@
</packing>
</child>
<child>
<object
class=
"GtkLabel"
>
<object
class=
"GtkCheckButton"
id=
"c_indicatorColorFromTheme"
>
<property
name=
"label"
translatable=
"yes"
>
Get indicator color from theme
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"label"
translatable=
"yes"
>
Active indicator:
</property>
<property
name=
"use_underline"
>
True
</property>
<property
name=
"draw_indicator"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
...
...
@@ -276,15 +279,65 @@
</packing>
</child>
<child>
<object
class=
"Gtk
ColorButton"
id=
"cp_i
ndicatorColor"
>
<object
class=
"Gtk
Grid"
id=
"g_customI
ndicatorColor
s
"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_alpha"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"margin_left"
>
6
</property>
<property
name=
"margin_right"
>
6
</property>
<property
name=
"row_spacing"
>
6
</property>
<property
name=
"column_spacing"
>
12
</property>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"label"
translatable=
"yes"
>
Active indicator:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkColorButton"
id=
"cp_indicatorColor"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_alpha"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"label"
translatable=
"yes"
>
Inactive indicator:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkColorButton"
id=
"cp_inactiveColor"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_alpha"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
1
</property>
</packing>
</child>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
2
</property>
<property
name=
"top_attach"
>
3
</property>
</packing>
</child>
<child>
...
...
@@ -327,30 +380,6 @@
<property
name=
"top_attach"
>
4
</property>
</packing>
</child>
<child>
<object
class=
"GtkColorButton"
id=
"cp_inactiveColor"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_alpha"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
3
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"halign"
>
start
</property>
<property
name=
"label"
translatable=
"yes"
>
Inactive indicator:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
3
</property>
</packing>
</child>
</object>
</child>
<child
type=
"label"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment