Skip to content

Commit

Permalink
[lib/hui] fixes for old versions of gtk4
Browse files Browse the repository at this point in the history
  • Loading branch information
momentarylapse committed Dec 1, 2024
1 parent 5fd5a78 commit 1b6c047
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/lib/hui/Controls/ControlEditGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace hui
{

#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
void set_list_cell(GtkListStore *store, GtkTreeIter &iter, int column, const string &str);
#endif

Expand Down Expand Up @@ -62,7 +62,7 @@ void ControlEdit::__reset() {
}

void ControlEdit::completion_add(const string &text) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkEntryCompletion *comp = gtk_entry_get_completion(GTK_ENTRY(widget));
if (!comp){
comp = gtk_entry_completion_new();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hui/Controls/ControlTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ControlTreeView : public Control {
int row_target;

string effective_format;
#if GTK_CHECK_VERSION(4,10,0)
#if GTK_CHECK_VERSION(4,0,0)
GListStore *store;
GtkTreeListModel *tree_model;
GtkSelectionModel *selection_model;
Expand Down
32 changes: 16 additions & 16 deletions src/lib/hui/Controls/ControlTreeViewGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace hui
string make_format_string_useful(const string &_format, int size);


#if GTK_CHECK_VERSION(4,10,0)
#if GTK_CHECK_VERSION(4,0,0)
void on_gtk_list_activate(GtkWidget* widget, guint pos, ControlListView* self);
void on_gtk_list_gesture_click_pressed(GtkGestureClick *gesture, int n_press, double x, double y, ControlListView *c);
void gtk_list_item_widget_enter_cb(GtkEventControllerMotion *controller, double x, double y, ControlListView::ItemMapper *h);
Expand All @@ -38,7 +38,7 @@ void on_gtk_column_view_activate(GtkColumnView* self, guint position, gpointer u
void on_gtk_selection_model_selection_changed(GtkSelectionModel* self, guint position, guint n_items, gpointer user_data);
#endif

#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
Array<GType> CreateTypeList(const string &_format);


Expand Down Expand Up @@ -160,7 +160,7 @@ ControlTreeView::ControlTreeView(const string &title, const string &id, Panel *p
#endif


#if GTK_CHECK_VERSION(4,10,0)
#if GTK_CHECK_VERSION(4,0,0)
effective_format = make_format_string_useful(fmt, parts.num);
msg_write(effective_format);

Expand Down Expand Up @@ -279,7 +279,7 @@ void ControlTreeView::__set_string(const string &str) {
__add_string(str);
}

#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
void set_tree_cell(GtkTreeStore *store, GtkTreeIter &_iter, int column, const string &str) {
GtkTreeIter iter = _iter;
GType type = gtk_tree_model_get_column_type(GTK_TREE_MODEL(store), column);
Expand Down Expand Up @@ -337,7 +337,7 @@ void ControlTreeView::__add_string(const string& _str) {
}

void ControlTreeView::__set_int(int i) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
if (i >= 0) {
gtk_tree_selection_select_iter(sel, &_item_[i]);
Expand All @@ -351,7 +351,7 @@ void ControlTreeView::__set_int(int i) {
}

int ControlTreeView::get_int() {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
for (int j=0;j<_item_.num;j++)
if (gtk_tree_selection_iter_is_selected(sel, &_item_[j]))
Expand All @@ -361,7 +361,7 @@ int ControlTreeView::get_int() {
}

void ControlTreeView::__add_child_string(int parent_row, const string& str) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeIter iter;
auto parts = split_title(str);
GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
Expand All @@ -373,7 +373,7 @@ void ControlTreeView::__add_child_string(int parent_row, const string& str) {
}

void ControlTreeView::__change_string(int row, const string& str) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
auto parts = split_title(str);
GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
/*for (int j=0;j<PartString.num;j++)
Expand All @@ -385,7 +385,7 @@ void ControlTreeView::__change_string(int row, const string& str) {
}

void ControlTreeView::__remove_string(int row) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
if ((row < 0) or (row >= _item_.num))
return;
GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
Expand All @@ -397,7 +397,7 @@ void ControlTreeView::__remove_string(int row) {
}

string ControlTreeView::get_cell(int row, int column) {
#if GTK_CHECK_VERSION(4,10,0)
#if GTK_CHECK_VERSION(4,0,0)
return "";
#else
if ((row < 0) or (row >= _item_.num))
Expand All @@ -408,7 +408,7 @@ string ControlTreeView::get_cell(int row, int column) {
}

void ControlTreeView::__set_cell(int row, int column, const string& str) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
if ((row < 0) or (row >= _item_.num))
return;
GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
Expand All @@ -419,7 +419,7 @@ void ControlTreeView::__set_cell(int row, int column, const string& str) {

Array<int> ControlTreeView::get_selection() {
Array<int> sel;
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeSelection *s = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
gtk_tree_selection_set_mode(s, GTK_SELECTION_MULTIPLE);
for (int j=0;j<_item_.num;j++)
Expand All @@ -431,7 +431,7 @@ Array<int> ControlTreeView::get_selection() {
}

void ControlTreeView::__set_selection(const Array<int>& sel) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeSelection *s = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
gtk_tree_selection_set_mode(s, GTK_SELECTION_MULTIPLE);
gtk_tree_selection_unselect_all(s);
Expand All @@ -441,15 +441,15 @@ void ControlTreeView::__set_selection(const Array<int>& sel) {
}

void ControlTreeView::__reset() {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
gtk_tree_store_clear(store);
_item_.clear();
#endif
}

void ControlTreeView::expand(int row, bool expand) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
if (row < 0) {
// expand all
if (expand)
Expand All @@ -472,7 +472,7 @@ bool ControlTreeView::is_expanded(int row) {
}

void ControlTreeView::__set_option(const string &op, const string &value) {
#if !GTK_CHECK_VERSION(4,10,0)
#if !GTK_CHECK_VERSION(4,0,0)
if (op == "nobar")
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(widget), false);
else if (op == "bar")
Expand Down

0 comments on commit 1b6c047

Please sign in to comment.