GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions
GncGtkColorUIItem Class Reference
Inheritance diagram for GncGtkColorUIItem:
GncOptionGtkUIItem GncOptionUIItem

Public Member Functions

 GncGtkColorUIItem (GtkWidget *widget)
 
void set_ui_item_from_option (GncOption &option) noexcept override
 
void set_option_from_ui_item (GncOption &option) noexcept override
 
- Public Member Functions inherited from GncOptionGtkUIItem
 GncOptionGtkUIItem (GtkWidget *widget, GncOptionUIType type)
 
 GncOptionGtkUIItem (const GncOptionGtkUIItem &item)
 
 GncOptionGtkUIItem (GncOptionGtkUIItem &&)=default
 
virtual void set_selectable (bool) const noexcept override
 Control wether the widget is sensitive.
 
void clear_ui_item () override
 Clear the data from the widget.
 
void set_widget (GtkWidget *widget)
 
virtual GtkWidget * get_widget () const
 
virtual SCM get_widget_scm_value (const GncOption &) const
 
- Public Member Functions inherited from GncOptionUIItem
 GncOptionUIItem (GncOptionUIType type)
 
GncOptionUIType get_ui_type () const noexcept
 
virtual void set_dirty (bool status) noexcept
 
virtual bool get_dirty () const noexcept
 

Detailed Description

Definition at line 1361 of file gnc-option-gtk-ui.cpp.

Constructor & Destructor Documentation

◆ GncGtkColorUIItem()

GncGtkColorUIItem::GncGtkColorUIItem ( GtkWidget *  widget)
inline

Definition at line 1364 of file gnc-option-gtk-ui.cpp.

1364 :
1365 GncOptionGtkUIItem{widget, GncOptionUIType::COLOR} {}
class GncOptionGtkUIItem Gtk-specific Interface class for Option Widget

Member Function Documentation

◆ set_option_from_ui_item()

void GncGtkColorUIItem::set_option_from_ui_item ( GncOption option)
inlineoverridevirtualnoexcept

Implements GncOptionUIItem.

Definition at line 1382 of file gnc-option-gtk-ui.cpp.

1383 {
1384 GdkRGBA color;
1385 auto color_button = GTK_COLOR_CHOOSER(get_widget());
1386 gtk_color_chooser_get_rgba(color_button, &color);
1387 auto rgba_str = g_strdup_printf("%2x%2x%2x%2x",
1388 (uint8_t)(color.red * 255),
1389 (uint8_t)(color.green * 255),
1390 (uint8_t)(color.blue * 255),
1391 (uint8_t)(color.alpha * 255));
1392 auto rgb_str = g_strdup_printf("%2x%2x%2x",
1393 (uint8_t)(color.red * 255),
1394 (uint8_t)(color.green * 255),
1395 (uint8_t)(color.blue * 255));
1396// sample-report.scm uses an old HTML4 attribute that doesn't understand alpha.
1397 option.set_value(std::string{rgb_str});
1398 g_free(rgba_str);
1399 g_free(rgb_str);
1400 }

◆ set_ui_item_from_option()

void GncGtkColorUIItem::set_ui_item_from_option ( GncOption option)
inlineoverridevirtualnoexcept

Implements GncOptionUIItem.

Definition at line 1366 of file gnc-option-gtk-ui.cpp.

1367 {
1368 GdkRGBA color;
1369 /* gdk_rgba_parse uses pango_color_parse for hex color strings instead
1370 * of pango_color_parse_with_alpha and that fails if the string length
1371 * is 8.
1372 */
1373 auto value{option.get_value<std::string>().substr(0,6)};
1374 auto rgba_str{g_strdup_printf("#%s", value.c_str())};
1375 if (gdk_rgba_parse(&color, rgba_str))
1376 {
1377 auto color_button = GTK_COLOR_CHOOSER(get_widget());
1378 gtk_color_chooser_set_rgba(color_button, &color);
1379 }
1380 g_free(rgba_str);
1381 }

The documentation for this class was generated from the following file: