22 #include "ns3/config.h"
23 #include "ns3/string.h"
24 #include "ns3/pointer.h"
33 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
36 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
45 g_object_set (renderer,
"text", str.
Get ().c_str (), (
char*) 0);
46 g_object_set (renderer,
"editable", TRUE, (
char*) 0);
50 g_object_set (renderer,
"text",
"", (
char*) 0);
51 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
60 GtkTreeIter *iter, gpointer user_data)
63 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
64 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
76 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
79 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
83 std::stringstream oss;
85 g_object_set (renderer,
"text", oss.str ().c_str (), (
char*) 0);
89 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
99 gchar *new_text, gpointer user_data)
101 GtkTreeModel *model = GTK_TREE_MODEL (user_data);
103 gtk_tree_model_get_iter_from_string (model, &iter, path_string);
105 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
123 g_return_val_if_fail (col != 0, -1);
124 g_return_val_if_fail (gtk_tree_view_column_get_tree_view(col) != 0, -1);
125 cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view(col)));
126 num = g_list_index (cols, (gpointer) col);
137 GtkTooltip *tooltip, gpointer user_data)
141 GtkTreeViewColumn * column;
142 if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), &
x, &y,
143 keyboard_tip, &model, 0, &iter))
147 if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
x, y, 0, &column, 0, 0))
154 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
165 std::string tip =
"This object is of type "
167 gtk_tooltip_set_text (tooltip, tip.c_str ());
176 std::string tip =
"This object is of type "
178 gtk_tooltip_set_text (tooltip, tip.c_str ());
187 std::string tip =
"This object is of type "
189 gtk_tooltip_set_text (tooltip, tip.c_str ());
195 uint32_t attrIndex = 0;
212 gtk_tooltip_set_text (tooltip, tip.c_str ());
219 tip =
"This attribute is of type " + checker->GetValueTypeName ();
220 if (checker->HasUnderlyingTypeInformation ())
222 tip +=
" " + checker->GetUnderlyingTypeInformation ();
224 gtk_tooltip_set_text (tooltip, tip.c_str ());
240 GtkTreeViewColumn *col;
241 GtkCellRenderer *renderer;
244 view = gtk_tree_view_new ();
245 g_object_set (view,
"has-tooltip", TRUE, (
char*) 0);
248 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_BOTH);
251 col = gtk_tree_view_column_new ();
252 gtk_tree_view_column_set_title (col,
"Object Attributes");
253 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
254 renderer = gtk_cell_renderer_text_new ();
255 gtk_tree_view_column_pack_start (col, renderer, TRUE);
257 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
259 col = gtk_tree_view_column_new ();
260 gtk_tree_view_column_set_title (col,
"Attribute Value");
261 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
262 renderer = gtk_cell_renderer_text_new ();
264 gtk_tree_view_column_pack_start (col, renderer, TRUE);
267 gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (model));
269 g_object_unref (model);
281 gtk_widget_hide (GTK_WIDGET (user_data));
291 gtk_widget_hide (GTK_WIDGET (user_data));
300 GtkTreeIter *iter, gpointer
data)
303 gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
COL_NODE, &node, -1);
320 GtkTreeModel *model, GtkTreeIter *iter,
324 gtk_tree_model_get (model, iter,
COL_TYPEID, &node, -1);
331 g_object_set (renderer,
"text", node->
defaultValue.c_str (), (
char*) 0);
332 g_object_set (renderer,
"editable", TRUE, (
char*) 0);
336 g_object_set (renderer,
"text",
"", (
char*) 0);
337 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
345 GtkTreeIter *iter, gpointer user_data)
348 gtk_tree_model_get (model, iter,
COL_NODE, &node, -1);
349 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
358 g_object_set (renderer,
"text", node->
tid.
GetName ().c_str (), (
char*) 0);
361 g_object_set (renderer,
"text", node->
name.c_str (), (
char*) 0);
374 gchar *new_text, gpointer user_data)
376 GtkTreeModel *model = GTK_TREE_MODEL (user_data);
378 gtk_tree_model_get_iter_from_string (model, &iter, path_string);
380 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
408 gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
412 GtkTreeViewColumn * column;
413 if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (widget), &
x, &y,
414 keyboard_tip, &model, 0, &iter))
418 if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
x, y, 0, &column, 0, 0))
425 gtk_tree_model_get (model, &iter,
COL_NODE, &node, -1);
436 std::string tip =
"This object is of type " + node->
tid.
GetName ();
437 gtk_tooltip_set_text (tooltip, tip.c_str ());
443 uint32_t attrIndex = node->
index;
447 gtk_tooltip_set_text (tooltip, tip.c_str ());
453 tip =
"This attribute is of type " + checker->GetValueTypeName ();
454 if (checker->HasUnderlyingTypeInformation ())
456 tip +=
" " + checker->GetUnderlyingTypeInformation ();
458 gtk_tooltip_set_text (tooltip, tip.c_str ());
477 GtkWindow *parent_window = GTK_WINDOW (user_data);
479 GtkFileChooserNative *native;
480 GtkFileChooser *chooser;
481 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
484 native = gtk_file_chooser_native_new (
"Save File",
489 chooser = GTK_FILE_CHOOSER (native);
491 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
493 gtk_file_chooser_set_current_name (chooser, (
"config-defaults.txt"));
495 res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
496 if (res == GTK_RESPONSE_ACCEPT)
500 filename = gtk_file_chooser_get_filename (chooser);
507 g_object_unref (native);
519 GtkWindow *parent_window = GTK_WINDOW (user_data);
520 GtkFileChooserNative *native;
521 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
524 native = gtk_file_chooser_native_new (
"Open File",
530 res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
531 if (res == GTK_RESPONSE_ACCEPT)
534 GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
535 filename = gtk_file_chooser_get_filename (chooser);
542 g_object_unref (native);
555 GtkWindow *parent_window = GTK_WINDOW (user_data);
557 GtkFileChooserNative *native;
558 GtkFileChooser *chooser;
559 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
562 native = gtk_file_chooser_native_new (
"Save File",
567 chooser = GTK_FILE_CHOOSER (native);
569 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
571 gtk_file_chooser_set_current_name (chooser, (
"config-attributes.txt"));
573 res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
574 if (res == GTK_RESPONSE_ACCEPT)
578 filename = gtk_file_chooser_get_filename (chooser);
585 g_object_unref (native);
597 GtkWindow *parent_window = GTK_WINDOW (user_data);
598 GtkFileChooserNative *native;
599 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
602 native = gtk_file_chooser_native_new (
"Open File",
608 res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
609 if (res == GTK_RESPONSE_ACCEPT)
612 GtkFileChooser *chooser = GTK_FILE_CHOOSER (native);
613 filename = gtk_file_chooser_get_filename (chooser);
620 g_object_unref (native);
630 GtkTreeViewColumn *col;
631 GtkCellRenderer *renderer;
634 view = gtk_tree_view_new ();
635 g_object_set (view,
"has-tooltip", TRUE, (
char*) 0);
638 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_BOTH);
641 col = gtk_tree_view_column_new ();
642 gtk_tree_view_column_set_title (col,
"Object Attributes");
643 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
644 renderer = gtk_cell_renderer_text_new ();
645 gtk_tree_view_column_pack_start (col, renderer, TRUE);
647 g_object_set (renderer,
"editable", FALSE, (
char*) 0);
649 col = gtk_tree_view_column_new ();
650 gtk_tree_view_column_set_title (col,
"Attribute Value");
651 gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
652 renderer = gtk_cell_renderer_text_new ();
654 gtk_tree_view_column_pack_start (col, renderer, TRUE);
657 gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (model));
659 g_object_unref (model);
669 GtkTreeIter *iter, gpointer
data)
672 gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
COL_TYPEID, &node, -1);
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Hold objects of type Ptr<T>.
Ptr< Object > GetObject(void) const
Get the Object referenced by the PointerValue.
Smart pointer class similar to boost::intrusive_ptr.
A class to enable loading of configuration store from a raw text file.
virtual void Default(void)
Load or save the default values.
virtual void SetFilename(std::string filename)
Set the file name.
virtual void Attributes(void)
Load or save the attributes values.
A class to enable saving of configuration store in a raw text file.
virtual void Attributes(void)
Load or save the attributes values.
virtual void SetFilename(std::string filename)
Set the file name.
virtual void Default(void)
Load or save the default values.
Hold variables of type string.
std::string Get(void) const
a unique identifier for an interface.
std::size_t GetAttributeN(void) const
Get the number of attributes.
bool HasParent(void) const
Check if this TypeId has a parent.
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
TypeId GetParent(void) const
Get the parent of this TypeId.
std::string GetName(void) const
Get the name.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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 clean_model_callback(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
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.
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.
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.
void save_clicked_attribute(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button for the Attributes.
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...
gboolean delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
Exit the application.
void exit_clicked_callback(GtkButton *button, gpointer user_data)
Exit the window when exit button is pressed.
GtkWidget * create_view_config_default(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes.
gboolean clean_model_callback_config_default(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
int get_col_number_from_tree_view_column(GtkTreeViewColumn *col)
This function gets the column number 0 or 1 from the mouse click.
GtkWidget * create_view(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes....
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.
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 save_clicked_default(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button for the Default attributes.
void load_clicked_default(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory for the Default attribu...
void load_clicked_attribute(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory for the Attributes.
list x
Random number samples.
A class used in the implementation of the GtkConfigStore.
enum ns3::ModelNode::@2 type
node type
Ptr< Object > object
the object
std::string name
node name
A class used in the implementation of the GtkConfigStore.
uint32_t index
stores the index of the attribute in list of attributes for a given TypeId
TypeId tid
The TypeId object and if it is an attribute, it's the TypeId object of the attribute.
enum ns3::ModelTypeid::@4 type
node type
std::string defaultValue
TypeId default value.
std::string name
TypeId name.