@@ -1216,6 +1216,45 @@ imagewindow_properties(GSimpleAction *action,
12161216 g_simple_action_set_state (action , state );
12171217}
12181218
1219+ static void
1220+ imagewindow_region_action (GSimpleAction * action ,
1221+ GVariant * state , gpointer user_data )
1222+ {
1223+ Imagewindow * win = IMAGEWINDOW (user_data );
1224+
1225+ if (win -> action_view &&
1226+ IS_REGIONVIEW (win -> action_view )) {
1227+ const char * name = g_action_get_name (G_ACTION (action ));
1228+ Regionview * regionview = REGIONVIEW (win -> action_view );
1229+ Row * row = HEAPMODEL (regionview -> classmodel )-> row ;
1230+ Workspace * ws = row -> ws ;
1231+
1232+ if (g_str_equal (name , "region-duplicate" )) {
1233+ row_select (row );
1234+ if (!workspace_selected_duplicate (ws ))
1235+ workspace_set_show_error (row -> ws , TRUE);
1236+ workspace_deselect_all (ws );
1237+
1238+ symbol_recalculate_all ();
1239+ }
1240+ else if (g_str_equal (name , "region-reset" )) {
1241+ (void ) icontainer_map_all (ICONTAINER (row ),
1242+ (icontainer_map_fn ) model_clear_edited , NULL );
1243+
1244+ symbol_recalculate_all ();
1245+ }
1246+ else if (g_str_equal (name , "region-saveas" )) {
1247+ Model * graphic = row -> child_rhs -> graphic ;
1248+
1249+ classmodel_graphic_save (CLASSMODEL (graphic ), GTK_WINDOW (win ));
1250+ }
1251+ else if (g_str_equal (name , "region-delete" ))
1252+ IDESTROY (row -> sym );
1253+
1254+ win -> action_view = NULL ;
1255+ }
1256+ }
1257+
12191258static GActionEntry imagewindow_entries [] = {
12201259 { "copy" , imagewindow_copy_action },
12211260 { "paste" , imagewindow_paste_action },
@@ -1250,6 +1289,12 @@ static GActionEntry imagewindow_entries[] = {
12501289 imagewindow_background },
12511290
12521291 { "reset" , imagewindow_reset },
1292+
1293+ { "region-duplicate" , imagewindow_region_action },
1294+ { "region-reset" , imagewindow_region_action },
1295+ { "region-saveas" , imagewindow_region_action },
1296+ { "region-delete" , imagewindow_region_action },
1297+
12531298};
12541299
12551300static void
@@ -1367,8 +1412,10 @@ imagewindow_pressed(GtkGestureClick *gesture,
13671412 menu = win -> region_menu ;
13681413 win -> action_view = VIEW (regionview );
13691414 }
1370- else
1415+ else {
13711416 menu = win -> right_click_menu ;
1417+ win -> action_view = NULL ;
1418+ }
13721419
13731420 gtk_popover_set_pointing_to (GTK_POPOVER (menu ),
13741421 & (const GdkRectangle ){ x , y , 1 , 1 });
0 commit comments