GnuCash 7574033+
Loading...
Searching...
No Matches
GncGtkListUIItem Class Reference
Inheritance diagram for GncGtkListUIItem:
GncOptionGtkUIItem GncOptionUIItem

Public Member Functions

 GncGtkListUIItem (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 1157 of file gnc-option-gtk-ui.cpp.

Constructor & Destructor Documentation

◆ GncGtkListUIItem()

GncGtkListUIItem::GncGtkListUIItem ( GtkWidget * widget)
inline

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

1160 :
1161 GncOptionGtkUIItem{widget, GncOptionUIType::LIST} {}

Member Function Documentation

◆ set_option_from_ui_item()

void GncGtkListUIItem::set_option_from_ui_item ( GncOption & option)
inlineoverridevirtualnoexcept

Implements GncOptionUIItem.

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

1180 {
1181 auto widget{GTK_TREE_VIEW(get_widget())};
1182 auto selection{gtk_tree_view_get_selection(widget)};
1183 auto selected_rows{gtk_tree_selection_get_selected_rows(selection, nullptr)};
1184 GncMultichoiceOptionIndexVec vec;
1185 for (auto row = selected_rows; row; row = g_list_next(row))
1186 {
1187 auto path{static_cast<GtkTreePath*>(row->data)};
1188 auto indices{gtk_tree_path_get_indices(path)};
1189 vec.push_back(*indices);
1190 }
1191 g_list_free_full(selected_rows, (GDestroyNotify)gtk_tree_path_free);
1192 option.set_value(vec);
1193 }

◆ set_ui_item_from_option()

void GncGtkListUIItem::set_ui_item_from_option ( GncOption & option)
inlineoverridevirtualnoexcept

Implements GncOptionUIItem.

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

1164 {
1165 auto widget{GTK_TREE_VIEW(get_widget())};
1166 auto selection{gtk_tree_view_get_selection(widget)};
1167 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
1168 g_signal_handlers_block_by_func(selection, (gpointer)list_changed_cb, &option);
1169 gtk_tree_selection_unselect_all(selection);
1170 for (auto index : option.get_value<GncMultichoiceOptionIndexVec>())
1171 {
1172 auto path{gtk_tree_path_new_from_indices(index, -1)};
1173 gtk_tree_selection_select_path(selection, path);
1174 gtk_tree_path_free(path);
1175 }
1176 g_signal_handlers_unblock_by_func(selection, (gpointer)list_changed_cb, &option);
1177 }

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