@@ -824,14 +824,6 @@ workspaceview_merge(Workspaceview *wview)
824824 & workspaceview_merge_sub , wview );
825825}
826826
827- static void *
828- workspaceview_find_workspace (Workspace * ws , void * a )
829- {
830- const char * name = (const char * ) a ;
831-
832- return g_str_equal (IOBJECT (ws )-> name , name ) ? ws : NULL ;
833- }
834-
835827static void
836828workspaceview_action (GSimpleAction * action , GVariant * parameter , View * view )
837829{
@@ -841,41 +833,48 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
841833 Workspace * ws = WORKSPACE (VOBJECT (wview )-> iobject );
842834 const char * name = g_action_get_name (G_ACTION (action ));
843835
844- if (g_str_equal (name , "column-new" ))
836+ if (g_str_equal (name , "column-new" ) &&
837+ !ws -> locked )
845838 workspace_column_new (ws );
846839 else if (g_str_equal (name , "next-error" ))
847840 workspace_set_show_error (ws , workspace_next_error (ws ));
848- else if (g_str_equal (name , "program" ))
841+ else if (g_str_equal (name , "program" ) &&
842+ !ws -> locked )
849843 program_new (app , ws -> kitg );
850- else if (g_str_equal (name , "tab-rename" ))
844+ else if (g_str_equal (name , "tab-rename" ) &&
845+ !ws -> locked )
851846 g_object_set (wview -> label ,
852847 "edit" , TRUE,
853848 NULL );
854- else if (g_str_equal (name , "tab-select-all" )) {
855- if (!ws -> locked )
856- workspace_select_all (ws );
857- }
849+ else if (g_str_equal (name , "tab-select-all" ) &&
850+ !ws -> locked )
851+ workspace_select_all (ws );
858852 else if (g_str_equal (name , "tab-duplicate" ))
859853 workspace_duplicate (ws );
860854 else if (g_str_equal (name , "tab-merge" ) &&
861- parameter ) {
855+ parameter &&
856+ !ws -> locked ) {
857+ const char * from_name = g_variant_get_string (parameter , NULL );
862858 Workspacegroup * wsg = workspace_get_workspacegroup (ws );
863- Workspace * from = workspacegroup_map (wsg ,
864- workspaceview_find_workspace ,
865- (void * ) g_variant_get_string (parameter , NULL ), NULL );
866- char filename [VIPS_PATH_MAX ];
867859
860+ Workspace * from ;
861+
862+ if (!(from = workspacegroup_find_workspace (wsg , from_name )))
863+ return ;
864+
865+ char filename [VIPS_PATH_MAX ];
868866 if (!temp_name (filename , IOBJECT (from )-> name , "ws" )) {
869867 workspace_set_show_error (ws , TRUE);
870868 return ;
871869 }
872870
873- icontainer_current (ICONTAINER (wsg ), ICONTAINER (ws ));
871+ icontainer_current (ICONTAINER (wsg ), ICONTAINER (from ));
874872 if (!workspacegroup_save_current (wsg , filename )) {
875873 workspace_set_show_error (ws , TRUE);
876874 return ;
877875 }
878876
877+ icontainer_current (ICONTAINER (wsg ), ICONTAINER (ws ));
879878 if (!workspace_merge_file (ws , filename )) {
880879 workspace_set_show_error (ws , TRUE);
881880 return ;
@@ -886,7 +885,8 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
886885 workspace_deselect_all (ws );
887886 symbol_recalculate_all ();
888887 }
889- else if (g_str_equal (name , "tab-merge-file" ))
888+ else if (g_str_equal (name , "tab-merge-file" ) &&
889+ !ws -> locked )
890890 workspaceview_merge (wview );
891891 else if (g_str_equal (name , "tab-saveas" ))
892892 workspaceview_saveas (wview );
@@ -896,10 +896,9 @@ workspaceview_action(GSimpleAction *action, GVariant *parameter, View *view)
896896 GVariant * locked = g_variant_new_boolean (ws -> locked );
897897 g_simple_action_set_state (action , locked );
898898 }
899- else if (g_str_equal (name , "tab-delete" )) {
900- if (!ws -> locked )
901- model_check_destroy (view_get_window (VIEW (wview )), MODEL (ws ));
902- }
899+ else if (g_str_equal (name , "tab-delete" ) &&
900+ !ws -> locked )
901+ model_check_destroy (view_get_window (VIEW (wview )), MODEL (ws ));
903902}
904903
905904static void
0 commit comments