21 #include "ns3/config.h" 22 #include "ns3/string.h" 23 #include "ns3/pointer.h" 32 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
35 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
40 g_object_set (renderer,
"text", str.
Get ().c_str (), (
char*) 0);
41 g_object_set (renderer,
"editable", TRUE, (
char*) 0);
45 g_object_set (renderer,
"text",
"", (
char*) 0);
46 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
55 GtkTreeIter *iter, gpointer user_data)
58 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
59 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
66 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
69 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
73 std::stringstream oss;
75 g_object_set (renderer,
"text", oss.str ().c_str (), (
char*) 0);
79 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
89 gchar *new_text, gpointer user_data)
91 GtkTreeModel *model = GTK_TREE_MODEL (user_data);
93 gtk_tree_model_get_iter_from_string (model, &iter, path_string);
95 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
109 g_return_val_if_fail (col != 0, -1);
110 g_return_val_if_fail (gtk_tree_view_column_get_tree_view(col) != 0, -1);
111 cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view(col)));
112 num = g_list_index (cols, (gpointer) col);
123 GtkTooltip *tooltip, gpointer user_data)
127 GtkTreeViewColumn * column;
128 if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), &
x, &y,
129 keyboard_tip, &model, 0, &iter))
133 if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
x, y, 0, &column, 0, 0))
140 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
147 std::string tip =
"This object is of type " 149 gtk_tooltip_set_text (tooltip, tip.c_str ());
158 std::string tip =
"This object is of type " 160 gtk_tooltip_set_text (tooltip, tip.c_str ());
169 std::string tip =
"This object is of type " 171 gtk_tooltip_set_text (tooltip, tip.c_str ());
177 uint32_t attrIndex = 0;
194 gtk_tooltip_set_text (tooltip, tip.c_str ());
206 gtk_tooltip_set_text (tooltip, tip.c_str ());
222 GtkTreeViewColumn *col;
223 GtkCellRenderer *renderer;
226 view = gtk_tree_view_new ();
227 g_object_set (view,
"has-tooltip", TRUE, (
char*) 0);
230 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_BOTH);
231 gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
233 col = gtk_tree_view_column_new ();
234 gtk_tree_view_column_set_title (col,
"Object Attributes");
235 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
236 renderer = gtk_cell_renderer_text_new ();
237 gtk_tree_view_column_pack_start (col, renderer, TRUE);
239 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
241 col = gtk_tree_view_column_new ();
242 gtk_tree_view_column_set_title (col,
"Attribute Value");
243 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
244 renderer = gtk_cell_renderer_text_new ();
246 gtk_tree_view_column_pack_start (col, renderer, TRUE);
249 gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (model));
251 g_object_unref (model);
266 GtkWidget *parent_window = GTK_WIDGET (user_data);
269 dialog = gtk_file_chooser_dialog_new (
"Save File", GTK_WINDOW (parent_window), GTK_FILE_CHOOSER_ACTION_SAVE,
270 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
271 GTK_RESPONSE_ACCEPT, (
char *) 0);
272 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
275 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
"config.txt");
277 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
281 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
288 gtk_widget_destroy (dialog);
297 GtkWidget *parent_window = GTK_WIDGET (user_data);
300 dialog = gtk_file_chooser_dialog_new (
"Open File", GTK_WINDOW (parent_window), GTK_FILE_CHOOSER_ACTION_OPEN,
301 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
302 GTK_RESPONSE_ACCEPT, (
char *) 0);
304 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
308 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
314 gtk_widget_destroy (dialog);
324 gtk_widget_hide (GTK_WIDGET (user_data));
334 gtk_widget_hide (GTK_WIDGET (user_data));
343 GtkTreeIter *iter, gpointer
data)
346 gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
COL_NODE, &node, -1);
360 GtkTreeModel *model, GtkTreeIter *iter,
364 gtk_tree_model_get (model, iter,
COL_TYPEID, &node, -1);
367 g_object_set (renderer,
"text", node->
defaultValue.c_str (), (
char*) 0);
368 g_object_set (renderer,
"editable", TRUE, (
char*) 0);
372 g_object_set (renderer,
"text",
"", (
char*) 0);
373 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
381 GtkTreeIter *iter, gpointer user_data)
384 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
385 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
389 g_object_set (renderer,
"text", node->
tid.
GetName ().c_str (), (
char*) 0);
392 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
405 gchar *new_text, gpointer user_data)
407 GtkTreeModel *model = GTK_TREE_MODEL (user_data);
409 gtk_tree_model_get_iter_from_string (model, &iter, path_string);
411 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
435 gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
439 GtkTreeViewColumn * column;
440 if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), &
x, &y,
441 keyboard_tip, &model, 0, &iter))
445 if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
x, y, 0, &column, 0, 0))
452 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
459 std::string tip =
"This object is of type " + node->
tid.
GetName ();
460 gtk_tooltip_set_text (tooltip, tip.c_str ());
466 uint32_t attrIndex = node->
index;
470 gtk_tooltip_set_text (tooltip, tip.c_str ());
481 gtk_tooltip_set_text (tooltip, tip.c_str ());
500 GtkWidget *parent_window = GTK_WIDGET (user_data);
503 dialog = gtk_file_chooser_dialog_new (
"Save File", GTK_WINDOW (parent_window), GTK_FILE_CHOOSER_ACTION_SAVE,
504 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
505 GTK_RESPONSE_ACCEPT, (
char *) 0);
506 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
509 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
"config.txt");
511 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
515 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
522 gtk_widget_destroy (dialog);
534 GtkWidget *parent_window = GTK_WIDGET (user_data);
537 dialog = gtk_file_chooser_dialog_new (
"Open File", GTK_WINDOW (parent_window), GTK_FILE_CHOOSER_ACTION_OPEN,
538 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
539 GTK_RESPONSE_ACCEPT, (
char *) 0);
541 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
545 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
551 gtk_widget_destroy (dialog);
561 GtkTreeViewColumn *col;
562 GtkCellRenderer *renderer;
565 view = gtk_tree_view_new ();
566 g_object_set (view,
"has-tooltip", TRUE, (
char*) 0);
569 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_BOTH);
570 gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
572 col = gtk_tree_view_column_new ();
573 gtk_tree_view_column_set_title (col,
"Object Attributes");
574 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
575 renderer = gtk_cell_renderer_text_new ();
576 gtk_tree_view_column_pack_start (col, renderer, TRUE);
578 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
580 col = gtk_tree_view_column_new ();
581 gtk_tree_view_column_set_title (col,
"Attribute Value");
582 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
583 renderer = gtk_cell_renderer_text_new ();
585 gtk_tree_view_column_pack_start (col, renderer, TRUE);
588 gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (model));
590 g_object_unref (model);
600 GtkTreeIter *iter, gpointer
data)
603 gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
COL_TYPEID, &node, -1);
std::string GetName(void) const
Get the name.
A class to enable saving of configuration store in a raw text file.
std::string name
node name
Smart pointer class similar to boost::intrusive_ptr.
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
virtual void Attributes(void)
Load or save the attributes values.
Hold variables of type string.
enum ns3::ModelTypeid::@3 type
node type
void cell_data_function_col_1(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function includes the name of the attribute or the editable value in the second column...
virtual void SetFilename(std::string filename)
Set the file name.
Ptr< Object > GetObject(void) const
Get the Object referenced by the PointerValue.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
int get_col_number_from_tree_view_column(GtkTreeViewColumn *col)
This function gets the column number 0 or 1 from the mouse click.
bool HasParent(void) const
Check if this TypeId has a parent.
virtual void SetFilename(std::string filename)
Set the file name.
void cell_edited_callback(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
This is the callback called when the value of an attribute is changed.
TypeId GetParent(void) const
Get the parent of this TypeId.
virtual bool HasUnderlyingTypeInformation(void) const =0
enum ns3::ModelNode::@1 type
node type
std::string defaultValue
TypeId default value.
std::string Get(void) const
virtual std::string GetValueTypeName(void) const =0
void cell_data_function_col_1_config_default(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function writes data in the second column, this data is going to be editable if it is a NODE_ATT...
gboolean cell_tooltip_callback(GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
This function displays the tooltip for an object, pointer, vector item or an attribute.
gboolean cell_tooltip_callback_config_default(GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
This function is used to display a tooltip whenever the user puts the mouse over a type ID or an attr...
void load_clicked(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory.
Ptr< Object > object
the object
std::string name
TypeId name.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void cell_data_function_col_0_config_default(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function writes the attribute or typeid name in the column 0.
Hold objects of type Ptr<T>.
GtkWidget * create_view_config_default(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes...
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
virtual void Attributes(void)
Load or save the attributes values.
GtkWidget * create_view(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes...
A class used in the implementation of the GtkConfigStore.
virtual void Default(void)
Load or save the default values.
TypeId tid
The TypeId object and if it is an attribute, it's the TypeId object of the attribute.
void cell_edited_callback_config_default(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
This functions is called whenever there is a change in the value of an attribute If the input value i...
void cell_data_function_col_0(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function includes the name of the object, pointer, vector or vector item in the first column...
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void load_clicked_default(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory.
std::size_t GetAttributeN(void) const
Get the number of attributes.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
void exit_clicked_callback(GtkButton *button, gpointer user_data)
Exit the window when exit button is pressed.
gboolean clean_model_callback(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
uint32_t index
stores the index of the attribute in list of attributes for a given TypeId
gboolean clean_model_callback_config_default(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
void save_clicked_default(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button.
A class used in the implementation of the GtkConfigStore.
virtual std::string GetUnderlyingTypeInformation(void) const =0
gboolean delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
Exit the application.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
A class to enable loading of configuration store from a raw text file.
a unique identifier for an interface.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
void save_clicked(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button.
virtual void Default(void)
Load or save the default values.