forked from verilog-to-routing/vtr-verilog-to-routing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add gtkcomboboxhelper functions, some opetions were changed from int-…
…index to string-value type, to have more robust way to transmit request between client and server
- Loading branch information
Showing
7 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "gtkcomboboxhelper.h" | ||
#include <gtk/gtk.h> | ||
|
||
gint get_item_count(gpointer combo_box) { | ||
GtkComboBoxText* combo = GTK_COMBO_BOX_TEXT(combo_box); | ||
|
||
// Get the model of the combo box | ||
GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | ||
|
||
// Get the number of items (indexes) in the combo box | ||
gint count = gtk_tree_model_iter_n_children(model, NULL); | ||
return count; | ||
} | ||
|
||
gint get_item_index_by_text(gpointer combo_box, gchar* target_item) { | ||
gint result_index = -1; | ||
GtkComboBoxText* combo = GTK_COMBO_BOX_TEXT(combo_box); | ||
|
||
// Get the model of the combo box | ||
GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); | ||
|
||
gchar* current_item_text = nullptr; | ||
|
||
for (gint index=0; index<get_item_count(combo_box); ++index) { | ||
GtkTreeIter iter; | ||
|
||
// Check if the index is within bounds | ||
if (gtk_tree_model_iter_nth_child(model, &iter, NULL, index)) { | ||
gtk_tree_model_get(model, &iter, 0, ¤t_item_text, -1); | ||
if (g_strcmp0(target_item, current_item_text) == 0) { | ||
result_index = index; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
g_free(current_item_text); | ||
return result_index; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GTKCOMBOBOXHELPER_H | ||
#define GTKCOMBOBOXHELPER_H | ||
|
||
#include <glib.h> | ||
|
||
gint get_item_count(gpointer combo_box); | ||
|
||
gint get_item_index_by_text(gpointer combo_box, gchar* target_item); | ||
|
||
#endif // GTKCOMBOBOXHELPER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
#ifndef STANDALONE_APP | ||
namespace ezgl { | ||
class application; | ||
}; | ||
} | ||
#endif | ||
|
||
class TaskResolver { | ||
|