Commit fca1f0fc authored by Claes Sjofors's avatar Claes Sjofors

Profinet configuration: expand all and collapse added, everything expanded...

Profinet configuration: expand all and collapse added, everything expanded before save to make all initialisations
parent 429e4476
......@@ -183,6 +183,20 @@ void GsdmlAttrGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
attr->activate_zoom_reset();
}
void GsdmlAttrGtk::activate_collapse( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_collapse();
}
void GsdmlAttrGtk::activate_expand_all( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_expand_all();
}
void GsdmlAttrGtk::activate_print( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
......@@ -343,10 +357,18 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
menubutton_paste = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect( menubutton_paste, "activate", G_CALLBACK(activate_paste), this);
GtkWidget *edit_collapse = gtk_menu_item_new_with_mnemonic("C_ollapse");
g_signal_connect( edit_collapse, "activate", G_CALLBACK(activate_collapse), this);
GtkWidget *edit_expand_all = gtk_menu_item_new_with_mnemonic("_Expand All");
g_signal_connect( edit_expand_all, "activate", G_CALLBACK(activate_expand_all), this);
GtkMenu *edit_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_copy);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_cut);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_paste);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_collapse);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_expand_all);
GtkWidget *edit = gtk_menu_item_new_with_mnemonic("_Edit");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit);
......
......@@ -69,6 +69,8 @@ class GsdmlAttrGtk : public GsdmlAttr {
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_collapse( GtkWidget *w, gpointer data);
static void activate_expand_all( GtkWidget *w, gpointer data);
static void activate_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_ok( GtkWidget *w, gpointer data);
static void cmd_close_apply_cb( void *ctx, void *data);
......
......@@ -176,6 +176,16 @@ void GsdmlAttr::activate_zoom_reset()
attrnav->unzoom();
}
void GsdmlAttr::activate_collapse()
{
attrnav->collapse();
}
void GsdmlAttr::activate_expand_all()
{
attrnav->expand_all();
}
void GsdmlAttr::activate_print()
{
char filename[80] = "pwrp_tmp:wnav.ps";
......
......@@ -82,6 +82,8 @@ class GsdmlAttr {
void activate_zoom_reset();
void activate_cmd_ok();
void activate_cmd_ca();
void activate_collapse();
void activate_expand_all();
static void gsdmlattr_message( void *attr, char severity, const char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
......
......@@ -494,6 +494,65 @@ void GsdmlAttrNav::unzoom()
brow_UnZoom( brow->ctx);
}
//
// Collapse
//
void GsdmlAttrNav::collapse()
{
brow_tObject *olist;
int ocnt;
ItemPn *item;
brow_SetNodraw( brow->ctx);
brow_GetObjectList( brow->ctx, &olist, &ocnt);
for ( int i = ocnt - 1; i >= 0; i--) {
if ( brow_GetObjectLevel( olist[i]) == 0) {
brow_GetUserData( olist[i], (void **)&item);
item->close( this, 0, 0);
}
}
brow_CenterObject( brow->ctx, olist[0], 0);
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
}
//
// Expand all items
//
void GsdmlAttrNav::expand_all()
{
brow_tObject *olist;
int ocnt;
ItemPn *item;
brow_SetNodraw( brow->ctx);
collapse();
brow_GetObjectList( brow->ctx, &olist, &ocnt);
for ( int i = 0; i < ocnt; i++) {
brow_GetUserData( olist[i], (void **)&item);
if ( !( item->type == attrnav_eItemType_PnParEnum ||
item->type == attrnav_eItemType_PnDevice ||
item->type == attrnav_eItemType_PnModuleType ||
item->type == attrnav_eItemType_PnDataItem ||
item->type == attrnav_eItemType_PnModuleClass ||
item->type == attrnav_eItemType_PnEnumByteOrder ||
item->type == attrnav_eItemType_PnEnumTimeRatio ||
item->type == attrnav_eItemType_PnEnumSendClock))
item->open_children( this, 0, 0);
brow_GetObjectList( brow->ctx, &olist, &ocnt);
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
}
// Get selected item
int GsdmlAttrNav::get_select( ItemPn **item)
{
......@@ -1355,6 +1414,10 @@ int GsdmlAttrNav::save( const char *filename)
if ( device_num == 0)
return PB__NODEVICE;
// Be sure all items are initialized, expand all
brow_SetNodraw( brow->ctx);
expand_all();
strncpy( dev_data.device_text, (char *)device_item->ModuleInfo->Body.Name.p, sizeof(dev_data.device_text));
dev_data.vendor_id = gsdml->DeviceIdentity->Body.VendorID;
dev_data.device_id = gsdml->DeviceIdentity->Body.DeviceID;
......@@ -1560,6 +1623,10 @@ int GsdmlAttrNav::save( const char *filename)
}
}
collapse();
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
return dev_data.print( filename);
// Unload channel diag
......@@ -1684,7 +1751,6 @@ void ItemPnBase::value_changed( GsdmlAttrNav *attrnav, char *value_str)
memcpy( value_p, buffer, size);
attrnav->set_modified(1);
}
int ItemPn::close( GsdmlAttrNav *attrnav, double x, double y)
{
double node_x, node_y;
......
......@@ -177,6 +177,8 @@ class GsdmlAttrNav {
int is_modified() { return modified;}
int save( const char *filename);
int open( const char *filename);
void collapse();
void expand_all();
void redraw();
void set_viewio( int set) { viewio = set;}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment