A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
gtk-config-store.cc
Go to the documentation of this file.
1
/*
2
* SPDX-License-Identifier: GPL-2.0-only
3
*
4
* Authors: Faker Moatamri <faker.moatamri@sophia.inria.fr>
5
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
6
*/
7
8
#include "
gtk-config-store.h
"
9
10
#include "
display-functions.h
"
11
#include "
raw-text-config.h
"
12
13
#include "ns3/log.h"
14
15
#include <fstream>
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"GtkconfigStore"
);
21
22
GtkConfigStore::GtkConfigStore
()
23
{
24
}
25
26
void
27
GtkConfigStore::ConfigureDefaults
()
28
{
29
// this function should be called before running the script to enable the user
30
// to configure the default values for the objects he wants to use
31
GtkWidget
* window;
32
GtkWidget
*
view
;
33
GtkWidget
*
scroll
;
34
35
gtk_init
(
nullptr
,
nullptr
);
36
window =
gtk_window_new
(
GTK_WINDOW_TOPLEVEL
);
37
gtk_window_set_title
(
GTK_WINDOW
(window),
"ns-3 Default attributes."
);
38
gtk_window_set_default_size
(
GTK_WINDOW
(window), 600, 600);
39
40
g_signal_connect
(window,
"delete_event"
, (
GCallback
)
delete_event_callback
, window);
41
GtkTreeStore
*
model
=
gtk_tree_store_new
(
COL_LAST
,
G_TYPE_POINTER
);
42
ModelTypeidCreator
creator
;
43
creator
.
Build
(
model
);
44
45
view
=
create_view_config_default
(
model
);
46
scroll
=
gtk_scrolled_window_new
(
nullptr
,
nullptr
);
47
gtk_container_add
(
GTK_CONTAINER
(
scroll
),
view
);
48
49
GtkWidget
*
vbox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
, 5);
50
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
scroll
,
TRUE
,
TRUE
, 0);
51
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
gtk_separator_new
(
GTK_ORIENTATION_HORIZONTAL
),
FALSE
,
FALSE
, 0);
52
GtkWidget
*
hbox
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
, 5);
53
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
hbox
,
FALSE
,
FALSE
, 0);
54
GtkWidget
*
save
=
gtk_button_new_with_label
(
"Save"
);
55
g_signal_connect
(
save
,
"clicked"
, (
GCallback
)
save_clicked_default
, window);
56
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
save
,
FALSE
,
FALSE
, 0);
57
GtkWidget
*
load
=
gtk_button_new_with_label
(
"Load"
);
58
g_signal_connect
(
load
,
"clicked"
, (
GCallback
)
load_clicked_default
, window);
59
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
load
,
FALSE
,
FALSE
, 0);
60
GtkWidget
*
exit
=
gtk_button_new_with_label
(
"Run Simulation"
);
61
g_signal_connect
(
exit
,
"clicked"
, (
GCallback
)
exit_clicked_callback
, window);
62
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
exit
,
FALSE
,
FALSE
, 0);
63
64
gtk_container_add
(
GTK_CONTAINER
(window),
vbox
);
65
66
gtk_widget_show_all
(window);
67
68
gtk_main
();
69
70
gtk_tree_model_foreach
(
GTK_TREE_MODEL
(
model
),
clean_model_callback_config_default
,
nullptr
);
71
72
gtk_widget_destroy
(window);
73
}
74
75
void
76
GtkConfigStore::ConfigureAttributes
()
77
{
78
GtkWidget
* window;
79
GtkWidget
*
view
;
80
GtkWidget
*
scroll
;
81
82
gtk_init
(
nullptr
,
nullptr
);
83
84
window =
gtk_window_new
(
GTK_WINDOW_TOPLEVEL
);
85
gtk_window_set_title
(
GTK_WINDOW
(window),
"ns-3 Object attributes."
);
86
gtk_window_set_default_size
(
GTK_WINDOW
(window), 600, 600);
87
88
g_signal_connect
(window,
"delete_event"
, (
GCallback
)
delete_event_callback
, window);
89
90
GtkTreeStore
*
model
=
gtk_tree_store_new
(
COL_LAST
,
G_TYPE_POINTER
);
91
ModelCreator
creator
;
92
creator
.
Build
(
model
);
93
94
view
=
create_view
(
model
);
95
scroll
=
gtk_scrolled_window_new
(
nullptr
,
nullptr
);
96
gtk_container_add
(
GTK_CONTAINER
(
scroll
),
view
);
97
98
GtkWidget
*
vbox
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
, 5);
99
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
scroll
,
TRUE
,
TRUE
, 0);
100
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
gtk_separator_new
(
GTK_ORIENTATION_HORIZONTAL
),
FALSE
,
FALSE
, 0);
101
GtkWidget
*
hbox
=
gtk_box_new
(
GTK_ORIENTATION_HORIZONTAL
, 5);
102
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
hbox
,
FALSE
,
FALSE
, 0);
103
GtkWidget
*
save
=
gtk_button_new_with_label
(
"Save"
);
104
g_signal_connect
(
save
,
"clicked"
, (
GCallback
)
save_clicked_attribute
, window);
105
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
save
,
FALSE
,
FALSE
, 0);
106
GtkWidget
*
load
=
gtk_button_new_with_label
(
"Load"
);
107
g_signal_connect
(
load
,
"clicked"
, (
GCallback
)
load_clicked_attribute
, window);
108
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
load
,
FALSE
,
FALSE
, 0);
109
GtkWidget
*
exit
=
gtk_button_new_with_label
(
"Run Simulation"
);
110
g_signal_connect
(
exit
,
"clicked"
, (
GCallback
)
exit_clicked_callback
, window);
111
gtk_box_pack_end
(
GTK_BOX
(
hbox
),
exit
,
FALSE
,
FALSE
, 0);
112
113
gtk_container_add
(
GTK_CONTAINER
(window),
vbox
);
114
115
gtk_widget_show_all
(window);
116
117
gtk_main
();
118
119
gtk_tree_model_foreach
(
GTK_TREE_MODEL
(
model
),
clean_model_callback
,
nullptr
);
120
121
gtk_widget_destroy
(window);
122
}
123
124
}
// namespace ns3
ns3::GtkConfigStore::ConfigureDefaults
void ConfigureDefaults()
Process default values.
Definition
gtk-config-store.cc:27
ns3::GtkConfigStore::ConfigureAttributes
void ConfigureAttributes()
Process attribute values.
Definition
gtk-config-store.cc:76
ns3::GtkConfigStore::GtkConfigStore
GtkConfigStore()
Definition
gtk-config-store.cc:22
ns3::ModelCreator
ModelCreator class.
Definition
model-node-creator.h:55
ns3::ModelCreator::Build
void Build(GtkTreeStore *treestore)
Allocate attribute tree.
Definition
model-node-creator.cc:19
ns3::ModelTypeidCreator
ModelTypeIdCreator class.
Definition
model-typeid-creator.h:55
ns3::ModelTypeidCreator::Build
void Build(GtkTreeStore *treestore)
This method will iterate on typeIds having default attributes and create a model for them,...
Definition
model-typeid-creator.cc:18
display-functions.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
gtk-config-store.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::clean_model_callback
gboolean clean_model_callback(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
Definition
display-functions.cc:318
ns3::COL_LAST
@ COL_LAST
Definition
model-node-creator.h:18
ns3::save_clicked_attribute
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.
Definition
display-functions.cc:584
ns3::delete_event_callback
gboolean delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
Exit the application.
Definition
display-functions.cc:307
ns3::exit_clicked_callback
void exit_clicked_callback(GtkButton *button, gpointer user_data)
Exit the window when exit button is pressed.
Definition
display-functions.cc:297
ns3::create_view_config_default
GtkWidget * create_view_config_default(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes.
Definition
display-functions.cc:651
ns3::clean_model_callback_config_default
gboolean clean_model_callback_config_default(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
Definition
display-functions.cc:699
ns3::create_view
GtkWidget * create_view(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes....
Definition
display-functions.cc:249
ns3::save_clicked_default
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.
Definition
display-functions.cc:514
ns3::load_clicked_default
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...
Definition
display-functions.cc:552
ns3::load_clicked_attribute
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.
Definition
display-functions.cc:622
raw-text-config.h
src
config-store
model
gtk-config-store.cc
Generated on Mon Dec 15 2025 15:21:49 for ns-3 by
1.9.8